help-bison
[Top][All Lists]
Advanced

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

using merge


From: Timo Du Four
Subject: using merge
Date: Mon, 15 Jan 2007 16:43:55 +0100
User-agent: Thunderbird 1.5.0.9 (Windows/20061207)

Dear bison users,

I'm having trouble figuring out how to use merge with a glr-parser. I found this example on the net:

        

stmt : expr ';'  %merge <stmtMerge>
    | decl      %merge <stmtMerge>
    ;
and define the |stmtMerge| function as:

        

static YYSTYPE
stmtMerge (YYSTYPE x0, YYSTYPE x1)
{
 printf ("<OR> ");
 return "";
}
with an accompanying forward declaration in the C declarations at the beginning of the file:

        

%{
 #define YYSTYPE char const *
 static YYSTYPE stmtMerge (YYSTYPE x0, YYSTYPE x1);
%}



I have a union:

%union {
   Node* node;
   bool boolean;
   int integer;
}

I would like to use Node* as YYSTYPE in my merge-function, but to do this I need a forward declaration of YYSTYPE. But when I do this, a have a redefinition of YYSTYPE, so the parser won't compile.
Am I doing something wrong, or is this impossible to do?

Timo




reply via email to

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