Luzgan
Luzgan

Reputation: 106

Bison pseudo-variables returns wrong value

I have strange problem with Bison. I'm begginer, so correct me if I'm wrong, but $1,$2...and so on should return values from first, second and so on terminal/nonterminals, yes?

command: IDENT{printf("%s",$1);} SET{printf("%s",$1);} expression{printf("%s",$1);} ENDCMD

I doing compilator, and i traped because from above example, I had for expression like "a := 1" (where ident is "a", set is ":=" and num is "1") "a" in first call, "a :=" in second and "a := 1" in third.

%union {
    int ival;
    char *sval;
}

ident is sval.

Important thing, I think, is that i recently add string to my bison file. Previously everything was ok.

Upvotes: 0

Views: 427

Answers (1)

Luzgan
Luzgan

Reputation: 106

Ok. Now I should blame myself. I dig deeper in stackoverflow and found that: http://www.gnu.org/software/bison/manual/html_node/Strings-are-Destroyed.html. Whats of course a

Upvotes: 1

Related Questions