[antlr-interest] Novice Question - Token for all characters from a given point to End of Line

Matt Palmer mattpalms at gmail.com
Tue Aug 5 13:00:43 PDT 2008


Actually, I think it should be:

(options{greedy=false;} : . )* NEW_LINE

Matt

On Tue, Aug 5, 2008 at 8:49 PM, Matt Palmer <mattpalms at gmail.com> wrote:

> Ooops!  I guess so :)
>
> Matt
>
>
> On Tue, Aug 5, 2008 at 8:46 PM, Foust <javafoust at gmail.com> wrote:
>
>>  Ø  (options{greedy=false;} : . ) NEW_LINE
>>
>>
>>
>> Did you mean:
>>
>>
>>
>>                                 .*
>>
>> ?
>>
>>
>>
>> Brent
>>
>> *From:* antlr-interest-bounces at antlr.org [mailto:
>> antlr-interest-bounces at antlr.org] *On Behalf Of *Matt Palmer
>> *Sent:* Tuesday, August 05, 2008 11:22 AM
>> *To:* Brisard, Fred D
>> *Cc:* antlr-interest at antlr.org
>> *Subject:* Re: [antlr-interest] Novice Question - Token for all
>> characters from a given point to End of Line
>>
>>
>>
>> Hi Fred,
>>
>> You should be able to use predicates, something like this:
>>
>> COMMAND
>>       : 'create' | 'delete'                     { inCommand = true; }
>>       ;
>>
>> COMMAND_TOKEN
>>       : {inCommand}?=>
>>           (options{greedy=false;} : . ) NEW_LINE  { inCommand = false; }
>>          ;
>>
>> Matt.
>>
>> On Tue, Aug 5, 2008 at 7:03 PM, Brisard, Fred D <Fred.Brisard at ca.com>
>> wrote:
>>
>> I have a keyword style grammar and have the need to accept all the
>> characters until the end of line to be accepted as a single token.
>>
>> For example, I have a statement that is of the following type
>>
>> Command multiple arguments (EOL)
>>
>> Where Command can be a command name and the multiple arguments are one or
>> more arguments.  There can be from 1 to many arguments – each argument
>> does not have a fixed content – it may be an integer, a string, a quoted
>> string.  The characters in the string can be most anything.
>>
>> I was looking for something similar to the multiple line comment technique
>> using the greedy=false option.  Collect all the characters following the
>> Command into a single token.
>>
>> Any ideas or suggestions are appreciated.
>>
>> Regards, Fred
>>
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080805/7b46387b/attachment-0001.html 


More information about the antlr-interest mailing list