I am not sure if this is what you want, but what about changing to something
like the following? (the parts I added are in bold)


file    : section1 section2?
       ;

section1: 'Section1' *CONTENTS*
       ;

section2: 'Section2' *CONTENTS*

       ;

ID      : ('a'..'z'|'A'..'Z')+
       ;

*CONTENTS      : ('a'..'z'|'A'..'Z')*
       ;*

SPACE   : ' ' {$channel = HIDDEN;}
       ;



2010/1/15 Arne Schröder <[email protected]>

> Hello,
>
> I am trying to write a parser for an initialization-file. This file is
> devided in sections which are not embraced but have a keyword to start
> them.
>
> Unfortunately the parser stops when encountering a problem and just ends
> the
> parsing-process, not even reporting an error.
>
> For demostration of the problem I wrote the following example-grammar:
>
> file    : section1 section2?
>        ;
>
> section1: 'Section1'
>        ;
>
> section2: 'Section2'
>        ;
>
> ID      : ('a'..'z'|'A'..'Z')+
>        ;
>
> SPACE   : ' ' {$channel = HIDDEN;}
>        ;
>
> Now using the input "Section1 bla Section2", I would expect the parser to
> stop at "bla", throw an UnwantedTokenException, do a SingleTokenDeletion as
> error-recovery and just continue parsing "Section2".
> What happens is that it stops at "bla", does not recognize it as section2
> and just terminates, leaving the two tokens unparsed and not reporting any
> error.
>
> So my question is: How can I avoid my parser doing stuff like that without
> changing my files' syntax?
>
>
> Thanks in advance
>
> Arne
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
> --
> You received this message because you are subscribed to the Google Groups
> "il-antlr-interest" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<il-antlr-interest%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/il-antlr-interest?hl=en.
>
>
>
>
--
You received this message because you are subscribed to the Google Groups "il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to