Open james-q-arnold opened 10 years ago
Hi. That is the intended functionality.
I suggest adding something to the documentation in this case.
Hi. It's buried on this page:
https://theantlrguy.atlassian.net/wiki/display/ANTLR4/ANTLR+Tool+Command+Line+Options
but in the book.
Reopening to examine whether the error message could be improved, but no promises that anything will change.
This one seems to get me every time I'm away from running TestRig for a while. I end up typing grun BlahParser someRule < infile
( instead of grun Blah someRule < infile
) and get this error message. Then I have to go pull up the source and realize that it adds the "Lexer" and "Parser" suffixes trying to find the class.
For split grammars, it's "non-obvious" at best (the source clearly says "BlahParser", I can see generated code for "BlahParser", but I get a ClassCastException for "BlahParser" 🤷).
Consider this another vote for either trying the input name without appending "Parser" or "Lexer", or at least a better error message.
I might even take a crack at it if everyone is open to the idea.
I split a grammer into a parser and a lexer. It appears the runtime package is very particular about the selected names. I had a lexer named 'SomeLex' and a parser 'SomeParser'.
Changing the lexer to 'SomeLexer' fixed the problem. By the way, I was using antlr4. The parser used tokenVocab to import the lexer. I would attach the files, but I don't see a way to do that in the github error report. The files were trivial: one rule (r) in the parser, three simple token rules in the lexer.