This is a follow-up question from where I told my problem in a simplified way, although it can not be solved here. It looks like without However, the way you are trying to solve it is complex. As far as I can see, you want to start (or leave) the input with the
I have the following grammar and when do I delete {true}? = & Gt; predicates, the text is no longer recognized in the input string
MODULE main LTLSPEC H {} {} {o} FALSE; . Note that the previous
; has not been token in the form of EOC, but as IGNORE when I
{true}? = & Gt; I / C> add the EOC rule
; is tokenized as EOC.
I tried to get it from the command line with the ANTLR-V 3.3 and without difference v3.4. Thanks in advance, I appreciate your help.
Grammar NusmvInput; Option {language = Java; } @ Parser :: members {public static zero principal (string [] args) Exceptions thrown {NusmvInputLexer lexer = New NusmvInputLexer (New ANTLRStringStream ("Module Head LTLSPEC H {} {} {F}}"); NusmvInputParser parser = new NusmvInputParser (new CommonTokenStream (lexer)); Parser.specification (); }} @ Letter :: members {private boolean inltl = false; } Specification: Module + EOF; Module: module module_declal; Module_decl: NAME parameter_list; Parameter_list: (LP (parameter (COMMA parameter) *)? RP? ; Parameter: (NAME | INTEGER); / **************** *** LEXER ***************************************************************************** ********************************************************************************************** other: {! InLTL}? = & Gt; ('&' | '' '' '' | 'Xor' | 'xnor' | '=' | '!' | 'Lt;'; '& gt;' | '-' | '+' '|' * * | '/' | 'Mod' | '[' '' ']' ''? '); RCP: {! INLTL}? = & Gt; '}'; LCP: {! INLTL}? = & Gt; '{'; LP: {! InLTL}? = & Gt; '('; RP: {! InLTL}? = & Gt; ')'; Module: {true}? = & Gt; 'Module' {inLTL = false;}; LTLSPC: {true}? = & Gt; 'LTLSPEC' {inLTL = true; Skip (); }; EOC: ';' {If (inLTL) {inLTL = false; Skip (); }}; WS: ('' '' '\ t' | '\ n' | '' \ r ') + {$ channel = HIDDEN;}; COMMENT: '-'. * ('\ N' | '\ r') {$ channel = HIDDEN;}; INTEGER: {! InLTL}? = & Gt; ('0' .. '9') +; NAME: {! InLTL}? = & Gt; ('A' .. 'Z' | 'A' .. 'Z' ('A' .. 'J' | 'A' .. 'Z' | '0' .. '9' | _ _ | '$' | '#' | '-') *; IGNORE: {inLTL}? = & Gt; . {Skip ();};
module and
LTLSPEC ,
NAME gets priority over it even if these tokens are defined before the
NAME token. Whether it's from design or bug, I do not know.
LTLSPEC and end it with a semi-colon, instead of doing something like this:
Specification: Module + EOF; Module: module module_declal; Module_decl: NAME parameter_list; Parameter_list: (LP (parameter (COMMA parameter) *)? RP? Parameter: (NAME | INTEGER); Module: 'Module'; LTLSPC: 'LTLSPEC' ~ '; * ';' {Skip ();}; a little break : ','; Others: ('and' | '|' | '| xor' | 'xnor' | '' '' '' '' '' lt; '|' 'gt;' | '-' '' + '| '*' | '/' | 'Mod' | '[' | ']] |' '?'); RCP: '}'; LCP: '{'; LP: '('; RP: ')'; EOC: ';'; WS: ('' '' '\ t' | '\ n' | '' \ r ') + {$ channel = HIDDEN;}; COMMENT: '-'. * ('\ N' | '\ r') {$ channel = HIDDEN;}; INTEGER: ('0' .. '9') +; Name: ('A' .. 'Z' | 'A' .. 'Z') ('A' .. 'J' | 'A' .. 'Z' | '0' .. '9' | ' _ '|' $ '' | '' '' '' - ') *;
Comments
Post a Comment