Skip to content

Commit

Permalink
c output w/ full-()
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriano committed Oct 1, 2010
1 parent 5f97788 commit 5dba213
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions tp1_eric.c
Expand Up @@ -256,14 +256,29 @@ void SchemePrint(struct AST *ast) {
SchemeExprPrint(ast->root);
printf("\n");
}
}

void CExprPrint(struct Expr *expr) {
if (expr->type == operand)
printf("%d", expr->value.number);
else {
printf("(");
CExprPrint(expr->value.expression.left);
printf(" ");
printf("%c", OperatorToChar(expr->value.expression.operator));
printf(" ");
CExprPrint(expr->value.expression.right);
printf(")");
}
}

void CPrint(struct AST *ast) {
int a;

if (ast)
a = 0;
if (ast->root->type == operand)
printf("%d\n", ast->root->value.number);
else {
CExprPrint(ast->root);
printf("\n");
}
}

void PSExprPrint(struct Expr *expr) {
Expand Down

0 comments on commit 5dba213

Please sign in to comment.