From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2ca464c92c72e0e9 X-Google-Attributes: gid103376,public From: Ray Blaak Subject: Re: Ada grammar Date: 2000/05/09 Message-ID: #1/1 X-Deja-AN: 621411647 Sender: blaak@ns55.infomatch.bc.ca References: <07a73f60.478cecce@usw-ex0102-015.remarq.com> <8euivq$qso$1@nnrp1.deja.com> <004d942d.2e326cd2@usw-ex0104-026.remarq.com> X-Trace: news.bc.tac.net 957930675 207.34.170.119 (Tue, 09 May 2000 20:51:15 PDT) NNTP-Posting-Date: Tue, 09 May 2000 20:51:15 PDT Newsgroups: comp.lang.ada X-Complaints-To: news@bctel.net Date: 2000-05-09T00:00:00+00:00 List-Id: bradders writes: > My company produces a UML based Real-time modelling tool. We > generate and reverse engineer code for C, C++ and Java and soon > we will be supporting Ada 95. Basically I need to be able to > Parse Ada code to build up a symbol table and populate a class > model. Everyone is telling you to use ASIS, but I think you should go for it and parse the sources directly. I have written both Ada parsers and UML reverse engineering tools, and in my opinion things are a lot more manageable if your tool does not require an ASIS-compliant Ada compiler to be installed. Your tool is more stand-alone and can work anywhere with a minimum of fuss (no configuration issues to interface to a client's existing Ada compiler) if it has minimal external dependencies. Certainly if one is reverse engineering Ada code, there is bound to be an Ada compiler nearby, but that is not reason enough to require it. A designer playing with a UML model is not necessarily the same person as the programmer compiling the Ada program. The main reasons you want your own parser are: - For design purposes you are interested a subset of the language and so can cut corners when parsing the uninteresting stuff (e.g. perhaps parsing routine bodies just enough to find the correct "end" token, but otherwise ignoring statements). - You can do tricks that a normal parser cannot do, like play games with whitespace, reconstructing comments, etc. (How good is ASIS at getting perfect reconstruction of the source)? - Even if ASIS is "perfect" with regards to giving access to absolutely every character of the source, having your own parser gives you the freedom to tailor your parsing to fit the design of your tool, so you can get access to the desired source information in the most natural way. Consider, for example, that your tool might require all sources of a project to be loaded simultaneously (i.e. if one is doing "interactive" forward/reverse engineering from UML to code and vice versa). With your own parser and parse trees you can optimize things to reduce space cost (e.g. loading on the fly, indirect token references to the source file instead of actually having contents in memory, etc.). This freedom of design is *the* reason to write your own parser. An Ada parser is non-trivial, but its not *that* hard. Tedious maybe, but not hard. The benefits are worth it, in my opinion, for a tool such as you are describing. -- Cheers, The Rhythm is around me, The Rhythm has control. Ray Blaak The Rhythm is inside me, blaak@infomatch.com The Rhythm has my soul.