Le 29/03/11 07:23, Jim Idle a écrit : > The interpreter is not likely to succeed with all those embedded fragments > and so on. Use the debugger and it will probably be fine. > > Jim I just tried my tests using the debugger and I have the same issues. But the output is not really the same (even it is a fail). Is this normal to have a different behaviour depending on the way I test my grammar ?
How may the number of fragment impacts on the interpreter ? Fabien. >> -----Original Message----- >> From: [email protected] [mailto:antlr-interest- >> [email protected]] On Behalf Of Fabien Hermenier >> Sent: Monday, March 28, 2011 11:47 PM >> To: [email protected] >> Subject: [antlr-interest] Spaces issues >> >> Hi >> >> I starting to use ANTLR3 with AntlrWorks 3.4.1 on OS X and I have some >> issues with spaces. I've attached a sample antlr file describing my >> grammar (see 1st grammar) >> >> I'm trying to test 'litteralRange'. So using the interpreter, I write >> "[2 ..3]" or "[2 .. 3]" as input and it works fine. However, if I give >> the string "[2..3]" it does not work. I have followed the tutorial and >> declare the Lexer WS with the channel hidden to ignore spaces, but I >> still have strange issues with this. >> >> Another strange fact is that if I write a reduced grammar that just >> isolate the rule I want to test, it is fine (see 2nd grammar). >> >> Does anyone have a solution or a hint ? >> >> Regards >> Fabien. >> >> --- 1st grammar --- >> grammar ANTLRVJob5; >> >> options { >> language = Java; >> output = AST; >> } >> fragment Digit :'0'..'9'; >> fragment Letter :'a'..'z'|'A'..'Z'; >> fragment HexDigit : (Digit|'a'..'f'|'A'..'F'); fragment HexPrefix: >> '0x'|'0X'; fragment HexNumber: HexPrefix HexDigit+; fragment OctNumber: >> '0' Digit+; fragment DecNumber: '0'|'1'..'9'Digit*; fragment Integer: >> HexNumber|OctNumber|DecNumber; >> fragment Name : Fqdn;/*Letter(InnerContent*(Digit|Letter))?;*/ >> fragment VarPrefix: '$'; >> fragment EnumSep: ','; >> fragment Fqdn: Domain ('.' Domain)*; >> fragment Domain: Letter ('-'?(Letter|Digit))*; >> fragment InnerContent: (Letter >> |Digit >> |'_' >> |'-' >> |'.'(Letter|Digit)); >> fragment RRange: ']' (InnerContent*(Letter|Digit))?; fragment LRange: >> (Letter (Digit|Letter|'-'|'_'|'.')*)? '['; >> >> >> INTEGER : Integer; >> NAME: Name; >> ENUMSEP: EnumSep; >> EQUALS : '='; >> ENDL : ';'; >> PLUS : '+'; >> MINUS : '-'; >> TIMES : '*'; >> VARIABLE: VarPrefix(Letter|'_')(Letter|Digit|'_')*; >> >> COMMENT >> : '//' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;} >> | '/*' ( options {greedy=false;} : . )* '*/' {$channel=HIDDEN;} >> ; >> >> WS : ('\n'|'\r'|'\t'|' ') {$channel=HIDDEN;}; >> >> >> INNERCONTENT: InnerContent+; >> RRANGE:RRange; >> LRANGE: LRange; >> LVRANGE: VarPrefix LRange; >> CONSTRAINTIDENTIFIER: Letter(Letter|Digit|'_')*'('; >> >> litteral: NAME|INTEGER; >> operator: PLUS|TIMES; >> >> litteralRange: '[' INTEGER '..' INTEGER ']'; >> >> litteralEnum: LRANGE INNERCONTENT /*(ENUMSEP INNERCONTENT)+']' >> RRANGE*/; >> >> variableEnum: LVRANGE INNERCONTENT (ENUMSEP INNERCONTENT)+ RRANGE; >> variableRange: LVRANGE INTEGER '..' INTEGER RRANGE; >> >> explodedSet:('{}'| '{'expression (ENUMSEP expression)*'}'); >> >> atom : '(' expression ')' >> |litteralRange >> ; >> >> >> expression: atom/* (operator expression)?*/; >> >> var_decl: VARIABLE EQUALS expression ';'; >> >> instruction: var_decl; >> >> vjob_decl: instruction*; >> --- >> >> --- 2nd grammar --- >> grammar some; >> >> COMMENT >> : '//' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;} >> | '/*' ( options {greedy=false;} : . )* '*/' {$channel=HIDDEN;} >> ; >> >> WS : ( ' ' >> | '\t' >> | '\r' >> | '\n' >> ) {$channel=HIDDEN;} >> ; >> fragment Digit :'0'..'9'; >> fragment HexDigit : (Digit|'a'..'f'|'A'..'F'); fragment HexPrefix: >> '0x'|'0X'; fragment HexNumber: HexPrefix HexDigit+; fragment OctNumber: >> '0' Digit+; fragment DecNumber: '0'|'1'..'9'Digit*; fragment Integer: >> HexNumber|OctNumber|DecNumber; >> >> INTEGER : Integer; >> litteralRange: '[' INTEGER '..' INTEGER ']'; >> //litteralRange: '[' INTEGER '..' INTEGER ']'; >> --- >> >> >> 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 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.
