Hello Colin,

You are missing a space in between.

This should work:

grammar test;

someRule        : DAY+  
        ;

DAY     :       
        'day' 's'?
        ;
        
Note that DAY is a lexer token.

Cheers!
Martijn
        


On Tue, Oct 26, 2010 at 1:34 PM, Colin Yates <[email protected]> wrote:
> Hi,
>
> The user can type in '1 day' or '7 days'.  I have the following rule which
> matches:
>
> durationPeriod: ('day' | 'days') { // do something};
>
> and this works fine.  I initially tried:
>
> durationPeriod: 'day'('s')? { // do something};
>
> but this never matched 'days'.
>
> Based on the '100 monkeys' reality I tried the following:
>
> durationPeriod: ('day''s')? { // do something};
> and
> durationPeriod: ('day')('s')? { // do something};
>
> but none of them matched 'days'.  The exact error is [line 1:2 no viable
> alternative at input 'days'']
>
> What have I missed?  The (incredibly useful!) Syntax Diagram in antlworks
> shows that the trailing 's' can be skipped, so I don't understand why it
> doesn't work.
>
> Many thanks,
>
> Col
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: 
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>

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].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to