Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bnf / bnftab / bnfkeywordtab mess #1821

Closed
zygoloid opened this issue Nov 18, 2017 · 16 comments
Closed

fix bnf / bnftab / bnfkeywordtab mess #1821

zygoloid opened this issue Nov 18, 2017 · 16 comments
Assignees

Comments

@zygoloid
Copy link
Member

We currently have mutliple "bnf" environments:

  • bnf is used for most normal grammar snippets. It does not support \> for indenting wrapped continuation lines.
  • bnftab is used for some grammar snippets. Upside: it supports \> for indenting continuation lines. Downside: it does not automatically indent the body of a grammar definition. Each line must be prefixed with \>.
  • bnfkeywordtab is used for "keyword" lists in the grammar. Actually, it's only used for lists of operators (one in [lex], one in [over]), since our lists of keywords are in tables not in the grammar at all.

You would think that we would use bnftab when we need to wrap a line, and bnf otherwise. But actually, we use bnftab for the grammar in [lex] (some of which is wrapped) and for non-grammar snippets such as the rewrite rules in [stmt], and we use bnf for the rest of the grammar, including cases that need line wraps (where the wrapping is constructed manually using \hspace*).

This is a mess. We should make \> work in bnf environments, and remove bnftab. We should also consider renaming bnfkeywordtab since it's not actually used for keywords (the only difference between it and bnftab is that text is by default in teletype rather than in italics).

@jensmaurer
Copy link
Member

There's also ncsimplebnf for "of the form" grammar quotes. Those should probably stay as-is.

@tkoeppe
Copy link
Contributor

tkoeppe commented Nov 19, 2017

@jensmaurer: That's the "non-copying" version that doesn't get extracted into the grammar summary.

@jensmaurer
Copy link
Member

@tkoeppe: Sure, but why do we sometimes use ncsimplebnf and sometimes ncbnftab for quoted grammar snippets?

@jensmaurer jensmaurer self-assigned this Nov 19, 2017
@jensmaurer
Copy link
Member

jensmaurer commented Nov 19, 2017

Ok, I have a bnf environment where \> works for indenting at the beginning of a line (for wrapped continuations). However, [cpp] also contains \> inside a bnftab for tabbing within a grammar production (see control-line). In general, enumerations (= automatic indent) and tabbing don't mix well.
@zygoloid: Are we keeping the aligned presentation of the grammar productions in [cpp], or are they considered an oddity that can go?

@jensmaurer
Copy link
Member

It seems the "tabto" package does what I want, even inside enumerations; see https://tex.stackexchange.com/questions/15628/ . Before I go there (and introduce yet another package dependency), @zygoloid should advise whether we want to keep the aligned grammar presentation in [cpp]. If yes, I'll go for the extra package; if no, I'll remove \> in the middle of a grammar production in [cpp].

@jensmaurer jensmaurer added the decision-required A decision of the editorial group (or the Project Editor) is required. label Nov 19, 2017
@zygoloid
Copy link
Member Author

Here's what [cpp] looks like without the bnftab:

screen shot 2018-03-17 at 8 43 58 pm

That seems fine to me. Other opinions solicited (@tkoeppe?)

@zygoloid zygoloid added decision-required A decision of the editorial group (or the Project Editor) is required. and removed decision-required A decision of the editorial group (or the Project Editor) is required. labels Mar 18, 2018
@jensmaurer
Copy link
Member

@tkoeppe: What's your opinion?

@jensmaurer jensmaurer removed their assignment Mar 24, 2018
@tkoeppe
Copy link
Contributor

tkoeppe commented Apr 3, 2018

Is [cpp] the only instance where we have additional alignment apart from the first one? If so, I think that can go. I'd be happy to lose the entire set of macros related to tabbing. It might be nice to see the impact of such a change on [lex], where we mix the two kinds of grammar environments.

@tkoeppe
Copy link
Contributor

tkoeppe commented Apr 3, 2018

It looks like we can replace ncbnftab environments with ncsimplebnf environments in several cases.

@tkoeppe
Copy link
Contributor

tkoeppe commented Apr 3, 2018

In [stmt] we use bnftab environments to indent and then exdent again. The plain "bnf" environment can't do that, since it indents all lines but the first, and simplebnf doesn't come with any indentation tools at all (I think).

@tkoeppe
Copy link
Contributor

tkoeppe commented Apr 3, 2018

...but I can trivially provide such an indentation aid :-)

@tkoeppe
Copy link
Contributor

tkoeppe commented Apr 3, 2018

I got rid of all bnftabs except the ones in [cpp]. We just need to decide whether we're OK with dropping the alignment.

@tkoeppe
Copy link
Contributor

tkoeppe commented Apr 3, 2018

Removed raw \hspaces in 6b700d6.

@tkoeppe
Copy link
Contributor

tkoeppe commented Apr 4, 2018

No more uses of bnfkeywordtab as of 1541232 and parent.

@tkoeppe tkoeppe removed the decision-required A decision of the editorial group (or the Project Editor) is required. label Apr 4, 2018
@tkoeppe
Copy link
Contributor

tkoeppe commented Apr 4, 2018

I sidestepped the discussion around [cpp] by aligning the grammar with spaces (rather than tabbing) in 7f84786.

@tkoeppe
Copy link
Contributor

tkoeppe commented Apr 4, 2018

Fixed by e964cd7.

@tkoeppe tkoeppe closed this as completed Apr 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants