groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [idea] troff -Troff


From: Douglas McIlroy
Subject: Re: [idea] troff -Troff
Date: Sun, 18 Feb 2024 09:37:10 -0500

To expand on Branden's observation that translating from one member of the
roff family to another is hard, I note that the final output of roff
usually presents a text in a shape that has been fine-tuned for appearance.
In grammatic terms it might best be described in transformational terms a
la Chomsky: a basic text with a fairly simple grammar tweaked by
pretty-printing transforms.

Translation involves parsing input into an AST according to one grammar and
unparsing  to generate output according to another. Chomsky's work uses
transformational grammars primarily for generation. I'm not aware of any
implementation of the inverse: parsing according to a transformational
grammar. Certainly no practical tools exist for doing so.

Unfortunately, one doesn't consciously write roff according to the model I
have outlined. This means that parsing it is more like parsing a natural
language than a strictly defined programming language. So, the absence of
formal tools is exacerbated. Roff scripts, like everyday English, are
written according to an intuitive--and occasionally ad hoc--grammar that
varies both with authors and with time. That machine translation of natural
languages remains unreliable despite 70 years of hard work attests to the
difficulty of dealing with informal grammars.

Doug


reply via email to

[Prev in Thread] Current Thread [Next in Thread]