I am learning how to generate a symbol table using Antlr4. I came across this example (and the only one so far) but it gives compilation errors for the files generated by Antlr4.
(commands:
antlr4 Simple.g4
and javac Simple*.java
)
-bash-4.1$ javac Simple*.java
SimpleBaseListener.java:3: error: package org.antlr.symbols does not exist
import org.antlr.symbols.*;
^
SimpleListener.java:3: error: package org.antlr.symbols does not exist
import org.antlr.symbols.*;
^
SimpleParser.java:3: error: package org.antlr.symbols does not exist
import org.antlr.symbols.*;
^
SimpleParser.java:87: error: cannot find symbol
public Scope scope;
^
symbol: class Scope
location: class FileContext
SimpleParser.java:166: error: cannot find symbol
public Scope scope;
^
symbol: class Scope
location: class FuncContext
SimpleParser.java:356: error: cannot find symbol
public Scope scope;
^
symbol: class Scope
location: class BlockContext
SimpleLexer.java:3: error: package org.antlr.symbols does not exist
import org.antlr.symbols.*;
^
7 errors
My guess is that this implementation uses an old verison of Antlr.
Is there an example for Antlr4? I tried the official documentation but it is not very helpful for a newbie.