Help with IF-ELSEIF-ELSE-ENDIF Coding

ddalton@dcscorp.com (Learning)
10 Oct 2001 15:54:04 -0400

          From comp.compilers

Related articles
Help with IF-ELSEIF-ELSE-ENDIF Coding ddalton@dcscorp.com (2001-10-10)
| List of all articles for this month |
From: ddalton@dcscorp.com (Learning)
Newsgroups: comp.compilers
Date: 10 Oct 2001 15:54:04 -0400
Organization: http://groups.google.com/
Keywords: design
Posted-Date: 10 Oct 2001 15:54:04 EDT

I am enhancing a compiler written be a previous employee. This may
seem like a naive question but, I figured out the grammer we wanted
now I am trying to do the code part. All the example I have looked at
are more complicated then I really want to do. This may be my lack of
knowledge but I just want to know if someone can give me an C code
example for the following:


IF '(' cond ')' statements ELSE statements ENDIF { ? },


how do I get to the ELSE statements if the "cond" ends up being false.
This is written in C using Bison to compile. If someone can please
give assistance I would greatlt appreciate it. I am waiting on a book
that many have mentioned would be good but it may take a week or so to
get in and the local bookstore don't seem to be kind enough to carry
it, but I really need to get the basics of this down in the next day
or two. Thanks
[The short answer is "with a jump". Straight-through interpretation
starts to get unpleasant as soon as you have flow of control. It's
usually easier to compile to an internal form like a parse tree or
RPN strings and then interpret that. -John]



Post a followup to this message

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