projects
/
cparser
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix goto and label printing
[cparser]
/
ast.c
diff --git
a/ast.c
b/ast.c
index
93ba57f
..
3d8c045
100644
(file)
--- a/
ast.c
+++ b/
ast.c
@@
-321,17
+321,18
@@
static void print_expression_statement(const expression_statement_t *statement)
static void print_goto_statement(const goto_statement_t *statement)
{
fprintf(out, "goto ");
static void print_goto_statement(const goto_statement_t *statement)
{
fprintf(out, "goto ");
- if(statement->label != NULL) {
- fprintf(out, "%s", statement->label->symbol->string);
- } else {
- fprintf(out, "?%s", statement->label_symbol->string);
- }
+ fputs(statement->label->symbol->string, out);
+ fprintf(stderr, "(%p)", (void*) statement->label);
fputs(";\n", out);
}
static void print_label_statement(const label_statement_t *statement)
{
fputs(";\n", out);
}
static void print_label_statement(const label_statement_t *statement)
{
- fprintf(out, "%s:\n", statement->symbol->string);
+ fprintf(stderr, "(%p)", (void*) statement->label);
+ fprintf(out, "%s:\n", statement->label->symbol->string);
+ if(statement->label_statement != NULL) {
+ print_statement(statement->label_statement);
+ }
}
static void print_if_statement(const if_statement_t *statement)
}
static void print_if_statement(const if_statement_t *statement)
@@
-414,8
+415,10
@@
static void print_for_statement(const for_statement_t *statement)
panic("multiple declarations in for statement not supported yet");
}
fputc(' ', out);
panic("multiple declarations in for statement not supported yet");
}
fputc(' ', out);
- } else if(statement->initialisation) {
- print_expression(statement->initialisation);
+ } else {
+ if(statement->initialisation) {
+ print_expression(statement->initialisation);
+ }
fputs("; ", out);
}
if(statement->condition != NULL) {
fputs("; ", out);
}
if(statement->condition != NULL) {