[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 11:22:07 PDT 2008


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/0d394d14/attachment.html 


More information about the antlr-interest mailing list