[antlr-interest] Re: strong error recovery

Monty Zukowski monty at codetransform.com
Fri Jul 30 09:34:49 PDT 2004


Ok, so what on earth are you parsing?  Why the garbage in there?

top: ((expr)=>expr | .)*;

Using a syntactic predicate as above will do the trick.  It will be 
slow, but it will find every valid expression and advance one token at 
a time if it wasn't an expression.

Monty

ANTLR & Java Consultant -- http://www.codetransform.com
ANSI C/GCC transformation toolkit -- 
http://www.codetransform.com/gcc.html
Embrace the Decay -- http://www.codetransform.com/EmbraceDecay.html

On Jul 30, 2004, at 2:17 AM, Neurosurg wrote:

> Thank you for you reply, Monty
>
> --- In antlr-interest at yahoogroups.com, Monty Zukowski <monty at c...> 
> wrote:
>> Here's the idea.  Follow my discussion in my article about how to 
>> write
>> a parser which grabs tokens from the input stream and then only parses
>> when it sees an interesting token.  In my example GOTO was one such
>> token that should be parsed.  In your example it will be anything that
>> can be an expression.
>
> That's the point. In my case, the valid symbols might be a part of the
> garbage:
>
> input:
> +)((7+5)*8
>
> extracted output:
> (7+5)*8
>
> So, the following your advice looks for me as closer
> approach to my case:
>
>> [...]Now that I think about it, there are probably other ways to 
>> handle
>> this.  For instance if you aren't passing on to a TokenStream, you
>> could get by with a parser rule like this:
>>
>> top: (expr | .)*;
>
> however this doesn't work as well for the test above and test posted
> in my original post.
>
>
> Best regards,
> Valery
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

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



More information about the antlr-interest mailing list