|Lex and Yacc Newbie Questions!!! email@example.com (2004-03-26)|
|Re: Lex and Yacc Newbie Questions!!! firstname.lastname@example.org (2004-04-04)|
|Re: Lex and Yacc Newbie Questions!!! email@example.com (Tim Bauer) (2004-04-14)|
|From:||firstname.lastname@example.org (Hari Sriniv)|
|Date:||26 Mar 2004 22:03:12 -0500|
|Keywords:||lex, yacc, question, comment|
|Posted-Date:||26 Mar 2004 22:03:12 EST|
I have some rudimentary question with the Lex and Yacc. I have been
developing an assembler for the in house processsor. I have assembled
the normal instructions pretty easily using the lex and Yacc. I have
some challenges for the branch instructions. I have also made some
progress in it and also know how to approach it. But I am a little bit
confused as how to do it in Lex and Yacc. What I have in mind is to
make 2 passes.
During the first pass, I will get associate the labels to the PC
(Prog. Counter) value and during the second pass assemble all the
instructions and for the Branch instructions assemble using the PC
values from the first pass. For this I have to open the same file
twice and parse it using lex and Yacc.
Whats happening here is I have assigned a variable in a header file
(say prc_defines.h) named static unsigned int Firstpass (This is the
flag I am using in my program). This .h file is included in main.c and
asm.y. Everything is fine and good during the first pass. It
associates the label to PC. But during the second pass the I change
the Firstpass (flag) to zero which signifies that it is not the first
pass and still, it works as though the it is the firstpass. I
understand (guess) the yyparse() initializes the variable defined
inthe prc_defines.h to 1 which makes it to behave like a first pass.
See the value changed in the main.c is overridden inside the asm.y.
Any thoughts, help as how to solve this puzzle in lex and yacc.
Any help is greatly appreciated. Thanks in advance.
[Look at the generated yyparse(), debug it like any other C code. -John]
Return to the
Search the comp.compilers archives again.