Paper-thin Parser Front-End: How?

charleyb@gr.hp.com (Charley Bay (Contract))
Thu, 30 Nov 1995 16:44:42 GMT

          From comp.compilers

Related articles
Paper-thin Parser Front-End: How? charleyb@gr.hp.com) (1995-11-30)
| List of all articles for this month |
Newsgroups: comp.compilers
From: charleyb@gr.hp.com (Charley Bay (Contract))
Keywords: parse, question
Organization: Hewlett-Packard Co., Greeley, CO, USA
Date: Thu, 30 Nov 1995 16:44:42 GMT

I like compilers, I just don't want to write another one.


I've built a meta-data infrastructure to manipulate "code-item"
components, and my issue now is to build a parse mechanism
to identify "code items" in source files, which will be inserted
into my meta-data infrastructure. The goal of the system is
to generate metrics and other meta-data on the actual source,
(including re-generating the source after analysis).


I WAS going to use lex/yacc, and have little "one-liner" function
calls off each yacc reduction that simply adds that code item
to my infrastructure. I want the parser to be paper-thin,
because I need to support at least two languages (C++ and ADA),
and I'm going to have to keep the parser in sync (ouch!) with
the current languages' rules.


I've been trying to better understand PCCTS to compare it with
lex and yacc (which I think I understand pretty well). However,
I'm now wondering if I don't even need lex/yacc:


(1) I'm not building a compiler. I don't need recursive
        descent capability because I can "insert" items at any
        time into my meta-data infrastructure.


(2) I think I want to "insert" at a point that may not actually
        be a reduction: For example,
              class X {
              class X :
        is adequate for me to acknowledge this is a "class defined"
        code item, even though NO reduction would have taken place.
        I can append members later.


(3) I need to track additional meta-information, like the
        absolute location of a C++ Namespace member declaration
        while parsing across files (read that as linking reference).
        I'm not quite sure how compilers do this one, though.


What does this mean? Am I really better off writing (read that
as MAINTAINING) my own customized parser for each language?


The system is in C++, and I was going to use the MKS Lex/Yacc
just to get the C++ calling interface (I thought I would also
need recursive call capability, but now I don't think so).


--
--charley #include <stdisclaimer.h>
charleyb@gr.hp.com -or- charley@agrostis.nrel.colostate.edu
--


Post a followup to this message

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