[antlr-interest] Serious Bug when using BitSetgeneration

Olivier Dragon dragonoe at mcmaster.ca
Fri Nov 11 07:35:51 PST 2005


On Wed, Nov 09, 2005 at 02:55:35PM -0800, Terence Parr wrote:
> First, why is this not what you want:
> 
> NUMERAL:
> 	('0'..'9')+ // integer
> 	(
> 		'h' // hex
> 	|	'.' ('0'..'9')* // real
> 	)?
> 	;
> 
> Why the predicate?  Set k=2 and it should work perfectly.

Unfortunatly it doesn't work. With k=2 and default value for
codeGenMakeSwitchThreshold I get:


		switch ( LA(1)) {
		case 'h':
		{
			match('h');
			break;
		}
		case '.':
		{
			match('.');
			{
			_loop7:
			do {
				if (((LA(1) >= '0' && LA(1) <= '9'))) {
					matchRange('0','9');
				}
				else {
					break _loop7;
				}
				
			} while (true);
			}
			break;
		}
		default:
			{
			}
		}


If I put k=2 and codeGenMakeSwitchThreshold=2 I get something wrong as
well:


		if ((LA(1)=='h')) {
			match('h');
		}
		else if ((LA(1)=='.')) {
			match('.');
			{
			_loop23:
			do {
				if (((LA(1) >= '0' && LA(1) <= '9'))) {
					matchRange('0','9');
				}
				else {
					break _loop23;
				}
				
			} while (true);
			}
		}
		else {
		}

It's like ANTLR doesn't see the non-determinism between OP: ".gt." and
the NUMERAL rule. I also tried changing the (HEX | REAL)? part to
(HEX | REAL | ) and got the same result. I tried increasing look-ahead
to k=5 but got the result as well.

I've tried with both ANTLR 2.7.5 and ANTLR 2.7.6 preview that came with
the the antlreclipse plugin v4.0.0-b2 and Java 1.5. Should I try with a
newer version? 3.0aX?

-Olivier

-- 
          __-/|    ? ?     |\-__
     __--/  /  \   (^^)   /  \  \--__
  _-/   /   /  /\ / ( )  /\  \   \   \-_
 /  /   /  /  /  (   ^^ ~  \  \  \   \  \
 / Oli Dragon    ( dragonoe at mcmaster.ca \
/  B.Eng. Sfwr   (     )    \    \  \    \
/  /  /    /__--_ (   ) __--__\    \  \  \
|  /  /  _/        \_ \_       \_  \  \  |
 \/  / _/            \_ \_       \_ \  \/
  \_/ /                -\_\        \ \_/
    \/                    )         \/
                        *~
        ___--<***************>--___
       [http://dragon.homelinux.org]
        ~~~--<***************>--~~~
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20051111/77d262cb/attachment.bin


More information about the antlr-interest mailing list