[antlr-interest] Parse tree error messages.

Ric Klaren klaren at cs.utwente.nl
Tue Apr 1 03:25:47 PST 2003


Hi,

On Fri, Mar 28, 2003 at 05:41:24AM -0700, Trey Spiva wrote:
> When parsing a file the recognizers report pretty good error messages.
> However, when using parse trees the error messages are very cryptic.  Is
> here a way to have the tree parser at least report the token AST type
> that it is expecting and the AST type that if found.
>
> The error message that the tree parser is reporting is:
>
> <AST> : unexpected AST node: <ASTNULL>

During development with treewalkers I usually have in each rule a exception
handler that prints out the offending tree. Something like this:

rule:
( sumthin ) *
sumthin_else
;
exception
catch [antlr::RecognitionException &ex]
{
	print_tree<RefMyAST,MyTreeParser> pr(*this);
	pr.pr_tree(#rule_in);
}

You can get the print_tree thing here:

http://wwwhome.cs.utwente.nl/~klaren/print_tree.h

Cheers,

Ric
--
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
  Chaos always defeats order because it is better organized.
  --- Terry Pratchet


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list