I am trying to run ANTLR C grammar file (DummyC.g) from command line to parse C source and header files (a.h). When I run it with antlr.jar file, it generates parser and lexer files. but when I compile test file Main.java. It gives error of missing ANTLR packages as shown below.
C:\antlr-2.7.6\test>javac Main.java
Main.java:1: package org.antlr.tool does not exist import org.antlr.tool.;
^ Main.java:2: package org.antlr.runtime does not exist import org.antlr.runtime.;
^ Main.java:3: package org.antlr.runtime.tree does not exist import org.antlr.runtime.tree.;
^ Main.java:4: package org.antlr.stringtemplate does not exist import org.antlr.stringtemplate.;
^ Main.java:8: cannot find symbol symbol : class CommonTree location: class Main CommonTree tree = DummyCParser.start("a.h");
Main.java
import org.antlr.tool.*;
import org.antlr.runtime.*;
import org.antlr.runtime.tree.*;
import org.antlr.stringtemplate.*;
public class Main {
public static void main(String[] args) throws Exception {
CommonTree tree = DummyCParser.start("a.h");
DOTTreeGenerator gen = new DOTTreeGenerator();
StringTemplate st = gen.toDOT(tree);
System.out.println(st);
}
}
What could be the problem?