help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Where to put '#define YYSTYPE char *'?


From: Hans Aberg
Subject: Re: Where to put '#define YYSTYPE char *'?
Date: Mon, 28 Dec 2009 10:36:36 +0100

On 28 Dec 2009, at 03:55, Peng Yu wrote:

I have the following example6.y and example6.l files. The compilation
gives me warnings. I'm not sure where to put '#define YYSTYPE char *'
(it is currently in example6.y). Could somebody let me know? The
example is from http://tldp.org/HOWTO/Lex-YACC-HOWTO-4.html

Stuff that should be seen both by the lexer and the parser are usually put in a header of its own. See for example the Bison manual 2.5.3 "The mfcalc SYmbol Table".

So define a header example6.h, included from both the .y and .l files and put
  #define YYSTYPE char *
in that. The bison -d option produces another header example6.tab.h that should be included from the .l file as well.

There now is a more advanced option where the stuff in the example6.h can be maintained from the .y file (wither by making this file, or making sure it ends up in the .tab.h file). I used a hack to do that, so I do not know exactly how to do it i current Bison. But it should be somewhere in the manual of latest Bison.

  Hans






reply via email to

[Prev in Thread] Current Thread [Next in Thread]