comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Parser interface design
Date: Wed, 6 Apr 2011 19:36:01 -0500
Date: 2011-04-06T19:36:01-05:00	[thread overview]
Message-ID: <inj0tm$i3h$1@munin.nbi.dk> (raw)
In-Reply-To: slrnipof32.2fnq.lithiumcat@sigil.instinctive.eu

"Natasha Kerensikova" <lithiumcat@gmail.com> wrote in message 
news:slrnipof32.2fnq.lithiumcat@sigil.instinctive.eu...
...
> The problem on which I want your opinion is designing the interface
> between the parser and the renderer. The point is to be able to "plug"
> may renderer into the parser, and thereby obtain a different kind of
> output, with as little code rewrite as possible (hence the idea of
> refactoring the "parser" into a re-usable part).

The tool that creates the formatted versions of the Ada Standard (and other 
documents) has pretty much this same problem. It had to take source files 
coded for an obsolete tool (Scribe) and convert them to modern (in 2000) 
formats. I defined a pair of abstract tagged types to serve as the bottom of 
the hierarchy, Input_Type and Output_Type, and then defined a set of 
operations for each. There then are multiple concrete implementations of 
each (file and buffer for Input, Text, HTML, and RTF for Output).

There is a central part of the code that uses dispatching calls to each to 
implement the actual command set of the source text files. (Note that in my 
design, the meaning of the text is fixed, only the source of the text 
changes, while you want a bit more flexibility in the parsing -- which could 
be accomplished by putting more of the parsing into the Input object. In 
hindsight, I probably should have done that as well.)

You can find the entire source code to the tool at 
http://www.ada-auth.org/arm.html (look for the formatting tool about halfway 
down the page). Note that this was a "working" program not necessarily 
designed for use as an example, so it is pretty large.

                                   Randy.





  parent reply	other threads:[~2011-04-07  0:36 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-06 10:11 Parser interface design Natasha Kerensikova
2011-04-06 12:17 ` Georg Bauhaus
2011-04-07 18:56   ` Natasha Kerensikova
2011-04-08 11:49     ` Stephen Leake
2011-04-06 12:20 ` Dmitry A. Kazakov
2011-04-07 19:14   ` Natasha Kerensikova
2011-04-07 20:31     ` Dmitry A. Kazakov
2011-04-08 13:51       ` Natasha Kerensikova
2011-04-08 14:21         ` Dmitry A. Kazakov
2011-04-12 15:58           ` Natasha Kerensikova
2011-04-12 17:14             ` Dmitry A. Kazakov
2011-04-06 15:51 ` Georg Bauhaus
2011-04-07 19:44   ` Natasha Kerensikova
2011-04-07 20:52     ` Dmitry A. Kazakov
2011-04-07 22:09     ` Simon Wright
2011-04-08 14:03       ` Natasha Kerensikova
2011-04-08 19:06         ` Jeffrey Carter
2011-04-08 19:59         ` Simon Wright
2011-04-12 16:13           ` Natasha Kerensikova
2011-04-12 17:22             ` Dmitry A. Kazakov
2011-04-12 19:02               ` Simon Wright
2011-04-13  8:20                 ` Natasha Kerensikova
2011-04-13  8:37                   ` Dmitry A. Kazakov
2011-04-13 11:06                     ` Georg Bauhaus
2011-04-13 12:46                       ` Dmitry A. Kazakov
2011-04-13 22:33                   ` Randy Brukardt
2011-04-14  6:55                     ` Natasha Kerensikova
2011-04-15  0:22                       ` Randy Brukardt
2011-04-12 21:54               ` Randy Brukardt
2011-04-07 22:13     ` Georg Bauhaus
2011-04-08 15:30       ` Natasha Kerensikova
2011-04-07  0:36 ` Randy Brukardt [this message]
2011-04-08 11:16 ` Brian Drummond
2011-04-19  9:08 ` Natasha Kerensikova
2011-04-19 12:35   ` Ludovic Brenta
2011-04-20 10:44     ` Brian Drummond
2011-04-19 17:28   ` Jeffrey Carter
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox