Re: A BibTeX grammar

Norm Tovey-Walsh writes:

>>> Am I missing something?
>>
>> What am *I* missing?
>
> A comma.
>
>   entry: -"@", @type, s*, -'{', s*, @citekey, fields?, s* -'}' .
> ...
>   entry: -"@", @type, s*, -'{', s*, @citekey, fields?, s*, -'}' .
> ...

> That’s ugly. I wonder if there’s anything reasonable that we could do
> to make that less likely.

Yeow.  That was hard to see.

Syntactically, I don't know if there is any nice solution to make that
error more detectable.

Given the current syntax, I can think of two things that might have
surfaced the error:

(1) extra parentheses around the body of the entry (or reification as a
nonterminal):

  entry: -"@", @type, s*, -'{', (s*, @citekey, fields?, s*) -'}' .

  entry: -"@", @type, s*, -'{', entry-body -'}' .
  -entrybody: s*, @citekey, fields?, s*.

but I know no motivation for inserting those parentheses, or for that
matter using that extra nonterminal.

(2) a linter of some kind.  It might be as simple as a translation of
the grammar into prose, the way some XML documentation does it:

    An entry is a sequence of
    - the character "@"
    - a type (q.v.)
    - zero or more occurrences of s (q.v.)
    - the character "{"
    - zero or more occurrences of s (q.v.)
    - a citekey (q.v.)
    - an optional occurrence of fields (q.v.)
    - zero or more occurrences of s (q.v.) separated 
      by the character "}"
    
Here I've used (q.v.) to mark what would be hyperlinks to the
description of that nonterminal.

I should put that on the list of tools to add to Gingersnap.

-- 
C. M. Sperberg-McQueen
Black Mesa Technologies LLC
http://blackmesatech.com

Received on Thursday, 17 February 2022 18:19:05 UTC