comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Parser interface design
Date: Fri, 8 Apr 2011 16:21:10 +0200
Date: 2011-04-08T16:21:09+02:00	[thread overview]
Message-ID: <r6hry0udb49j.a7rex5pdigzd.dlg@40tude.net> (raw)
In-Reply-To: slrnipu4nn.2fnq.lithiumcat@sigil.instinctive.eu

On Fri, 8 Apr 2011 13:51:51 +0000 (UTC), Natasha Kerensikova wrote:

>>> I'm asking
>>> because in my C implementation, a NULL callback was a meant to
>>> communicate to the parser that the associated active character should
>>> no longer be considered active, thereby switching off that particular
>>> feature (which is very different from having a no-op callback).
>>
>> Why should you test for anything? Just make the implementation do what is
>> required to do in order to achieve the desired effect.
> 
> Well, that test thing is an implementation detail, on which I believe is
> too early to spend time.

No, it is not an implementation, because the check happens on the caller's
side. Implementation detail is always a callee's thing .

> Then, it so happens that the set of features matches exactly the set of
> callbacks.

If the property is one of the callback, it is the callback's responsibility
to check it. Moving it to the parser is fragile design.

> I just can't imagine any design that has a use of several hierarchy, for
> now. (when writing the OP I could imagine only one design, and now I've
> already reached two designs, sketched above, so I'm progressing)

When your parser sums two numbers it does not have + as a primitive
operation. Does it? If numbers may have a hierarchy of their own, why
renderer cannot? 

> As long as the design is the client calling exactly once the parser,
> there is no need for an object to keep a hidden state, the local stack
> is enough, isn't it?

Maybe. Note that more states you glue together by maintaining single
hierarchy of "everything", more difficult it becomes for single stack. BTW,
parsing infix expressions is much simpler with two stacks. You might also
wish not to use the standard stack for such things.
 
> but as far as I can tell, parser or coordinator objects don't
> need to be tagged or in any hierarchy, or am I missing something?

You never know it in advance. It depends on the parser design. A
table-driven parser might be extended rather by extending the tables it
uses. Other parsers might be extended directly.

In Ada you lose nothing making it tagged. Differently to C++ where
"virtual" has non-zero overhead, in Ada making a procedure primitive has
zero performance cost, because the target will be resolved statically.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2011-04-08 14:21 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 [this message]
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
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