Re: Converting C to C++ (Peter Kenneth LAWREY)
Mon, 22 Nov 1993 22:42:06 GMT

          From comp.compilers

Related articles
Converting C to C++ jhall@whale.WPI.EDU (1993-11-14)
Converting C to C++ (1993-11-16)
Re: Converting C to C++ (1993-11-17)
Re: Converting C to C++ (1993-11-22)
| List of all articles for this month |

Newsgroups: comp.compilers
From: (Peter Kenneth LAWREY)
Keywords: C, parse, translator
Organization: Computer Science, University of Melbourne, Australia
References: 93-11-089 93-11-115
Date: Mon, 22 Nov 1993 22:42:06 GMT

>John Clinton Hall (jhall@whale.WPI.EDU) wrote:
>: I'm wondering what to use for my intermediate representation: a
>: "traditional" AST or a flat list of tokens? An expression such as "x1 =
>: (a + bb) * 12;" is translated to the following AST:

>: =
>: / \
>: x1 *
>: / \
>: + 12
>: / \
>: a b

Although you may want to generate C++ code which is readable, there is no
need for the translator to generate code like you do. You could just place
brackets at each fork and ignore precedence.

ie the above tree becomes (x1 = ((a + b) * 12)).
note the assignment is an expression.

This might not be as readable but it is unambigious even to one unfamiliar
with the precedence levels.


Post a followup to this message

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