Skip to content

Commit 661f2dc

Browse files
committed
Apply some light edits to the grammar chapter
1 parent 6248caa commit 661f2dc

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

reference-dev-guide/src/grammar.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Rust grammar
22

3-
The Reference grammar is written in markdown code blocks using a modified BNF-like syntax (with a blend of regex and other arbitrary things). The [`mdbook-spec`] extension parses these rules and converts them to a renderable format, including railroad diagrams.
3+
The Reference grammar is written in markdown code blocks using a modified BNF-like syntax (with a blend of regex and other arbitrary things). The [`mdbook-spec`] extension parses these rules and converts them into a renderable format, including railroad diagrams.
44

5-
The code block should have a lang string with the word "grammar", a comma, and the category of the grammar, like this:
5+
The code block should have a lang string with the word `grammar`, a comma, and the category of the grammar, like this:
66

77
~~~
88
```grammar,items
@@ -14,7 +14,7 @@ The category is used to group similar productions on the grammar summary page in
1414

1515
## Grammar syntax
1616

17-
The syntax for the grammar itself is pretty close to what is described in the [Notation chapter], though there are some rendering differences.
17+
The syntax for the grammar itself is similar to what is described in the [Notation chapter], though there are some rendering differences.
1818

1919
A "root" production, marked with `@root`, is one that is not used in any other production.
2020

@@ -94,38 +94,38 @@ Group -> `(` ` `* Expression ` `* `)`
9494
NegativeExpression -> `~` ( Charset | Terminal | NonTerminal )
9595
```
9696

97-
The general format is a series of productions separated by blank lines. The expressions are:
97+
The general format is a series of productions separated by blank lines. The expressions are as follows:
9898

9999
| Expression | Example | Description |
100100
|------------|---------|-------------|
101-
| Unicode | U+0060 | A single unicode character. |
101+
| Unicode | U+0060 | A single Unicode character. |
102102
| NonTerminal | FunctionParameters | A reference to another production by name. |
103-
| Break | | This is used internally by the renderer to detect line breaks and indentation. |
103+
| Break | | Used internally by the renderer to detect line breaks and indentation. |
104104
| Comment | // Single line comment. | A comment extending to the end of the line. |
105-
| Terminal | \`example\` | This is a sequence of exact characters, surrounded by backticks |
106-
| Charset | [ \`A\`-\`Z\` \`0\`-\`9\` \`_\` ] | A choice from a set of characters, space separated. There are three different forms. |
107-
| CharacterRange | [ \`A\`-\`Z\` ] | A range of characters, each character should be in backticks.
105+
| Terminal | \`example\` | A sequence of exact characters, surrounded by backticks. |
106+
| Charset | [ \`A\`-\`Z\` \`0\`-\`9\` \`_\` ] | A choice from a set of characters, space-separated. There are three different forms. |
107+
| CharacterRange | [ \`A\`-\`Z\` ] | A range of characters; each character should be in backticks.
108108
| CharacterTerminal | [ \`x\` ] | A single character, surrounded by backticks. |
109109
| CharacterName | [ LF ] | A nonterminal, referring to another production. |
110-
| Prose | \<any ASCII character except CR\> | This is an English description of what should be matched, surrounded in angle brackets. |
111-
| Group | (\`,\` Parameter)+ | This groups an expression for the purpose of precedence, such as applying a repetition operator to a sequence of other expressions.
110+
| Prose | \<any ASCII character except CR\> | An English description of what should be matched, surrounded in angle brackets. |
111+
| Group | (\`,\` Parameter)+ | Groups an expression for the purpose of precedence, such as applying a repetition operator to a sequence of other expressions.
112112
| NegativeExpression | ~[\` \` LF] | Matches anything except the given Charset, Terminal, or Nonterminal. |
113-
| Sequence | \`fn\` Name Parameters | A sequence of expressions, where they must match in order. |
113+
| Sequence | \`fn\` Name Parameters | A sequence of expressions that must match in order. |
114114
| Alternation | Expr1 \| Expr2 | Matches only one of the given expressions, separated by the vertical pipe character. |
115-
| Suffix | \_except \[LazyBooleanExpression\]\_ | This adds a suffix to the previous expression to provide an additional English description to it, rendered in subscript. This can have limited markdown, but try to avoid anything except basics like links. |
116-
| Footnote | \[^extern-safe\] | This adds a footnote, which can supply some extra information that may be helpful to the user. The footnote itself should be defined outside of the code block like a normal markdown footnote. |
115+
| Suffix | \_except \[LazyBooleanExpression\]\_ | Adds a suffix to the previous expression to provide an additional English description, rendered in subscript. This can contain limited markdown, but try to avoid anything except basics like links. |
116+
| Footnote | \[^extern-safe\] | Adds a footnote, which can supply extra information that may be helpful to the user. The footnote itself should be defined outside of the code block like a normal markdown footnote. |
117117
| Optional | Expr? | The preceding expression is optional. |
118118
| Repeat | Expr* | The preceding expression is repeated 0 or more times. |
119119
| Repeat (non-greedy) | Expr*? | The preceding expression is repeated 0 or more times without being greedy. |
120120
| RepeatPlus | Expr+ | The preceding expression is repeated 1 or more times. |
121121
| RepeatPlus (non-greedy) | Expr+? | The preceding expression is repeated 1 or more times without being greedy. |
122-
| RepeatRange | Expr{2..4} | The preceding expression is repeated between the range of times specified. Either bounds can be excluded, which works just like Rust ranges. |
122+
| RepeatRange | Expr{2..4} | The preceding expression is repeated between the range of times specified. Either bound can be excluded, which works just like Rust ranges. |
123123

124124
## Automatic linking
125125

126-
The [`mdbook-spec`] plugin automatically adds markdown link definitions for all the production names on every page. If you want to link directly to a production name, all you need to do is surround it in square brackets, like `[ArrayExpression]`.
126+
The [`mdbook-spec`] plugin automatically adds markdown link definitions for all production names on every page. To link directly to a production name, simply surround it in square brackets, like `[ArrayExpression]`.
127127

128-
In some cases there might be name collisions with the automatic linking of rule names. In that case, disambiguate with the `grammar-` prefix, such as `[Type][grammar-Type]`. You can also do that if you just feel like being more explicit.
128+
In some cases, there might be name collisions with the automatic linking of rule names. In that case, disambiguate with the `grammar-` prefix, such as `[Type][grammar-Type]`. You can also do this if you prefer to be more explicit.
129129

130130
[`mdbook-spec`]: tooling/mdbook-spec.md
131131
[Notation chapter]: https://doc.rust-lang.org/nightly/reference/notation.html

0 commit comments

Comments
 (0)