You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because of the way the AST compiles down into C code the operator precedence is not honored. The AST gets it right but writes it out wrong for C to interpret. It is going to be more involved than just putting () around every function, that seems to break things. (maybe makes things into bools??)
operations.chestnut
print("4 * (1+1) should equal 8, in reality it is %s",4*(1+1));
output:
$ ./operations
4 * (1+1) should equal 8, in reality it is 5
The text was updated successfully, but these errors were encountered:
When compiling the AST I now put parentheses around everything, which fixes this issue but makes the generated code look awful. The correct way to fix this is to re-create the parentheses when compiling, which requires the compiler (in addition to the parser) to know about operator precedence.
Because of the way the AST compiles down into C code the operator precedence is not honored. The AST gets it right but writes it out wrong for C to interpret. It is going to be more involved than just putting () around every function, that seems to break things. (maybe makes things into bools??)
operations.chestnut
output:
The text was updated successfully, but these errors were encountered: