[J3] [SC22WG5.6520] RE: [ukfortran] RE: Fwd: [SC 22 Convenors] JTC 1 plenary wrap-up - Electronic attachments to standard

Van Snyder van.snyder at sbcglobal.net
Thu Nov 23 21:58:48 UTC 2023


On Wed, 2023-11-22 at 16:50 -0600, Kurt W Hirchert via J3 wrote:
>     On 11/22/2023 12:30 PM, Van Snyder via
>       J3 wrote:
> 
>     
>     
> >       
> >       On Wed, 2023-11-22 at 11:54 +0900, Malcolm Cohen via J3
> >         wrote:
> >       
> > >         Actually, the reason we stopped doing a
> > >           syntax rule annex was that the procedure/program for
> > > making it
> > >           failed, so it was wrong.
> > >       
> > 
> >       
> > 
> >       
> >       Thanks for remembering this. Kurt wrote a Perl program to
> >         extract them. Perl is a write-only language, so the program
> >         could not be repaired.
> >       
> > 
> >       
> >     
> 
>     From Malcolm's description of the process, I had assumed
>       something else had replaced my original Perl program.  While it
> is
>       certainly possible to write Perl that looks like line noise, it
> is
>       also possible to write in styles that are quite readable.  I
> hope
>       my program was closer to the latter.  As I remember it, the
>       biggest problem at the time was that there was no definitive
>       termination of syntax rules and constraints in the LaTeX, so we
>       had to use some heuristics to decide how much to copy.  Its
> been
>       more than two decades since I wrote my program, so I might be
>       misremembering, but I believe we weren't numbering constraints
> at
>       that time, so I assume my program was either updated or
> replaced
>       to address that change.
>     If there is enough demand for it, I would be happy to try to
>       modify my old program or write a new one to extract the rules
> and
>       constraints from the current LaTeX source.
> 
>     
>     -Kurt
> 
>     
>   
> 

The syntax rules and constraints are well delineated. The syntax rules
all begin \bnf, with another letter to specify precisely what to do,
such as \bnfi is for an "is" rule and  \bnfo is for the "or" part of a
rule. Different \bnf* macros have different numbers of arguments
enclosed in curly brackets, with the most being three. The only time
there would be ambiguity in collecting this in a program that doesn't
individually recognize each rule and then parse the requisite number of
arguments is if a syntax rule is immediately followed by text enclosed
in curly brackets. I'm pretty sure that this does not appear.

Constraints are mostly set by a \dcons macro, with its main argument in
curly brackets, and an optional first argument in square brackets if it
refers to a specific syntax rule, but there's also a \begin{cons} ...
\end{cons} environment.

This is all in the j3.cls file that's part of the tarball Malcolm puts
into the /EDIT folder. Look for "Macros for BNF" and "Environment for
constraints."

The annex of syntax rules and constraints was created by extracting the
syntax rules and constraints into a separate LaTeX file, which was then
typeset by an \include (or maybe \input) macro. To print the same rule
numbers as in the main body, each \bnfi rule (bnf "is"), which
increments a counter and makes the LHS a label for that counter value,
was replaced by a  \bnfn macro wherein the number is determined by
reference to the left-hand-side, instead of creating a new one (or
maybe the \bnfi macro was changed to be \bnfr in that annex).

If that annex could be reinstated, with an option whether to typeset
it, it could be extracted and then converted to text to make it useful
to tools that generate grammars for parser generators. Instead of
setting up the standard process to typeset (or not typeset) the annex,
it could be a stand-alone document that uses the "xr" package and
\externaldocument macro to access the syntax rule numbers from the
standard's .aux files.

What had initially confused me was that we had at one time a separate
index of syntax rule names. We decided it would be easier to use if
they were in the main index, so the "put the syntax rule in a special
index" macro became simply another name for "put the syntax rule in the
main index."


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20231123/24f9783b/attachment.htm>


More information about the J3 mailing list