-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[2-parsers] Subtraction Issue #7
Comments
Thanks for spotting this. You could fix this by adding a unary minus-operator and not allowing integer literals to be prefixed with a minus sign. Then an input like Or, you could just accept that the user has to always provide a space after the minus-operator. Since the provided specification has this limitation built-in, I think it would be not be reasonable for me to test your code with input like |
Just so you know, one of the TODO's is: /* TODO-3 : Add support for (x+6) and (10-y). You'll need to add production rules, and create an AddOperator... which might be misleading |
On this note, another ambiguity occurs in the case of Where standard mathematical associativity should equate it to (I believe) |
@Darrekt I believe since unary operators are not defined, -2^2 won't be tested; instead, 0 - 2 ^ 2 is a possible input. |
Right. |
The parser gives a syntax error when inputting 5-3 as it lexes it as 5 and -3 instead of 5 MINUS 3. This happens because the lexer tries to take in as many tokens as possible. Hence, even though it recognises the minus sign, it sees that there is a number followed by it which is why it takes it in as a negative number as opposed to a minus sign in subtraction.
The text was updated successfully, but these errors were encountered: