Re: C/C++ Expression Parsing with Visual Parse++ (John Lilley)
6 Oct 1996 00:55:58 -0400

          From comp.compilers

Related articles
C/C++ Expression Parsing with Visual Parse++ (Mark Bracey) (1996-10-03)
Re: C/C++ Expression Parsing with Visual Parse++ (1996-10-06)
| List of all articles for this month |

From: (John Lilley)
Newsgroups: comp.compilers
Date: 6 Oct 1996 00:55:58 -0400
Organization: Nerds for Hire, Inc.
References: 96-10-015
Keywords: parse, C++ says...
>I'm new to this group and am wondering if anyone could give me a few
>hints on using Visual Parse++ to create an expression evaluation
>parser for C/C++. The difficulty I am encountering deals with the
>ability to support a symbol table. I don't want to do a symbol table
>look up every time I resolve an expression so I need to parse to a
>stream of tokens, and then be able to resolve that stream on a demand

I've checked out the C++ grammar supplied with Visual Parse++ (if you
don't have it, get it from their ftp site). It is basically a port of
Jim Roskind's C++ grammar for YACC, which I would also get for
reference. It has some problems, most notably (1) the lack of a
symbol table, (2) incorrect handling of some ambiguities, and (3)
missing features (exceptions, templates, etc). The symbol table is
the biggest problem, because without it you cannot resolve the classic
id/typedef ambiguity. In C++ this is made even worse by the nested
scope nature of the symbol table. So it can be done, but requires
considerable work. Of course, if you have no typedefs (meaning that
you're willing to live without a portion of the expression grammar),
then it's pretty simple. I'd still get the grammar that the SandStone
people supply.

I've been working on a C++ grammar that uses PCCTS. It's a bit more
complete than Roskind's, but you have to deal with the fact that it's
an LL parser instead of an LALR parser. However, it has predication
to make up for some of those deficiencies, and backtracking handles
everything else (albeit with some runtime expense).

For more info, check out:

which is down for a few days but should work soon

john lilley

Post a followup to this message

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