Hi, everybody, Please help me this problem: I do the example on the page: http://www.antlr.org/wiki/pages/viewpage.action?pageId=1760 in order use this example, i have built the grammar P on ANTLRWork and generate code to have class PLexer and PParser. But when i run this code on java Jcreator 4.5: import org.antlr.runtime.*; import org.antlr.runtime.tree.*; import org.antlr.runtime.debug.*; import org.antlr.runtime.ANTLRStringStream; import org.antlr.runtime.CharStream; import ParserAndLexer.*; public class TestP { public static void main (String[] args) throws Exception{ ANTLRInputStream input=new ANTLRInputStream(System.in); PLexer lexer=new PLexer(input); CommonTokenStream tokens=new CommonTokenStream(lexer); ParseTreeBuilder builder=new ParseTreeBuilder("prog"); PParser parser=new PParser(tokens,builder); parser.prog(); System.out.println(builder.getTree().toStringTree()); } } -----------------------------
the error appear:
D:\CAO HOC\TAI LIEU THAM KHAO\ANTLR-EBNF\CREATE PARSTREE\TestP.java:14:
cannot find symbol
symbol : constructor
PParser(org.antlr.runtime.CommonTokenStream,org.antlr.runtime.debug.ParseTreeBuilder)
location: class ParserAndLexer.PParser
PParser parser=new PParser(tokens,builder);
---------------------------
When I drop one argument "builder" in method PParser(tokens,builder) then
that error not found. but i don't know how to run to have the following
result:
java TestP
int i;
i=4;
(<grammar prog> (prog (decl (type int) i ;) (stat i = (expr 4))))
note: I have attach a file. Could you have me.
Thanh you very much.
List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
CREATE PARSTREE.rar
Description: application/rar
-- You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
