By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,501 Members | 2,861 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,501 IT Pros & Developers. It's quick & easy.

Parsing C++ with typenam tagging

P: n/a
(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.
Aug 6 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.