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
{{ message }}
This repository has been archived by the owner on Dec 29, 2019. It is now read-only.
If we mix all the binary operators (+, -, *, /) together, we lost the precedence, and user need to explicitly add () to have multiply executed before plus. The reason we put them together is we want to avoid duplicated code in visitor when building AST, because the operator is the only difference
Currently we have (this is wrong)
term
: literal # TmLiteral
| '-' term # TmNegative
| term BINARY_OP term # TmBinaryOp
// | list # TmList// | record # TmRecord
| '(' term ')' # TmBrackets
;
BINARY_OP
: '+'
| '-'
| '*'
| '/'
;
for 1 + 2 * 3 we have
*
+ 3
1 2
but we should have
+
1 *
2 3
The text was updated successfully, but these errors were encountered:
- #19 should be solved, didn't write unit test for that, might test it
end to end after a bare bone of REPL is finished (ASTBuilder, TypeChecker, Evaluator)
- add empty type package for Type class and Checker, ast package is only for AST
- test verified #18#19#22 are solved, see negative_precedence.rka
- add more exception classes, ReikaException is for checked exception
- InvalidSyntax for parser error
If we mix all the binary operators (+, -, *, /) together, we lost the precedence, and user need to explicitly add
()
to have multiply executed before plus. The reason we put them together is we want to avoid duplicated code in visitor when building AST, because the operator is the only differenceCurrently we have (this is wrong)
for
1 + 2 * 3
we havebut we should have
The text was updated successfully, but these errors were encountered: