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 }}
Repository navigation
Newline required at end of file with test statement #87
During the UI testing (see #84) I discovered that I was getting a parse error if the file ended with a "test" statement that didn't terminate with a newline. This may be a UI-only issue; more testing is necessary.
That claims that it's probably easier to just add a new line to the input if there isn't one present. Dealing with it in the grammar can be more trouble than it's worth.
Activity
Zamua commentedon Feb 21, 2020
What's the bug?
lam2mo commentedon Feb 21, 2020
Sorry, was going to come back and add more details later but today was crazy busy. Edited with more info.
[-]Newline required at end of file[/-][+]Newline required at end of file with test statement[/+]Zamua commentedon Feb 21, 2020
https://github.com/JMU-CS/less-java/blob/master/src/main/antlr/LJ.g4#L20
Yeah seems the grammar requires an EOL. Could we redefine EOL to be a new line character or end of file?
Here's some discussion I found online about that: http://antlr.1301665.n2.nabble.com/How-to-treat-EOF-as-NEWLINE-td7579363.html
The second to last comment seems to provide a solution:
lam2mo commentedon Feb 21, 2020
Aha. Figured it was something like that. Yes, this seems like a fine solution to me.
Zamua commentedon Feb 21, 2020
Did some testing and I can't quite get it to work. It also appears that it's maybe not recommended: https://www.antlr3.org/pipermail/antlr-interest/2011-January/040642.html
That claims that it's probably easier to just add a new line to the input if there isn't one present. Dealing with it in the grammar can be more trouble than it's worth.
Zamua commentedon Feb 21, 2020
Can't figure out if there's an elegant way for me to add a commit to #84 but the change is simple.
before this line: https://github.com/lam2mo/less-java/blob/ui/src/main/java/com/github/lessjava/LJUI.java#L98
add:
Add newline in UI before lexing/parsing