Parsing C++ with typenam tagging

O

Ole Nielsby

(sorry, wrong button, here is the real post:)

I'm working on a C++ parser which is to be used for various
code analysis and transformation tools.

(It's part of my PILS programming system which will be released
as opensource in a not too distant future.)

I want to do the parsing using a homebrew recursive-descent-
parser-generator system (PILS Kvernbitr) which can produce
reliable parsers for nontrivial languages like vb and t-sql - but
with C++, the "identifier" vs. "typename" schism is a problem
which prohibits the use of context-free parsing techniques.

I have considered various ways of dealing with this, and I think
my preferred option is to write an extra preprocessor that runs
after the standard preprocessor and does nothing but flag
typenames. When typenames are properly flagged, I can use
context-free parsing for the rest.

I'd like some opinions about the feasibility of this approach.
Can this preprocessor be kept substantially simpler than a full
parser? Am I right in assuming that parsing will be simplified
a lot by marking the typenames?

I ask here because it's a question of insight in the standard I
don't quite have - I'm not (yet) a hardcore C++ programmer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,166
Latest member
DollyBff32
Top