Antlr4: no viable alternative at input '<EOF>'

Created on 5 Jun 2014  Â·  5Comments  Â·  Source: antlr/antlr4

The following grammar:

grammar Expr;
expr
    :   expr '+' expr
    |   INT
    ;
INT     : [0-9]+ ;

with the input "42" it throws
line 1:1 no viable alternative at input '<EOF>'

only adding a rule as '(' expr ')' it starts to work fine.

duplicate

Most helpful comment

Hmm...adding a start rule works:

s : expr EOF ;

I get the same EOF issue without that rule. I thought that Sam and I had worked on this to make left recursive rules work as start symbols.

are you running this with TestRig/grun? or from your own test?

All 5 comments

42 followed by newline? v4.2.2?

No is the exact string. After 42 there is EOF
On 5 Jun 2014 17:11, "Terence Parr" [email protected] wrote:

42 followed by newline?

—
Reply to this email directly or view it on GitHub
https://github.com/antlr/antlr4/issues/606#issuecomment-45231749.

Hmm...adding a start rule works:

s : expr EOF ;

I get the same EOF issue without that rule. I thought that Sam and I had worked on this to make left recursive rules work as start symbols.

are you running this with TestRig/grun? or from your own test?

No, my own test, using Java. Antlr 4.2.2.
On 5 Jun 2014 18:52, "Terence Parr" [email protected] wrote:

Hmm...adding a start rule works:

s : expr EOF ;

I get the same EOF issue without that rule. I thought that Sam and I had
worked on this to make left recursive rules work as start symbols.

are you running this with TestRig/grun? or from your own test?

—
Reply to this email directly or view it on GitHub
https://github.com/antlr/antlr4/issues/606#issuecomment-45245036.

I'm going to close this as a duplicate of #118.

Was this page helpful?
0 / 5 - 0 ratings