From: | Karsten Nyblad <148f3wg02@sneakemail.com> |
Newsgroups: | comp.compilers |
Date: | 19 Dec 2006 01:05:31 -0500 |
Organization: | Compilers Central |
References: | 06-09-029 06-09-042 06-09-048 06-09-060 06-09-078 06-09-093 06-12-064 06-12-066 |
Keywords: | C, parse |
Posted-Date: | 19 Dec 2006 01:05:30 EST |
Robert A Duff asks if anybody has tried parsing C or C++ without using
a context sensitive grammar, and mentions that in Ada the grammar for
array indexing and function calls are similar.
In C you can write an expression (a)-b*c. If a is a type then(a)-b*c is
equivalent to ((a)-b)*c, but if a is a variable then (a)-b*c is
equivalent to (a)-(b*c). To put it an other way: In Ada you will want
a parse tree of the same structure independently of whether a subtree is
an array indexing or a function call. It is simply a question of
putting the right labels on the nodes. In C and C++ it is not enough to
put some other labels on some nodes. You will want to reorder the tree,
and that reordering will be so complex, that it is easier to use a
context sensitive grammar.
Karsten Nyblad
148f3wg02 at sneakemail dot com
Return to the
comp.compilers page.
Search the
comp.compilers archives again.