WANTED: stylistic advice/guidelines for YACC and LEX

timd@Starbase.NeoSoft.COM (TimD)
27 Jan 1996 01:08:06 -0500

          From comp.compilers

Related articles
WANTED: stylistic advice/guidelines for YACC and LEX timd@Starbase.NeoSoft.COM (1996-01-27)
Re: WANTED: stylistic advice/guidelines for YACC and LEX scooter@mccabe.com (Scott Stanchfield) (1996-01-29)
Re: WANTED: stylistic advice/guidelines for YACC and LEX rmonroe@hever.demon.co.uk (Robert F. Monroe) (1996-01-31)
Re: WANTED: stylistic advice/guidelines for YACC and LEX rmonroe@hever.demon.co.uk (Robert F. Monroe) (1996-02-02)
Re: WANTED: stylistic advice/guidelines for YACC and LEX Robert@hever.demon.co.uk (Robert F. Monroe) (1996-02-04)
Re: WANTED: stylistic advice/guidelines for YACC and LEX rmonroe@hever.demon.co.uk (Robert F. Monroe) (1996-02-09)
Re: WANTED: stylistic advice/guidelines for YACC and LEX ltribble@msmail4.hac.com (Tribble, Louis) (1996-02-09)
| List of all articles for this month |

From: timd@Starbase.NeoSoft.COM (TimD)
Newsgroups: comp.compilers
Date: 27 Jan 1996 01:08:06 -0500
Organization: NeoSoft, Inc. +1 713 968 5800
Keywords: lex, yacc, question

Okay, so I know how to write specifications in LEX and YACC. I've
done it it in C and Ada and even C++ (sort of). I would like to
hear about some of the following from others:


      1 - YACC/LEX programming style suggestions
      2 - common tricks in YACC and LEX
      3 - difficulties in using C YACC/LEX with C++


EG:


(1) For example, when I write a spec with an action, I try to
          put the action code in a subroutine. Compare:


    A : B C D
              {
                    type_a *v_a;


                    v_a = new_type_a();
                    v_a->b = $1->get_b();
                    v_a->c = $1->get_c();
                    v_a->d = $1->get_d();
                    $$ = v_a;
              }


          with


    A : B C D
              {
                    $$ = make_a_from_b_c_d($1,$2,$3);
              }


          To me, the benefits of doing this are:


                1) the yacc spec is shorter (more modular) and easier to read.
                2) when stepping through the code in a debugger, it is easier
                      to tell where you are.


Well, just looking for opinions and ideas...


-t
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.