bug-bison
[Top][All Lists]
Advanced

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

bug


From: IJ/ETH
Subject: bug
Date: Fri, 4 Mar 2005 16:06:21 +0100

Dear Experts!

Try this module:

bug.y:
---------------------------

%name-prefix="bug_yy"
%output="bug.c"

%union {
  char *s;
}

%token <s> TOK_Begin "["
%token <s> TOK_End "]"


%type <s> S

%destructor {free($$);}
S
TOK_Begin
TOK_End

%%

S:
  TOK_Begin TOK_End
  {free($1); free($2);}
;

%%

--------------------------------------

bison bug.y

see the destructor for TOK_Begin and TOK_End:

bug.c
---------------------------
...

#if defined (__STDC__) || defined (__cplusplus)
static void
yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
#else
static void
yydestruct (yymsg, yytype, yyvaluep)
    const char *yymsg;
    int yytype;
    YYSTYPE *yyvaluep;
#endif
{
  /* Pacify ``unused variable'' warnings.  */
  (void) yyvaluep;

  if (!yymsg)
    yymsg = "Deleting";
  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);

  switch (yytype)
    {
      case ["bug.y"], [14], ["]": /* "["], [3], [{free(]b4_dollar_dollar[);}], 
[s] */
#line 14 "bug.y"
        4;
#line 698 "bug.c"
        break;
      case 6: /* S */
#line 14 "bug.y"
        {free((yyvaluep->s));};
#line 703 "bug.c"
        break;

      default:
        break;
    }
}

...
-------------------------------------------------------

If i change the name of TOK_Begin and TOK_End, then everything is OK. Perhaps 
'[' and ']' should be escaped somehow for m4.

Regards,
/M




reply via email to

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