-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If an identifier is given without a keyword, the most recent keyword is assumed. For example, not host vs and ace is short for not host vs and host ace Which should not be confused with not ( host vs or ace ) This patch fixes issue #17.
- Loading branch information
Showing
1 changed file
with
30 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2f685f2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In 'parse_primitive_or_arithmetic' I tried to do a peek and later consume the next token, but I had trouble with other expressions. Finally I added a method to the lexer to put back a token. For example, in the expression:
not and host vs ace
When the lexer reaches 'ace', cannot find primitive, so since I keep track of the last keyword I know what keyword to apply. However, the pos of the lexer has already advance. The consumed 'ace' should be the last keyword (in this case 'host'), and I append 'ace' back to the string at the current position.
Another thing is that I'm not sure if the tree for "not host vs and ace" is correct. I got the following for its equivalent expression "not host vs and ace":
{not, {and, {host, vs}, {host, ace}}}
Shouldn't be:
{and, {not, {host, vs}}, {host, ace}}
As usually 'not' has higher precedence than any other logical operator. I noticed 'not' is not present in the precedence table, maybe it has to do with this. WDYT?