Skip to content

Commit d37fe83

Browse files
authored
[spec] Tweak GRAMMAR_INLINE macro (#4328)
Add CSS `bnf_inline` class with distinct `background-color` vs `P`. Make `GRAMMAR_INLINE` use `bnf_inline`. Use `GRAMMAR_INLINE` for `goto` inline grammar forms.
1 parent c065eaf commit d37fe83

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

book/dlang.org.ddoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ GNAME=<a id="$0">$(SPANC gname, $0)</a>
186186
GRAMMAR=$(TC pre, bnf notranslate, $0)
187187
GRAMMAR_INFORMATIVE=$(GRAMMAR $0)
188188
GRAMMAR_LEX=$(GRAMMAR $0)
189-
GRAMMAR_INLINE=$(TC tt, bnf notranslate, $0)
189+
GRAMMAR_INLINE=$(TC tt, bnf_inline notranslate, $0)
190190
GREEN=$(SPANC green, $0)
191191
GSELF=$(I $0)
192192
GT=&gt;

css/style.css

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ body, .d_decl .quickindex
4444
font-family: "Roboto Slab", sans-serif;
4545
}
4646

47-
pre, code, .tt, .d_inlinecode, td.param_id, .CodeMirror pre, .d_decl
47+
pre, code, .tt, .d_inlinecode, .bnf_inline, td.param_id, .CodeMirror pre, .d_decl
4848
{
4949
font-family: Consolas, "Bitstream Vera Sans Mono", "Andale Mono", Monaco, "DejaVu Sans Mono", "Lucida Console", monospace;
5050
}
@@ -1202,6 +1202,12 @@ body.dcompiler dt a.anchor:hover:before
12021202
background-color: white;
12031203
}
12041204

1205+
.bnf_inline
1206+
{
1207+
font-size: small;
1208+
background-color: #F5F5F5; /* differentiate grammar from paragraph punctuation */
1209+
}
1210+
12051211
.ddoccode
12061212
{
12071213
background-color: #f3eeee;

dlang.org.ddoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ $(COMMENT GRAMMAR invocations will appear in spec/grammar.html, but NOT the suff
189189
GRAMMAR=$(TC pre, bnf notranslate, $0)
190190
GRAMMAR_INFORMATIVE=$(GRAMMAR $0)
191191
GRAMMAR_LEX=$(GRAMMAR $0)
192-
GRAMMAR_INLINE=$(TC tt, bnf notranslate, $0)
192+
GRAMMAR_INLINE=$(TC tt, bnf_inline notranslate, $0)
193193
GREEN=$(SPANC green, $0)
194194
GSELF=$(I $0)
195195
GT=&gt;

spec/expression.dd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1911,7 +1911,7 @@ $(GNAME Slice):
19111911
The special variable `$` is declared and set to be the number
19121912
of elements in the $(I PostfixExpression) (when available).
19131913
A new declaration scope is created for the evaluation of the
1914-
$(GRAMMAR_INLINE *AssignExpression* .. *AssignExpression*) and `$` appears in
1914+
$(GRAMMAR_INLINE *AssignExpression* `..` *AssignExpression*) and `$` appears in
19151915
that scope only.
19161916
)
19171917

spec/statement.dd

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,16 +1808,15 @@ L1:
18081808
---
18091809
)
18101810

1811-
$(P The second form, $(CODE goto default;), transfers to the innermost $(GLINK
1811+
$(P The second form, $(GRAMMAR_INLINE `goto default`;), transfers to the innermost $(GLINK
18121812
DefaultStatement) of an enclosing $(GLINK SwitchStatement).)
18131813

1814-
$(P The third form, $(CODE goto case;), transfers to the
1814+
$(P The third form, $(GRAMMAR_INLINE `goto case`;), transfers to the
18151815
next $(GLINK CaseStatement) of the innermost enclosing
18161816
$(GLINK SwitchStatement).)
18171817

1818-
$(P The fourth form, $(CODE goto case) *Expression*$(D ;), transfers to the
1819-
$(GLINK CaseStatement) of the innermost enclosing
1820-
$(GLINK SwitchStatement)
1818+
$(P The fourth form, $(GRAMMAR_INLINE `goto case` *Expression*;), transfers to the
1819+
$(GLINK CaseStatement) of the innermost enclosing $(GLINK SwitchStatement)
18211820
with a matching *Expression*.)
18221821

18231822
$(SPEC_RUNNABLE_EXAMPLE_RUN
@@ -1842,15 +1841,15 @@ switch (x)
18421841
---
18431842
)
18441843

1845-
$(P Any intervening finally clauses are executed, along with releasing any
1844+
$(P Any intervening `finally` clauses are executed, along with releasing any
18461845
intervening synchronization mutexes.)
18471846

18481847
$(P It is illegal for a $(I GotoStatement) to be used to skip
18491848
initializations within its containing scope.)
18501849

18511850
$(BEST_PRACTICE Prefer using a higher-level control-flow construct
18521851
or a labelled $(GLINK BreakStatement)/$(GLINK ContinueStatement)
1853-
rather than the $(GRAMMAR_INLINE *`goto` Identifier;*) form.)
1852+
rather than the $(GRAMMAR_INLINE `goto` *Identifier*;) form.)
18541853

18551854

18561855
$(H2 $(LEGACY_LNAME2 WithStatement, with-statement, With Statement))

0 commit comments

Comments
 (0)