Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing error information for invalid input #1820

Open
trevorgithub opened this issue Apr 12, 2017 · 0 comments
Open

Missing error information for invalid input #1820

trevorgithub opened this issue Apr 12, 2017 · 0 comments

Comments

@trevorgithub
Copy link

I apologize if this is a duplicate. I did skim the issues, but didn't notice the same thing (unless I misunderstood an existing issue, which is entirely possible).

I have a grammar that parsed correctly with invalid input in 4.5.1 & 4.6, but doesn't report errors in 4.7.

Here's the grammar, which I named Sample.g4 (sorry about the formatting; I used insert code but it didn't format as expected):

`grammar Sample;

fragment TERM_CHAR
: ~(' ' | '\t' | '\n' | '\r' | '\u3000'
| '"' | '\u201c' | '\u201d' | '(' | ')' | '\')
;

LPAREN : '(' ;
RPAREN : ')' ;

AND : 'AND' ;
OR : 'OR' ;

TERM_CONTENT : (TERM_CHAR)+ ;

WS
: ( ' '
| '\t'
| '\r'
| '\n'
| '\u3000'
)
-> channel(HIDDEN)
;

expression : noneExpression;
noneExpression : (orExpression)+;
orExpression : andExpression (OR andExpression);
andExpression : atom (AND atom)
;

atom : (term
| parent)
;

term : TERM_CONTENT | '\' ;

parent : LPAREN noneExpression? RPAREN ;`

Steps to reproduce:

Preconditions:

  1. Install & configure ANTLR 4.7
  2. Navigate to folder with Sample.g4, then follow the next steps

Steps to follow in shell, within folder containing Sample.g4:

  1. antlr4 Sample.g4
  2. javac *.java
  3. grun Sample expression -gui
    a) Enter this string as standard input:
    xxx ) yyy (zzz OR hhh)
    ^D

Expected results:
(This is the behaviour seen using ANTLR 4.6)
The tree should show several nodes, with multiple branches & highlight an error node (the right parenthesis)
Errors should be written to the console:
line 1:4 extraneous input ')' expecting {, '', '(', 'AND', 'OR', TERM_CONTENT}

Actual results:

The tree shows a single branch, with no error nodes highlighted
No error are written to the console

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant