help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Parsing if, while, for, etc


From: Hans Aberg
Subject: Re: Parsing if, while, for, etc
Date: Thu, 7 Dec 2000 12:23:23 +0100

At 22:09 +1100 0-12-02, James Buchanan wrote:
>I have a book called Lex & Yacc by O'Rielly, however its coverage
>of parsing conditionals and loops is pitiful to say the least. It is
>excellent in all other areas, but it's a total failure in conditionals and
>loops.
>
>I am wondering what other people do when needing to
>parse loops and conditionals. Let's suppose we are generating
>pseudo assembler as a kind of intermediate representation, and
>come across something like this in a source file:
...
>Can someone tell me, if they have ever written a grammar involving
>conditionals and loops, what you do when you need to generate
>code for them or what you do when you execute statements
>straight away as in an interpreted script?

An input:

My guess is that you are not asking about a problem that has anything to do
with parsing and such in itself, but in general how to build a "function
cover". Simon Peyton-Jones has written a book on implementation of
functional languages, which I think might describe how to do this in the
context of a low functional language.

In C++ one can produce such covers one the fly, by creating classes and
instantiation of those. This makes use of the C++ feature to create
"temporaries". In a more low-level language like C (or assembler), one must
figure out by hand where to put these temporaries, in "registers"
(specially assigned memory locations) or perhaps sometimes on the parameter
stack.

  Hans Aberg





reply via email to

[Prev in Thread] Current Thread [Next in Thread]