groff
[Top][All Lists]
Advanced

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

Re: [idea] troff -Troff


From: James K. Lowden
Subject: Re: [idea] troff -Troff
Date: Sat, 17 Feb 2024 17:47:32 -0500

On Fri, 16 Feb 2024 10:49:52 -0600
"G. Branden Robinson" <g.branden.robinson@gmail.com> wrote:

> That's before lex.  That's even before yacc.  That's before the first
> editions of major texts in parser theory now taught to computer
> science undergraduates were even written.

Yes, but that overstates the case.  We're talking about the country's
premier computer research lab, not an undergradute introduction to
parsing.  They were well aware of the state of the art.  

BNF was used to define Algol-60. LR(1) parsing had been investigated by
Knuth.  yacc implements a published agorithm.  It's very name, "yet
another" tells us others came before it.  

> the roff language does not have a formal grammar

Not true, unless by "formal"  you mean "expressed as BNF".  The parser
reads input and produces output.  Input not conforming to its syntax is
rejected.  That couldn't be true without a grammar to compare it to.  

> I don't know that roff can be categorized in one of the traditional
> classes

I see no reason why not.  

troff input is described quite succintly in groff(7).  Each request
takes zero or more parameters.  Those parameters may themselves include
requests; that's recursion.  It's all very well defined.  Maybe not as
tidy and orthogonal as you might like, but languages without warts are,
I'm sure you'll agree, vanishingly rare.  

I'm not sure that matters, though.  The question is whether or not man
macros can be expanded to their groff equivalents.  groff input need
not conform to any formal theory for the answer to that question to be
Yes.  

> A bit more theory before I get to the concrete.

Perhaps I missed it, but did you get to the concrete?  

Alejandro said, simply, 

>  I wanted a program that reads man(7) source and produces roff(7)
> source

Isn't that exactly what pic does?  If there's a reason man isn't
susceptible to the same treatment, can you provide a concrete example?
Because I can't think of one, and an "arbitrary number of macro
expansions" isn't one.  

For example, would a man(7) parser need to recognize groff(7)
requests?  I'm not a man fan, but pic and tbl specifically say they 
pass low-level requests transparently.  

>From my point of view, as a guy who's been using Bison for the last 3
years to parse Cobol, a project to parse man(7) and produce groff(7) is
100% feasible.  It doesn't even look particullarly hard; the whole
description is under 2000 words.   

--jkl




reply via email to

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