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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,50e705cdf2767cc6 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!feeder2.cambriumusenet.nl!feed.tweaknews.nl!193.201.147.93.MISMATCH!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!news.tele.dk!news.tele.dk!small.news.tele.dk!bnewspeer01.bru.ops.eu.uu.net!bnewspeer00.bru.ops.eu.uu.net!emea.uu.net!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Parser interface design Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1p6q05xtgjspf.7qanu7wlynvi$.dlg@40tude.net> Date: Fri, 8 Apr 2011 16:21:10 +0200 Message-ID: NNTP-Posting-Date: 08 Apr 2011 16:21:09 CEST NNTP-Posting-Host: 8ceb9b63.newsspool1.arcor-online.net X-Trace: DXC=9347lF`n@P]\Dic==]BZ:afN4Fo<]lROoRA<`=YMgDjhgBd2OU1aaAFVD[6LHn;2LCVN7enW;^6ZC`D\`mfM[68DCCg9FcaOfIJQO X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:19694 Date: 2011-04-08T16:21:09+02:00 List-Id: 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