[antlr-interest] Which one is quicker?
Johannes Luber
jaluber at gmx.de
Fri Dec 26 03:09:14 PST 2008
chain one schrieb:
> 1.
> INT
> : '-'? DIGIT+
> ;
> FLOAT
>
> : ('-'|'+')? DIGIT+ '.' DIGIT* (('e' | 'E') ('+' | '-')? (DIGIT)+)?
> ;
>
> 2.
> INT_OR_FLOAT
> : '-'? DIGIT+ FLOAT?
> ;
>
> fragment
> FLOAT
>
> : '.' DIGIT* EXPONENT?
> ;
>
> fragment
> EXPONENT: ('e' | 'E') ('+' | '-')? (DIGIT)+;
>
>
> Which one is quicker?
> I think the 2th is quicker. Because in the 1st lex rule, A DFA is needed
> to predict if it is a INT or FLOAT.
> Am I right?
>
>
> Thanks
> Best Regards,
> Young
Did you benchmark the code? I've heard that people don't see the true
bottlenecks just by looking at code alone. Run the recognition a million
times and you should see a difference.
Johannes
More information about the antlr-interest
mailing list