Re: Which one is "better" ?
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 ___ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison
Re[2]: Which one is "better" ?
Bonjour Hans, Le dimanche 31 juillet 2005 à 11:27:43, vous écriviez : HA> 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" : HA> >> With %left, and %nonassoc (and %right too) it give this : HA> There is no big practical difference between these two methods, as HA> a typical compiler spends most time in the actions and the lexer. HA> So choose the method you are most comfortable with. Using HA> precedence rules %left, etc. produces a more compact grammar that HA> is also more structured, which might help human programming. HA> Otherwise, using precedence rules cuts down the number of states, HA> so that parser will be somewhat faster; the transitions, HA> independent of number, are put in a lookup array, so the number HA> does not affect parser size. HA>Hans Aberg Oki doki for that point. I will use precedence rules (since I find it easier to work with). Now, I'm asking myself about how bison store the grammar in the produced parser : In class I've seen how to construct the LL(1) table, and the transition table for the automata, but since I've seen it only on paper, I don't know how I could efficently store this like Bison does ? (Since I would like to "translate" the C parser into a PHP one). -- Cordialement, BaldurienCourriel : [EMAIL PROTECTED] ___ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison
Re: Re[2]: Which one is "better" ?
On 31 Jul 2005, at 18:03, Baldurien (club internet) wrote: Now, I'm asking myself about how bison store the grammar in the produced parser : In class I've seen how to construct the LL(1) table, and the transition table for the automata, but since I've seen it only on paper, I don't know how I could efficently store this like Bison does ? Bison is currently only supporting LALR(1), which is essentially a cut down and compacted form of LR(1). This is described in standard books on compliers, for example, the one by Aho et al. "Compiler..." (the "dragon book"). You might look into the book by Dick Grune, available online (see the FAQ of the newsgroup comp.compilers, published there monthly). In short, the grammar isn't stored at all in the parser, only the states one sees in the ".output" file. Hans Aberg ___ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison
Re[4]: Which one is "better" ?
Bonjour Hans, Le dimanche 31 juillet 2005 à 18:43:20, vous écriviez : HA> On 31 Jul 2005, at 18:03, Baldurien (club internet) wrote: >> Now, I'm asking myself about how bison store the grammar in the >> produced parser : >> >> In class I've seen how to construct the LL(1) table, and the >> transition table for the automata, but since I've seen it only on >> paper, I don't know how I could efficently store this like Bison does >> ? HA> Bison is currently only supporting LALR(1), which is essentially a HA> cut down and compacted form of LR(1). This is described in standard HA> books on compliers, for example, the one by Aho et al. HA> "Compiler..." (the "dragon book"). You might look into the book by HA> Dick Grune, available online (see the FAQ of the newsgroup HA> comp.compilers, published there monthly). In short, the grammar isn't HA> stored at all in the parser, only the states one sees in the HA> ".output" file. HA>Hans Aberg Thank you for the Dick Grune (and Jacob)'s book. I will try to investigate, translate (since I prefer french book :o), and use it. -- Cordialement, BaldurienCourriel : [EMAIL PROTECTED] ___ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison