|
From: | Hans Aberg |
Subject: | Re: Which one is "better" ? |
Date: | Sun, 31 Jul 2005 11:27:43 +0200 |
On 31 Jul 2005, at 01:07, Baldurien (club internet) wrote:
I have a grammar to do for my self, and since this grammar add the same expression than the one we could have in a SQL query language, I'm wondering which grammar is better in term of performance. My first one is the classical "one production per precedence" :
...
With %left, and %nonassoc (and %right too) it give this :
There is no big practical difference between these two methods, as a typical compiler spends most time in the actions and the lexer. So choose the method you are most comfortable with. Using precedence rules %left, etc. produces a more compact grammar that is also more structured, which might help human programming. Otherwise, using precedence rules cuts down the number of states, so that parser will be somewhat faster; the transitions, independent of number, are put in a lookup array, so the number does not affect parser size.
Hans Aberg
[Prev in Thread] | Current Thread | [Next in Thread] |