Parser improvements: !=
operator and key: [line_break]
#220
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request implements two fixes to the parser:
x!=1
(used to be parsed asx!(1)
instead ofx != 1
)should be parsed as
foo(x: "some text")
but it was parsed asfoo(x:); "some text"
because the parser incorrectly interpreted the line break afterx:
as a statement terminator.The first problem is addressed by letting the scanner handle identifiers that end with
!
, so it can do a negative lookahead test for a=
character.The second problem is addressed by adding a fake "no_line_break" token in the grammar right after the
:
symbol in a pair and change the scanner so it won't produce "line_break" symbols if a "no_line_break" symbol is expected. This solution feels a bit "hacky" to me, but it could not think of a better way. @maxbrunsfeld any ideas?Checklist: