[antlr-interest] fixed the ~SET bug in lexer

Terence Parr parrt at cs.usfca.edu
Wed Mar 14 13:26:23 PDT 2007


Complicated unit tests now pass like this:

	public void testNotComplicatedSetRuleInLexer() throws Exception {
		Grammar g = new Grammar(
			"lexer grammar T;\n"+
			"A : B | ~B {;} ;\n" +
			"fragment B : 'a'|'b'|'c'..'e'|C ;\n" +
			"fragment C : 'f' ;\n"); // has to seen from B to C
		String expecting =
			".s0-'a'..'f'->:s1=>1\n" +
			".s0-{'\\u0000'..'`', 'g'..'\\uFFFE'}->:s2=>2\n";
		checkDecision(g, 1, expecting, null);

Note that it's a 2-level set.  ~B must compute set from C.  This is  
NOT during analysis, which works no problem already.  This is an NFA  
construction problem.  The analysis uses the NFA to go to a DFA.

Fixed: http://www.antlr.org:8888/browse/ANTLR-95

No code gen target changes required.


More information about the antlr-interest mailing list