bug-bison
[Top][All Lists]
Advanced

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

Wrong value on a type


From: jesus
Subject: Wrong value on a type
Date: Fri, 19 Jan 2001 11:54:44 -0500 (EST)

I had the productions:

typed   :  IDENTIFIER
           {
                $$ = $1;
           }
        ;


fparmitem : typed IDENTIFIER
          {
              printf("creating an item of type %s and named %s",$1,$2);
          }

IDENTIFIER and typed are both of type char*.

%token <str> IDENTIFIER
%type <str> typed 

When i run the program generated, with the input (for example):

integer b

the content of  $1 on fparmitem is "integer b" in orden of "integer", that
is what i expect. $2 is correctly set to "b". But if i declare a global
variable aux and change the semantic routines to:  

typed   :  IDENTIFIER
           {
                $$ = $1;
                strcpy (aux,$1);
           }
        ;


fparmitem : typed IDENTIFIER
          {
              printf("creating an item of type %s and named %s",aux,$2);
          }

the result is the expected. I think that there is some problem on the
costervation of the value on the type typed.


-- 
 Jesus Miguel Diaz Hdez
 ____________________________________

 Grupo de Redes
 Facultad de Matematica Cibernetica
 Universidad de la Habana,Cuba
 
e-mail:
   address@hidden




reply via email to

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