Hi Bart Here is. It's just a change in LEFTY: --- fragment Digit :'0'..'9'; DEC_NUMBER: '1'..'9' Digit*;
fragment Letter :'a'..'z'|'A'..'Z'; WS : ('\n'|'\r'|'\t'|' ') {$channel=HIDDEN;}; LEFTY: (Letter|Digit) ('.'|Letter|Digit|'-')* '['; RIGHTY: ']' (('-' (Letter|Digit))|Letter|Digit)* ; number :DEC_NUMBER; range: LEFTY number '..' number RIGHTY; --- Le 28/06/11 23:51, Bart Kiers a écrit : > Hi Fabien, > > Can you post the grammar that produces the error? > > Bart. > > > On Wed, Jun 29, 2011 at 5:57 AM, Fabien Hermenier > <hermenierfab...@gmail.com <mailto:hermenierfab...@gmail.com>> wrote: > > Hi > > I am sorry, but this is another problem related to sequence of > integer. > I don't understand my error(s), despite severals > pass on the wiki page related to this use case. > > I want to parse a string with a "sequence" parameter into it, such as > "toto-[2 ..3]-toto". > Here is a short version of the grammar that works perfectly: > --- > grammar tryout; > > options { > k=3; > } > fragment Digit :'0'..'9'; > DEC_NUMBER: '1'..'9' Digit*; > > fragment Letter :'a'..'z'|'A'..'Z'; > > WS : ('\n'|'\r'|'\t'|' ') {$channel=HIDDEN;}; > LEFTY: (Letter|Digit) (Letter|Digit|'-')* '['; > RIGHTY: ']' (('-' (Letter|Digit))|Letter|Digit)* ; > > > number :DEC_NUMBER; //HEX_NUMBER, OCT_NUMBER, ... are following but > removed for this example. > > range: LEFTY number '..' number RIGHTY; > --- > > This grammar accepts "toto-[1..3]-toto" or "toto-[1 .. 3]-toto". > Now, I want to be able to accept the LEFTY token or the RIGHTY token > even if they contains a '.' inside (not at the beginning). So I've > modified LEFTY as following: > LEFTY: (Letter|Digit) ('.'|Letter|Digit|'-')* '['; > > Now, ANTLR does no longer accept "toto-[1..3]-toto". It requires at > least one space between the first number and the range. > I have read the wiki page related to range, integer, and so one. > But in > my case, I don't see where my grammar is ambiguous as no token > can start with a '.' . So it seems there is a concept I don't get. Can > anyone try to help me ? > > Thanks in advance, > Fabien. > > List: http://www.antlr.org/mailman/listinfo/antlr-interest > Unsubscribe: > http://www.antlr.org/mailman/options/antlr-interest/your-email-address > > -- postdoctoral researcher at Flux School of Computing, University of Utah http://sites.google.com/site/hermenierfabien/home 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 il-antlr-inter...@googlegroups.com. To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.