Reputation: 469
I'm just starting out with parsers and the like, and I'm trying to build my own little logical language for a game I've been toying with. I set up ANTLR4 on my machine and ran through the test code just fine - by running
grun Hello r -gui
I was able to get the appropriate output.
However, when I compile the following grammar and try running
grun garden expr -gui
I get a
NoClassDefFoundError: gardenLexer(wrong name: parser/gardenLexer)
gardenLexer.class exists in the folder, but for some reason ANTLR can't seem to see it.
grammar garden;
@header
{
package parser;
}
expr
: '(' expr ')'
| 'not' expr
| expr 'and' expr
| expr 'xor' expr
| expr 'or' expr
| 'exactly' INT property
| 'atleast' INT property
| 'atmost' INT property
| 'exists' INT property
| property 'adjacent' property
| property 'leftof' property
| property 'rightof' property
| property 'above' property
| property 'below' property
;
property
: SIZE
| COLOR
| TYPE
| SIZE COLOR
| SIZE TYPE
| COLOR TYPE
| SIZE COLOR TYPE
| 'water'
| 'any'
;
WS
: [ \t\n\r]+ -> skip;
INT
: '0'..'9'+;
TYPE
: 'stone'
| 'statue'
| 'plant'
;
COLOR
: 'black'
| 'white'
| 'gray'
;
SIZE
: 'small'
| 'large'
;
Upvotes: 3
Views: 929
Reputation: 1166
If your antlr-generated classes belong to a package you should call grun as
grun *packageName*.garden expr -gui
from "classes" folder (not sources)
Upvotes: 4