Skip to content

Commit 454401c

Browse files
Merge pull request #465 from ehuss/remove-old-grammar
Remove the last remnants of the old grammar.
2 parents cd192bf + a2405b9 commit 454401c

File tree

5 files changed

+40
-26
lines changed

5 files changed

+40
-26
lines changed

src/crates-and-source-files.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
1010
> **<sup>Lexer</sup>**\
1111
> UTF8BOM : `\uFEFF`\
12-
> SHEBANG : `#!` ~[`[` `\n`] ~`\n`<sup>*</sup>
12+
> SHEBANG : `#!` ~[`[` `\n`] ~`\n`<sup>\*</sup>
1313
1414

1515
> Note: Although Rust, like any other language, can be implemented by an
@@ -42,12 +42,12 @@ extension `.rs`.
4242

4343
A Rust source file describes a module, the name and location of which &mdash;
4444
in the module tree of the current crate &mdash; are defined from outside the
45-
source file: either by an explicit [`mod` item][module] in a referencing
45+
source file: either by an explicit [_Module_][module] item in a referencing
4646
source file, or by the name of the crate itself. Every source file is a
4747
module, but not every module needs its own source file: [module
4848
definitions][module] can be nested within one file.
4949

50-
Each source file contains a sequence of zero or more `item` definitions, and
50+
Each source file contains a sequence of zero or more [_Item_] definitions, and
5151
may optionally begin with any number of [attributes]
5252
that apply to the containing module, most of which influence the behavior of
5353
the compiler. The anonymous crate module can have additional attributes that

src/expressions/closure-expr.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@
33
> **<sup>Syntax</sup>**\
44
> _ClosureExpression_ :\
55
> &nbsp;&nbsp; `move`<sup>?</sup>\
6-
> &nbsp;&nbsp; ( `||` | `|` [_FunctionParameters_]<sup>?</sup> `|` )\
6+
> &nbsp;&nbsp; ( `||` | `|` _ClosureParameters_<sup>?</sup> `|` )\
77
> &nbsp;&nbsp; ([_Expression_] | `->` [_TypeNoBounds_]&nbsp;[_BlockExpression_])
8+
>
9+
> _ClosureParameters_ :\
10+
> &nbsp;&nbsp; _ClosureParam_ (`,` _ClosureParam_)<sup>\*</sup> `,`<sup>?</sup>
11+
>
12+
> _ClosureParam_ :\
13+
> &nbsp;&nbsp; [_Pattern_]&nbsp;( `:` [_Type_] )<sup>?</sup>
814
915
A _closure expression_ defines a closure and denotes it as a value, in a single
1016
expression. A closure expression is a pipe-symbol-delimited (`|`) list of
@@ -14,11 +20,11 @@ type, the expression used for the body of the closure must be a normal
1420
[block]. A closure expression also may begin with the
1521
`move` keyword before the initial `|`.
1622

17-
A closure expression denotes a function that maps a list of parameters
18-
(`ident_list`) onto the expression that follows the `ident_list`. The patterns
19-
in the `ident_list` are the parameters to the closure. If a parameter's types
20-
is not specified, then the compiler infers it from context. Each closure
21-
expression has a unique anonymous type.
23+
A closure expression denotes a function that maps a list of parameters onto
24+
the expression that follows the parameters. Just like a [`let` binding], the
25+
parameters are irrefutable [patterns], whose type annotation is optional and
26+
will be inferred from context if not given. Each closure expression has a
27+
unique, anonymous type.
2228

2329
Closure expressions are most useful when passing functions as arguments to other
2430
functions, as an abbreviation for defining and capturing a separate function.
@@ -69,3 +75,6 @@ ten_times(move |j| println!("{}, {}", word, j));
6975
[_BlockExpression_]: expressions/block-expr.html
7076
[_TypeNoBounds_]: types.html#type-expressions
7177
[_FunctionParameters_]: items/functions.html
78+
[_Pattern_]: patterns.html
79+
[_Type_]: types.html#type-expressions
80+
[`let` binding]: statements.html#let-statements

src/input-format.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
11
# Input format
22

33
Rust input is interpreted as a sequence of Unicode code points encoded in UTF-8.
4-
Most Rust grammar rules are defined in terms of printable ASCII-range
5-
code points, but a small number are defined in terms of Unicode properties or
6-
explicit code point lists. [^inputformat]
7-
8-
[^inputformat]: Substitute definitions for the special Unicode productions are
9-
provided to the grammar verifier, restricted to ASCII range, when verifying the
10-
grammar in this document.

src/introduction.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ provides three kinds of material:
99
- Appendix chapters providing rationale and references to languages that
1010
influenced the design.
1111

12-
> **Note**: You may also be interested in the [grammar].
13-
1412
<div class="warning">
1513

1614
Warning: This book is incomplete. Documenting everything takes a while. See
@@ -120,6 +118,8 @@ information. These conventions are documented here.
120118
> &nbsp;&nbsp; &nbsp;&nbsp; `~` [_Expression_]\
121119
> &nbsp;&nbsp; | `box` [_Expression_]
122120
121+
See [Notation] for more detail.
122+
123123
## Contributing
124124

125125
We welcome contributions of all kinds.
@@ -133,7 +133,6 @@ attention to making those sections the best that they can be.
133133

134134
[book]: ../book/index.html
135135
[standard library]: ../std/index.html
136-
[grammar]: ../grammar.html
137136
[the Rust Reference repository]: https://github.com/rust-lang-nursery/reference/
138137
[big issue]: https://github.com/rust-lang-nursery/reference/issues/9
139138
[Unstable Book]: https://doc.rust-lang.org/nightly/unstable-book/
@@ -145,3 +144,4 @@ attention to making those sections the best that they can be.
145144
[linkage]: linkage.html
146145
[rustc book]: ../rustc/index.html
147146
[undocumented]: undocumented.html
147+
[Notation]: notation.html

src/notation.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
# Notation
22

3-
## Unicode productions
3+
## Grammar
44

5-
A few productions in Rust's grammar permit Unicode code points outside the
6-
ASCII range. We define these productions in terms of character properties
7-
specified in the Unicode standard, rather than in terms of ASCII-range code
8-
points. The grammar has a [Special Unicode Productions] section that lists these
9-
productions.
5+
The following notations are used by the *Lexer* and *Syntax* grammar snippets:
6+
7+
| Notation | Examples | Meaning |
8+
|-------------------|-------------------------------|-------------------------------------------|
9+
| CAPITAL | KW_IF, INTEGER_LITERAL | A token produced by the lexer |
10+
| _ItalicCamelCase_ | _LetStatement_, _Item_ | A syntactical production |
11+
| `string` | `x`, `while`, `*` | The exact character(s) |
12+
| \\x | \\n, \\r, \\t, \\0 | The character represented by this escape |
13+
| x<sup>?</sup> | `pub`<sup>?</sup> | An optional item |
14+
| x<sup>\*</sup> | _OuterAttribute_<sup>\*</sup> | 0 or more of x |
15+
| x<sup>+</sup> | _MacroMatch_<sup>+</sup> | 1 or more of x |
16+
| x<sup>a..b</sup> | HEX_DIGIT<sup>1..6</sup> | a to b repetitions of x |
17+
| \| | `u8` \| `u16`, Block \| Item | Either one or another |
18+
| [ ] | [`b` `B`] | Any of the characters listed |
19+
| [ - ] | [`a`-`z`] | Any of the characters in the range |
20+
| ~[ ] | ~[`b` `B`] | Any characters, except those listed |
21+
| ~`string` | ~`\n`, ~`*/` | Any characters, except this sequence |
22+
| ( ) | (`,` _Parameter_)<sup>?</sup> | Groups items |
1023

1124
## String table productions
1225

@@ -22,7 +35,6 @@ When such a string in `monospace` font occurs inside the grammar,
2235
it is an implicit reference to a single member of such a string table
2336
production. See [tokens] for more information.
2437

25-
[Special Unicode Productions]: ../grammar.html#special-unicode-productions
2638
[binary operators]: expressions/operator-expr.html#arithmetic-and-logical-binary-operators
2739
[keywords]: keywords.html
2840
[tokens]: tokens.html

0 commit comments

Comments
 (0)