On Friday, November 26, 2010 at 19:23:24 (+0100) Martijn Reuvers writes:
>Hello Bill,
>
>The grammar below does the trick for your command (I stripped it
>somewhat, to quickly get it working). See the SHELL_COMMAND token,
>notice the options part with the greedy identifier. It reads until it
>encounters the newline stuff. You need to have something in front of
>it, like SHELL in this example - otherwise it would match anything,
>which is not what you want.

Thanks Martijn.  I tried replacing my original COMMAND_TEXT with
your suggestion:

COMMAND_TEXT: (options {greedy=false;} : . )* '\r'? '\n' {
        setText(getText().trim());
    }
    ;

and though this reduces the conflict, I still have one I don't know how
to resolve:

error(208): Command.g:124:1: The following token definitions can never be 
matched because prior tokens match the same input: NEWLINE

I need the NEWLINE so I can limit the commands to a single line.  Here is
one part of the grammar I did not share that is relevant, along with
the parts I changed with your help:

command
    : (clean|shell) (NEWLINE | EOF)
    | NEWLINE
    ;

[clean as before]

shell : 'shell' timeoutOption? COMMAND_TEXT ;

[timeoutOption as before, etc.]

COMMAND_TEXT: (options {greedy=false;} : . )* '\r'? '\n' {
        setText(getText().trim());
    }
    ;
EMAIL: ~('\n' | '\r' | ' ' | '"')+ ;
NEWLINE: '\r'? '\n' ;
WS: (' ' | '\t')+ { skip(); } ;

So, how do I preserve the single-line command idiom with the shell command
"read-to-end-of" line part?


Bill

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