[antlr-interest] Line number information for Tree Parser exceptions

Ric Klaren klaren at cs.utwente.nl
Wed Oct 1 03:09:40 PDT 2003


On Tue, Sep 30, 2003 at 09:03:41PM -0000, veekook wrote:
> Is there any way to augment exceptions thrown by the tree parser (eg 
> MismatchedTokenException) to maintain line numbers?  I've subclassed 
> CommonAST to include line numbers in my AST, but is there a method 
> for getting at the line numbers for an offending rule from a catch 
> block embedded in a tree grammar rule?  The following doesn't work 
> because tree exceptions don't track line numbers.

In java this should work in C++ I just now see that something wasn't ported
over from java mode. If the exception is generated by the match method of
the treeparser then the node attribute in the exception should be set.
Which means you're one cast away from the line number. Check out
MismatchedTokenException.java.

Depending on how you built your trees some nodes may lack line information.

Cheers,

Ric
--
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
  Xander: "Buffy, we need to do something *now*"
  Angel: "We need a distraction."
  Buffy: "Right."
  Angel: "What are you going to do?"
  Buffy: "I'm going to kill them all. That oughtta distract 'em..."


 

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




More information about the antlr-interest mailing list