On Sun, 18 Feb 2024 09:37:10 -0500 Douglas McIlroy <douglas.mcil...@dartmouth.edu> wrote:
> 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. Maybe Chomsky doesn't matter? ISTM that "parsing input into an AST according to one grammar and unparsing to generate output according to another", if it has no theoretical examples, has many in practice. It's so common they've acquired the hip name: transpiler. For an example close to home, I give you cfront: C++ in, C out. I think you're saying there's no inverse to yacc. (Even that gives yacc too much credit. yacc doesn't produce an AST; it just lets the user create one.) Be that as it may, it certainly hasn't prevented language-to-language translation. > 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. I'm very surprised to hear you make that argument. Whatever the user may consciously do, the machine interprets the input and produces the output. groff isn't making heuristic large language model guesses about the input. It parses it, quite mechanically, regardless of the fluidity of the prose or the author's attention to convention and practice. Doug, I'm absolutely sure that you are fully aware of the points I'm making. What is it I'm missing? --jkl