Hello Bill, As said before most likely your newline is causing problems. I'd recommend you to get rid of it first (completely including the \r \n constructs), to the point where your grammar does not give any error anymore. After that introduce it step by step.
As a side note avoid using text constructs in parser rules (e.g. 'cleanLogs', use real tokens for it). Sooner or later these will cause trouble, plus that with real tokens you can have better error reporting. Regards, Martijn On Fri, Nov 26, 2010 at 10:50 PM, Bill Lear <[email protected]> wrote: > On Friday, November 26, 2010 at 20:15:19 (+0100) Massimiliano Donini writes: >> >>Can you send complete grammar? >>That error is about lexer rules order. > > Ok, added below my sig. > > > Bill > > grammar Command; > > @header { > import java.util.ArrayList; > import java.util.List; > } > > @parser::members { > private StageParameters stageParameters; > private List<Command> commandList = new ArrayList<Command>(); > > public void setStageParameters(final StageParameters params) { > stageParameters = params; > } > > public List<Command> getCommandList() { > return commandList; > } > } > > commands: command+ > ; > > command > scope { > int timeout; > List<String> notifyList; > } > @init { > $command::timeout = -1; > $command::notifyList = new ArrayList<String>(); > } > : (cleanlogs|cleanup) (NEWLINE | EOF) > | NEWLINE > ; > > cleanlogs > @init { > $command::timeout = CleanlogCommand.defaultMinutesToSleep; > } > : 'cleanLogs' command_options? { > commandList.add(new CleanlogCommand(stageParameters, > $command::timeout, > $command::notifyList)); > } > ; > > cleanup > @init { > $command::timeout = CleanlogCommand.defaultMinutesToSleep; > } > : 'cleanup' command_options ? { > commandList.add(new CleanupCommand(stageParameters, > $command::timeout, > $command::notifyList)); > } > ; > > shellCommand > @init { > $command::timeout = ShellCommand.defaultMinutesToSleep; > } > : 'shellCommand' timeoutOption? COMMAND_TEXT { > commandList.add(new ShellCommand(stageParameters, > $COMMAND_TEXT.text)); > } > ; > > command_options: > timeoutOption > | notifyOption > | timeoutOption notifyOption > | notifyOption timeoutOption > ; > > timeoutOption: > '-timeout' INT { $command::timeout = Integer.parseInt($INT.text); } > ; > > notifyOption: '-notify' EMAIL { > $command::notifyList.add($EMAIL.text); > } > | '-notify' QUOTED_STRING { > String[] l = $QUOTED_STRING.text.split("\\s+"); > > for (int i = 0; i < l.length; i++) { > $command::notifyList.add(l[i]); > } > } > ; > > COMMAND_TEXT: (options {greedy=false;} : . )* '\r'? '\n' { > setText(getText().trim()); > } > ; > > QUOTED_STRING: > '"' ( EscapeSequence | ~('\\'|'"') )* '"' { > setText(getText().substring(1, getText().length() - 1)); > } > | '\'' ( EscapeSequence | ~('\\'|'\'') )* '\'' { > setText(getText().substring(1, getText().length() - 1)); > } > ; > > fragment > EscapeSequence : '\\' ('\"'|'\''|'\\') ; > > INT: '0'..'9'+ > ; > > ID: 'a'..'z'+ > ; > > EMAIL: ~('\n' | '\r' | ' ' | '"')+ > ; > > NEWLINE: > '\r'? '\n' > ; > > COMMENT > : '//' ~('\n'|'\r')* '\r'? '\n' { skip(); } > | '/*' ( options {greedy=false;} : . )* '*/' { skip(); } > ; > > WS: (' ' | '\t')+ { skip(); } > ; > > 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.
