[antlr-interest] retrieving the length of a production match
Adrian Herscu
bmf1972 at fastmail.fm
Tue Aug 21 13:29:21 PDT 2007
Hi Randall, and thanks for your fast reply.
Please see my comments inline.
Adrian.
Randall R Schulz wrote:
> On Tuesday 21 August 2007 12:32, Adrian Herscu wrote:
>> Hi all,
>>
>> 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.
>
> Technically speaking, parse errors don't have a length. There is a point
> (a single token) at which the parser can detect ungrammatical input.
> After that, it's all over.
I can deal with parsing errors by extracting the token from the
exception. The problem is with things beyond the syntax, like type checking.
I will rephrase the question. On a syntactically correct input, is it
possible to retrieve the textual length of each production match and
store it in the AST during parsing?
>
> Of course, people often try to go beyond that elementary kind of yes /
> no parsing and add some kind recovery. My favorite "universal"
> (non-parser-tool-dependent) technique is to write production for
> explicitly non-grammatical (but usually common) errors so that you can
> report them and continue parsing.
>
> Other more sophisticated, parser-generator-specific techniques are
> possible, but I'm not up on them. The topic is covered extensively in
> TDAR.
>
What is "TDAR"?
More information about the antlr-interest
mailing list