antlr4-lab icon indicating copy to clipboard operation
antlr4-lab copied to clipboard

sample problems

Open BINARYGARRY opened this issue 2 years ago • 4 comments

Hi, I'm running the sample in antlr tools and getting these comments. 2:9 token recognition error at: '+' 2:10 extraneous input 'foo' expecting ';'

I've made no changes and just clicked the run button. The '+' makes sense to me since it's not in the lexer. It does build the tree but 'foo' is highlighted in the tree and input . Is this meant to be a learning exercise or possibly a bug?

My apologies if this has already been explained. Thx Garry

BINARYGARRY avatar Jul 10 '23 15:07 BINARYGARRY

Which grammar? Expr.g4 or JavaLexer.g4/JavaParser.g4? Those are the only two discussed. https://github.com/antlr/antlr4-tools#parsing-using-interpreter

kaby76 avatar Jul 10 '23 15:07 kaby76

sorry I wasn't more clear . it's the default sample http://lab.antlr.org/

BINARYGARRY avatar Jul 11 '23 01:07 BINARYGARRY

The default example at lab.antlr.org is supposed to contain the error. It's a demo of how it reports an error. If you change the input line a=3+foo; to a = 3 and 2;, then run the parse, it succeeds.

kaby76 avatar Jul 11 '23 01:07 kaby76

ok that matches the rules. constructive criticism - that's confusing for someone starting out. Also a really cool addition would be to include the virtuals and overrides based on those rules

anyway, thanks for helping me. Great product and appreciate the teams efforts.

Garry

BINARYGARRY avatar Jul 11 '23 11:07 BINARYGARRY