[antlr-interest] Faster expression parsing
Sam Harwell
sharwell at pixelminegames.com
Thu Aug 28 09:16:23 PDT 2008
In my case (with this whole email referring to the grammar in my
application, not the sample one I sent out), unary operators are handled
in the 'prefix_operator' and 'postfix_operator' steps. One thing I
forgot to mention in my first email: 21% of the total time spent in
profiling was spent in 'primary_expression'. Since the total time spent
in 'expression' was 23%, the 6 expression levels leading to
'primary_expression' are now taking so little time that it's clearly
more beneficial for me to focus on optimizing either
'primary_expression', or better yet, the items that make up the
remaining 77% of the parse time.
As an exercise, I plan to find a way to incorporate 'ternary_expression'
into the flat parsing routine, which would lead to incorporating
'assignment_expression' as well.
Sam
-----Original Message-----
From: Gavin Lambert [mailto:antlr at mirality.co.nz]
Sent: Thursday, August 28, 2008 2:51 AM
To: Sam Harwell; antlr-interest
Subject: Re: [antlr-interest] Faster expression parsing
At 15:31 28/08/2008, Sam Harwell wrote:
>Profiling my grammar showed the expression parsing as one of the
>slowest segments. The problem stemmed from the fact that this
>grammar has ~18 precedence categories of operators, so getting to
>a primary expression was unnecessarily slow. Here is an example
>grammar that shows how you can flatten groups of operators while
>maintaining a correct AST.
What about unary operators?
More information about the antlr-interest
mailing list