I tried to run the ANTLR4 visualization interpreter from this class with the example grammar description and program code from the antlr4-tools.
However with the latest antlr4 release (4.13.1) it runs indefinitely without producing results or throwing an exception
- Download complete antlr4 jar release here
- Create file “Expr.g4” with the following content:
<code>grammar Expr;
prog: expr EOF ;
expr: expr ('*'|'/') expr
| expr ('+'|'-') expr
| INT
| '(' expr ')'
;
NEWLINE : [rn]+ -> skip;
INT : [0-9]+ ;
</code>
<code>grammar Expr;
prog: expr EOF ;
expr: expr ('*'|'/') expr
| expr ('+'|'-') expr
| INT
| '(' expr ')'
;
NEWLINE : [rn]+ -> skip;
INT : [0-9]+ ;
</code>
grammar Expr;
prog: expr EOF ;
expr: expr ('*'|'/') expr
| expr ('+'|'-') expr
| INT
| '(' expr ')'
;
NEWLINE : [rn]+ -> skip;
INT : [0-9]+ ;
- Create file “prog” with the following content:
<code>10+20*30
</code>
<code>10+20*30
</code>
10+20*30
- Run the following command:
<code>java -cp antlr4-4.13.1-complete.jar org.antlr.v4.gui.Interpreter Expr.g4 prog
</code>
<code>java -cp antlr4-4.13.1-complete.jar org.antlr.v4.gui.Interpreter Expr.g4 prog
</code>
java -cp antlr4-4.13.1-complete.jar org.antlr.v4.gui.Interpreter Expr.g4 prog
The command runs without interruption and does not produce anything.
It was ran on a Pop!_OS 22.04 but also tried on Ubuntu 24.04.
New contributor
bcherry is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.