On Thursday 14 May 2009 19:02:56 Ratul Bhadury wrote:
> Hello all,
>
> I've been trying to achieve something using Antlr v3, but have been
> struggling for a while now, and think its now time to ask the help of more
> experienced users, hence this mail.
>
> What I basically want to achieve is a simple parser which will accept lines
> of the nature:
>
> sec = <keyword>
>
> I want any whitespace (spaces and tabs) before the '=' sign to be ignored,
> but any spaces after '=' to be included in what will be regarded as the
> keyword. Therefore:
> sec= hello -> is valid
> sec =hello people -> is valid
> sec = hello -> is valid
> se= hello -> is rejected
something like this? (this read only one clause),
KEYWORD includes the whitespace at the beginning, but not at the end.
grammar Key;
start : clause EOF;
clause : SECURITY KEYWORD WS* ;
fragment WS : ' ' | '\t';
fragment NUMBER : ('0' .. '9')+;
fragment WORD : ('a' .. 'z')+;
SECURITY : ('S'|'s')('E'|'e')('C'|'c') WS* '=' ;
KEYWORD : WS* (WORD | NUMBER);
cheers,
Michael
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
-~----------~----~----~----~------~----~------~--~---