[antlr-interest] performance and token declaration order

Sébastien Kirche sebastien.kirche at gmail.com
Thu Jul 14 09:18:34 PDT 2011


Hi,

considering that the tokens are processed by the parser in the order
they are listed in the grammar, and looking at the generated code,
does it make sense to list the alternatives in the order of higher to
lower frequency ?

For example, considering the following rule :
dataType
	: Any
	| Blob
	| Boolean
	| Byte
	| Char
	| DateTime
	| Date
	| Dec
	| Double
	| Int
	| LongLong
	| Long
	| Real
	| String
	| Time
	| UInt
	| ULong ;

I have put the different types in the order they are listed in the
language help file. But while knowing that I have far more longs,
integers and strings than bytes or dates (and theoretically no Reals
for example), should I move the most used types at the beginning ? I
did not found an answer in the FAQ yet.

Regards.
-- 
Sébastien Kirche


More information about the antlr-interest mailing list