[antlr-interest] retrieving the length of a production match

Kay Roepke kroepke at classdump.org
Tue Aug 21 12:50:44 PDT 2007


On Aug 21, 2007, at 9:32 PM, Adrian Herscu wrote:

> I want to embed my parser in an IDE. One of the required features  
> is to provide error markers. The markers framework API requires the  
> length of the error besides of the line and column.
>
> I have looked into the AST API and couldn't find nothing to help  
> with this task... Searched the group and google, but still nothing :-(

A tree node has the start and stop token index (in the sense that in  
a tree like ^(+ 3 4) the + encompasses everything below). From that  
you can get the tokens from the token stream and eventually figure  
out the length of the matched string in the character stream :)

HTH,
-k
-- 
Kay Röpke
http://classdump.org/






More information about the antlr-interest mailing list