About
import org.antlr.v4.runtime.; import org.antlr.v4.runtime.tree.;
public class TestLanguage { public static void main(String[] args) throws Exception { // Input program (you can replace this with actual input from file) String program = """ let var N := 8; type intArray = array of int; var row := intArray [ N ] of 0; var col := intArray [ N ] of 0; """;
// Create input stream
CharStream input = CharStreams.fromString(program);
// Create lexer
LanguageLexer lexer = new LanguageLexer(input);
// Create tokens stream
CommonTokenStream tokens = new CommonTokenStream(lexer);
// Create parser
LanguageParser parser = new LanguageParser(tokens);
// Parse and get the parse tree
ParseTree tree = parser.program();
// Print the parse tree
System.out.println(tree.toStringTree(parser));
}
}