Skip to content

Commit

Permalink
Add note about -1 being scanned too greedily.
Browse files Browse the repository at this point in the history
  • Loading branch information
Warren Toomey committed Feb 12, 2020
1 parent bf747f3 commit bcba9c5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions 43_More_Operators/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ as the two tokens '1', 'int literal -1', but I forgot that `next()` doesn't
skip the space. So, by having a space between the '-' and the '1', the
expression `1 - 1` is correctly parsed as '1', '-', '1'.
However, as [Luke Gruber](https://github.com/luke-gru) has pointed out,
this also means that the input `1-1` **is** treated as `1 -1` instead of
`1 - 1`. In other words, the scanner is too greedy and forces `-1` to
always be treated as a T_INTLIT when sometimes it shouldn't be. I'm going
to leave this for now, as we can work around it when writing our source
code. Obviously, in a production compiler this would have to be fixed.
## Misfeatures
In the AST node and symbol table node structures, I've been using unions to
Expand Down

0 comments on commit bcba9c5

Please sign in to comment.