[antlr-interest] Line start vs non-line ...
Bart Kiers
bkiers at gmail.com
Tue Jul 5 03:25:39 PDT 2011
Hi James,
Something like this would do the trick:
lines
: (LineStartingWithPlus | LineNotStartingWithPlus | LineBreak)* EOF
;
LineStartingWithPlus
: '+' ~('\r' | '\n')*
;
LineNotStartingWithPlus
: ~'+' ~('\r' | '\n')*
;
LineBreak
: ('\r'? '\n' | '\r')
;
Regards,
Bart.
On Tue, Jul 5, 2011 at 12:18 PM, James Ladd <james_ladd at hotmail.com> wrote:
>
> Hi All,
>
> I hope this is a simple request to answer.
>
> I have a simple preprocessor I want to write but I can't get the rules
> right.
> I think I am regex challenged.
>
> In simple terms I want to have this:
>
> lines
> : (lineStartingWithPlus | lineNotStartingWithPlus)*
> ;
>
>
> If these were rules A and B respectively then ...
>
> + this line matches A
> this line matches B
>
> Please can someone help ?
>
> Rgs, James.
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
More information about the antlr-interest
mailing list