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.9 required=5.0 tests=BAYES_00 autolearn=ham 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: g2news1.google.com!news4.google.com!feeder.news-service.com!85.214.198.2.MISMATCH!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Parser interface design Date: Tue, 12 Apr 2011 20:02:29 +0100 Organization: A noiseless patient Spider Message-ID: References: <4d9c8c19$0$6769$9b4e6d93@newsspool3.arcor-online.net> <1ovsbvdul64pw$.1q49g3o7n296m$.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="dFCm8HWntFqmDIilBLqEJQ"; logging-data="3563"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/AKLrbi32zvezo6ey9ZRm7ZB0OrSr3J3o=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (darwin) Cancel-Lock: sha1:Z5qW9amSnfUsGH8M+yhE+dwIm/4= sha1:JdGlrtxZaGrWYpt89mNlsVRDFmc= Xref: g2news1.google.com comp.lang.ada:18778 Date: 2011-04-12T20:02:29+01:00 List-Id: "Dmitry A. Kazakov" writes: > On Tue, 12 Apr 2011 16:13:30 +0000 (UTC), Natasha Kerensikova wrote: > >> On 2011-04-08, Simon Wright wrote: > >>> In other words, HTML.Emphasize ("bar") would return "bar", but >>> No_Op ("bar") would just return "bar". >> >> And that's exactly why disabling emphasis should be done on the parser >> level: the callback only has the semantic information ("render bar >> emphasized") without any knowledge of how it was obtained (the source >> could have been "foo *bar* baz" or "foo _bar_ baz"). Therefore no >> callback can reconstruct the intact input. > > That looks wrong to me. I think that obvious design is to move it to the > renderer: > > HTML.Emphasize ("bar") -> "bar" > ASCII.Emphasize ("bar") -> "*bar*" > Plain_Text.Emphasize ("bar") -> "bar" > Gtk_Text_Buffer.Emphasize ("bar") -> sets tags around the text slice > ... > > Parser just calls On_Emphasize, the implementation of routes it to the > renderer's Emphasize, which figures out what to do. Clearly you and I think similarly here. But Natasha is (as well as being the potential implementer) the customer.