52 |
static RC_STMT *rc_stmt_create(enum rc_stmt_type type); |
static RC_STMT *rc_stmt_create(enum rc_stmt_type type); |
53 |
static void rc_stmt_destroy(RC_STMT *stmt); |
static void rc_stmt_destroy(RC_STMT *stmt); |
54 |
static void rc_stmt_list_destroy(RC_STMT *stmt); |
static void rc_stmt_list_destroy(RC_STMT *stmt); |
55 |
static void rc_stmt_print(RC_STMT *stmt); |
static void rc_stmt_print(RC_STMT *stmt, int level); |
56 |
static void reg_option_init(); |
static void reg_option_init(); |
57 |
static int reg_option_add(char *opt); |
static int reg_option_add(char *opt); |
58 |
|
|
406 |
rc_section_print(RC_SECTION *sect) |
rc_section_print(RC_SECTION *sect) |
407 |
{ |
{ |
408 |
for (; sect; sect = sect->next) { |
for (; sect; sect = sect->next) { |
409 |
printf("BEGIN %s\n", sect->name); |
printf("BEGIN SECTION %s\n", sect->name); |
410 |
rc_stmt_print(sect->stmt); |
rc_stmt_print(sect->stmt, 1); |
411 |
printf("END %s\n", sect->name); |
printf("END SECTION %s\n", sect->name); |
412 |
} |
} |
413 |
} |
} |
414 |
|
|
572 |
} |
} |
573 |
|
|
574 |
void |
void |
575 |
rc_stmt_print(RC_STMT *stmt) |
rc_level_print(int level, char *str) |
576 |
|
{ |
577 |
|
int i; |
578 |
|
|
579 |
|
for (i = 0; i < level*2; i++) |
580 |
|
putchar(' '); |
581 |
|
printf("%s", str); |
582 |
|
} |
583 |
|
|
584 |
|
void |
585 |
|
rc_stmt_print(RC_STMT *stmt, int level) |
586 |
{ |
{ |
587 |
for (; stmt; stmt = stmt->next) { |
for (; stmt; stmt = stmt->next) { |
588 |
switch (stmt->type) { |
switch (stmt->type) { |
589 |
case rc_stmt_asgn: |
case rc_stmt_asgn: |
590 |
printf("ASGN: %s = %s", |
rc_level_print(level, "ASGN: "); |
591 |
|
printf("%s = %s", |
592 |
stmt->v.asgn.lhs, stmt->v.asgn.rhs); |
stmt->v.asgn.lhs, stmt->v.asgn.rhs); |
593 |
break; |
break; |
594 |
|
|
595 |
case rc_stmt_cond: |
case rc_stmt_cond: |
596 |
printf("COND: "); |
rc_level_print(level, "COND: "); |
597 |
rc_node_print(stmt->v.cond.node); |
rc_node_print(stmt->v.cond.node); |
598 |
printf("\nIFTRUE:\n"); |
printf("\n"); |
599 |
rc_stmt_print(stmt->v.cond.iftrue); |
rc_level_print(level, "IFTRUE:\n"); |
600 |
|
rc_stmt_print(stmt->v.cond.iftrue, level+1); |
601 |
if (stmt->v.cond.iffalse) { |
if (stmt->v.cond.iffalse) { |
602 |
printf("IFFALSE:\n"); |
rc_level_print(level, "IFFALSE:\n"); |
603 |
rc_stmt_print(stmt->v.cond.iffalse); |
rc_stmt_print(stmt->v.cond.iffalse, level+1); |
604 |
} |
} |
605 |
printf("END COND"); |
rc_level_print(level, "END COND"); |
606 |
break; |
break; |
607 |
|
|
608 |
case rc_stmt_rule: |
case rc_stmt_rule: |
609 |
printf("RULE: "); |
rc_level_print(level, "RULE: "); |
610 |
rc_node_print(stmt->v.rule.node); |
rc_node_print(stmt->v.rule.node); |
611 |
printf("\nBODY\n"); |
printf("\n"); |
612 |
rc_stmt_print(stmt->v.rule.stmt); |
rc_level_print(level, "BODY\n"); |
613 |
printf("END RULE"); |
rc_stmt_print(stmt->v.rule.stmt, level+1); |
614 |
|
rc_level_print(level, "END RULE"); |
615 |
break; |
break; |
616 |
|
|
617 |
default: |
default: |