parsing - Basic problem with yacc/lex -
I have some problems with a very simple yacc / lex program. I have probably forgotten some basic steps (when I have used these tools since then it has been a long time).
In my Lex program, I have some basic values like:
word [a-zA-Z] [a-zA-Z] * %% ":" Return (PV); {Word} {Yiwal = yatex; Printf ("yylval =% s \ n", yellow); Return (word); } "\ N" return (ENDLINE);
In my yacc program is the beginning of my grammar (where the translation UIT is my% beginning):
Translation: / * nothing * / | InfoBlock data; InfoBlock: / * None * / | InfoBlock InfoExpression {}; Information Expression: Word PV Word Endline {printf ("$ 1 =% s \ n", $ 1); Printf ("$ 2 =% s \ n", $ 2); Printf ("$ 3 =% s \ n", $ 3); Printf ("$ 4 =% s \ n", $ 4); } | ... /* other things */ ; Data: ... / * Other Things * /
When I run my program with input:
keyword: value
< / Pre>I thought I would get the least:
$ 1 = keyword $ 2 = keyword // do not change yylval for tokoni $ 3 = value $ 4 = value / Not really changed to Yolwel token:
$ 1 = keyword: value $ 2 = keyword: value $ 3 = value $ 4 = value
I do not understand the result I had some time ago Studied extracts and even if I do not remember everything, so I have no significant fault ...
Thanks in advance for your help.
The problem is that unless you do not save the token, overwriting Lex / Wide Space Goes for, or points to a different place, etc. Before it is modified, you need to hide important information. Your printing in Lex Code should show you that See also that the same basic problem was encountered and diagnosed. yylval
values were exact at that point when
Comments
Post a Comment