Lex , Yacc Problem

dbansidhar@indiainfo.com (Bansidhar)
14 Sep 2003 17:02:23 -0400

          From comp.compilers

Related articles
Lex , Yacc Problem dbansidhar@indiainfo.com (2003-09-14)
Re: Lex , Yacc Problem paulchen32@freenet.de (Jens Kallup) (2003-09-22)
Re: Lex , Yacc Problem rkrayhawk@aol.com (2003-09-22)
Re: Lex , Yacc Problem blackmarlin@asean-mail.com (2003-09-23)
| List of all articles for this month |

From: dbansidhar@indiainfo.com (Bansidhar)
Newsgroups: comp.compilers
Date: 14 Sep 2003 17:02:23 -0400
Organization: http://groups.google.com/
Keywords: lex, yacc
Posted-Date: 14 Sep 2003 17:02:23 EDT

Hello all ,


Actually I developing assembler for xyz processor. I am having some
interesting problem with current implementation.


Problem definition :


Consider assembly code


;a.asm
;------


#if 0
#if ((test)


.........
#endif
#endif


This is giving me error because there are no balance paranthesis . But
as we are in #if 0 block logically (test) should not be considered
(check with C preprocessor) with the same example. (I used GCC)


Actually I want to ignore the part ((test) part and
assume that it is #if 0


Some how I come to know I am in #if 0 block which
parsing for 2nd #if statement.


Requriement : Once I encounter second #if I want to insert a string "
\n " in the input so that lexer will see the second #if statement as
#if 0 ((test). How can I achieve this functionality in lex. Can I
insert some string in input file in the run time ? Or is there any
other way to achive the similar functionality..
[Lex can't count nesting levels by itself, nor can it evaluate expressions.
You can certainly help it out with code of your own that counts #if and #endif
lines and ignores them. -John]



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.