On 04/14/2010 07:51 AM, Tyler Distad wrote: > I have the following grammar: > > fragment TAB : '\t'; > fragment PRINTABLE : '\u0020'..'\u007F' | TAB; > > fragment DELIM: '|||||'; > FILE_DELIMITER : DELIM (PRINTABLE ~ '|')+ DELIM;
The group (PRINTABLE ~'|') does not do what you want it to. It will match any pair of characters of which the first is a PRINTABLE and the second is not a '|' character. Thus your grammar only matches even numbers of characters between your delimiters.... > I have the following sample lexer rules: > |||||12||||| > |||||123||||| > > The ANTLR interpreter accepts the first one, but the generated tree diagram > looks like: > FILE_DELIMITER: > |--DELIM > |--PRINTABLE > |--DELIM > (Note there's only one PRINTABLE.) > > For the second one, the ANTLR interpreter blows up with a > MismatchedSetException and a diagram like: > FILE_DELIMITER: > |--DELIM > |--PRINTABLE > |--PRINTABLE > |--MismatchedSetException > > This pattern is reproducible: any input with an even number of PRINTABLE > characters succeeds. All odd inputs fail. > > Any thoughts? > > Tyler Distad > > List: http://www.antlr.org/mailman/listinfo/antlr-interest > Unsubscribe: > http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- Kevin J. Cummings [email protected] [email protected] [email protected] Registered Linux User #1232 (http://counter.li.org) 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.
