[antlr-interest] Java grammar accepting junk

Ron Hunter-Duvar ron.hunter-duvar at oracle.com
Mon Aug 18 08:13:52 PDT 2008


Terence Parr wrote:
>
> On Aug 15, 2008, at 4:03 PM, Ron Hunter-Duvar wrote:
>
>> Funny, I went looking for just such a method and didn't find one. Now 
>> I go back and see exactly the code you pointed to. Accomplishes the 
>> same thing with slightly less code.
>>
>> About my other question, though, if errors have occurred, with 
>> backtracking and recovery going on, how can I know if it succeeded in 
>> recovering and got to the end of file or just gave up early?
>
> it only counts real errors not backtracking errors :)  you can also 
> ask for state.input.index() to get the token index.
>
> Ter
>
So a real error means the parser really did give up before the end of 
the file was reached? If so, then what I have is sufficient.

Not sure what the token index would tell me. Do you mean use that index 
to get the token and check if it's an EOF token?

Ron

-- 
Ron Hunter-Duvar | Software Developer V | 403-272-6580
Oracle Service Engineering
Gulf Canada Square 401 - 9th Avenue S.W., Calgary, AB, Canada T2P 3C5

All opinions expressed here are mine, and do not necessarily represent
those of my employer.



More information about the antlr-interest mailing list