You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently using org.antlr.v4.gui.TestRig for ANTLR teaching to help students debug simple grammars. Since my course uses Python, I'd rather avoid exposing students to Java stuff.
antlr4-parse looks very much like what I'm looking for, but doesn't seem to work for lexer grammars:
With TestRig, I can do:
$ cat Tokens.g4
lexer grammar Tokens;
HELLO : 'hello' ; // beware the single quotes
ID : [a-z]+ ; // match lower-case identifiers
INT : [0-9]+ ;
KEYWORD : 'begin' | 'end' | 'for' ; // perhaps this should be elsewhere
WS : [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines
$ antlr4 Tokens.g4 && javac *.java
$ echo hello | java org.antlr.v4.gui.TestRig Tokens tokens -tokens
[@0,0:4='hello',<'hello'>,1:0]
[@1,6:5='<EOF>',<EOF>,2:0]
However, it crashes when I try antlr4-parse:
$ antlr4-parse Tokens.g4 tokens -tokens
Exception in thread "main" java.lang.ClassCastException: class org.antlr.v4.gui.Interpreter$IgnoreTokenVocabGrammar cannot be cast to class org.antlr.v4.tool.LexerGrammar (org.antlr.v4.gui.Interpreter$IgnoreTokenVocabGrammar and org.antlr.v4.tool.LexerGrammar are in unnamed module of loader 'app')
at org.antlr.v4.semantics.SymbolChecks.checkForModeConflicts(SymbolChecks.java:313)
at org.antlr.v4.semantics.SemanticPipeline.process(SemanticPipeline.java:110)
at org.antlr.v4.Tool.processNonCombinedGrammar(Tool.java:371)
at org.antlr.v4.Tool.process(Tool.java:359)
at org.antlr.v4.tool.Grammar.<init>(Grammar.java:364)
at org.antlr.v4.gui.Interpreter$IgnoreTokenVocabGrammar.<init>(Interpreter.java:42)
at org.antlr.v4.gui.Interpreter.interp(Interpreter.java:141)
at org.antlr.v4.gui.Interpreter.main(Interpreter.java:277)
The text was updated successfully, but these errors were encountered:
I'm currently using
org.antlr.v4.gui.TestRig
for ANTLR teaching to help students debug simple grammars. Since my course uses Python, I'd rather avoid exposing students to Java stuff.antlr4-parse
looks very much like what I'm looking for, but doesn't seem to work for lexer grammars:With TestRig, I can do:
However, it crashes when I try
antlr4-parse
:The text was updated successfully, but these errors were encountered: