I strongly advise you to purchase 'The Definitive ANTLR Reference'. C#
example below.
Cheers -- John Pool
MyLexer lexer = new MyLexer (new ANTLRStringStream ("my code to parse"));
// ... or ANTLRFileStream ("my file to parse")
CommonTokenStream cts = new CommonTokenStream (lexer);
MyParser parser = new MyParser (cts);
MyParser.member_return returnValue = parser.member(); // or whatever
'root' rule you want to parse
tree = (CommonTree)returnValue.Tree;
string treeAsString = tree.ToStringTree ();
AntlrExceptions.CheckForErrors (); // my own error handling class ...
// ... contains overridden versions of ReportError() for the parser, lexer
and treeparser
// depending on whether you need a treeparser (AST parser):
CommonTreeNodeStream treeNodeStream = new CommonTreeNodeStream (tree);
JclTreeParser treeParser = new JclTreeParser (treeNodeStream);
treeNodeStream.TokenStream = cts;
AntlrExceptions.CheckForErrors ();
--
View this message in context:
http://n2.nabble.com/Creating-AST-with-third-party-grammar-tp4524691p4553093.html
Sent from the ANTLR mailing list archive at Nabble.com.
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--
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.