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

[gram] Use 'extract' package for grammar summary #816

Merged
merged 1 commit into from Jul 18, 2016

Conversation

tkoeppe
Copy link
Contributor

@tkoeppe tkoeppe commented Jul 10, 2016

No description provided.

@tkoeppe tkoeppe force-pushed the gram branch 5 times, most recently from 55983a9 to f40ba42 Compare July 10, 2016 15:05
\usepackage[extract-env={bnftab,simplebnf,bnf,bnfkeywordtab}]{extract}
\def\PrintGrammar{\input{std-gram.ext}}}{
\usepackage[active,header=false,handles=false,copydocumentclass=false,generate=std-gram.ext,extract-env={bnftab,simplebnf,bnf,bnfkeywordtab}]{extract}
\def\PrintGrammar{Run again to include grammar summary}
Copy link
Member

@zygoloid zygoloid Jul 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this two-pass approach? Is there no way to flush the grammar at the end of the normal clauses so we can do this in one go? It seems easier to get this wrong than the current approach, since a manual deletion step is now necessary even when checking out someone else's correctly-generated change. If we can't make this automatic, then at least we should use something like \ref{grammar.not.extracted.yet} here to trigger latexmk to do another iteration, and we should always regenerate the file even if we already have a copy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be a way to close the current file by hacking into the guts of the extract package to make it close the output file and stop extracting. Then we'll get the desired output on every pass. I can try that if you'd entertain that route.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed, please take another look. I'm just calling into extract now to close the output file and reopen it under a new dummy name. The dummy file is discarded, but the point is that the main content is now always generated in the same run.

@@ -1,8 +1,9 @@
%!TEX root = std.tex
\rSec0[basic]{Basic concepts}

%gram: \rSec1[gram.basic]{Basic concepts}
%gram:
\begin{extract}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you create a wrapper environment for this with a more semantically-meaningful name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean something integrated like \grammarheading{gram.basic}{Basic concepts}?

@tkoeppe tkoeppe force-pushed the gram branch 5 times, most recently from aca11c4 to 20f4680 Compare July 13, 2016 00:13
@@ -1,6 +0,0 @@
# remove index "see" entries
/\\index.*|see/d
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this unnecessary now? (How? Do we simply not have any of these in extracted groups?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right, this construction doesn't exist at the moment. (You can see what's extracted in std-gram.ext; and there are no PDF diffs from this PR.) In the future, if such a situation comes up, we can perhaps work around with with extract and extractskip environments, or we can build another special-purpose command that changes meaning in the grammar.

@zygoloid
Copy link
Member

This looks great, thanks!

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

Successfully merging this pull request may close these issues.

None yet

2 participants