Skip to content

Commit

Permalink
Add newline in UI before lexing/parsing
Browse files Browse the repository at this point in the history
Fixes JMU-CS#87 in the UI by avoiding EOL/EOF issues with ANTLR:
  https://www.antlr3.org/pipermail/antlr-interest/2011-January/040642.html
  • Loading branch information
lam2mo committed Feb 21, 2020
1 parent f7455aa commit 8b96948
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/github/lessjava/LJUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ public void actionPerformed(ActionEvent e)

public String compile(String code)
{
// add newline to avoid EOL/EOF issues w/ ANTLR:
// https://www.antlr3.org/pipermail/antlr-interest/2011-January/040642.html
code += "\n";

// lexing and parsing (TODO: report errors in UI)
LJLexer lexer = new LJLexer(new ANTLRInputStream(code));
LJParser parser = new LJParser(new CommonTokenStream(lexer));
Expand Down

0 comments on commit 8b96948

Please sign in to comment.