Skip to content

Commit ded4e9e

Browse files
committed
---
yaml --- r: 210591 b: refs/heads/try c: 5b0e197 h: refs/heads/master i: 210589: 71e3424 210587: a75897f 210583: fd6aa6e 210575: 20d4d2d 210559: a6b45e6 v: v3
1 parent 5931d6c commit ded4e9e

File tree

14 files changed

+129
-167
lines changed

14 files changed

+129
-167
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 3e561f05c00cd180ec02db4ccab2840a4aba93d2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
5-
refs/heads/try: f697041b37e8c9c86dfe463262501ad61dd2d4a3
5+
refs/heads/try: 5b0e19794efe6d2d7f225df57505205627103f32
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/doc/grammar.md

Lines changed: 66 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ The two values of the boolean type are written `true` and `false`.
253253
### Symbols
254254

255255
```antlr
256-
symbol : "::" | "->"
256+
symbol : "::" "->"
257257
| '#' | '[' | ']' | '(' | ')' | '{' | '}'
258258
| ',' | ';' ;
259259
```
@@ -304,7 +304,7 @@ transcriber : '(' transcriber * ')' | '[' transcriber * ']'
304304
## Items
305305

306306
```antlr
307-
item : vis ? mod_item | fn_item | type_item | struct_item | enum_item
307+
item : mod_item | fn_item | type_item | struct_item | enum_item
308308
| const_item | static_item | trait_item | impl_item | extern_block ;
309309
```
310310

@@ -322,7 +322,7 @@ mod : [ view_item | item ] * ;
322322
#### View items
323323

324324
```antlr
325-
view_item : extern_crate_decl | use_decl ';' ;
325+
view_item : extern_crate_decl | use_decl ;
326326
```
327327

328328
##### Extern crate declarations
@@ -335,14 +335,14 @@ crate_name: ident | ( ident "as" ident )
335335
##### Use declarations
336336

337337
```antlr
338-
use_decl : vis ? "use" [ path "as" ident
339-
| path_glob ] ;
338+
use_decl : "pub" ? "use" [ path "as" ident
339+
| path_glob ] ;
340340
341341
path_glob : ident [ "::" [ path_glob
342342
| '*' ] ] ?
343343
| '{' path_item [ ',' path_item ] * '}' ;
344344
345-
path_item : ident | "self" ;
345+
path_item : ident | "mod" ;
346346
```
347347

348348
### Functions
@@ -414,17 +414,16 @@ extern_block : [ foreign_fn ] * ;
414414

415415
## Visibility and Privacy
416416

417-
```antlr
418-
vis : "pub" ;
419-
```
417+
**FIXME:** grammar?
418+
420419
### Re-exporting and Visibility
421420

422-
See [Use declarations](#use-declarations).
421+
**FIXME:** grammar?
423422

424423
## Attributes
425424

426425
```antlr
427-
attribute : '#' '!' ? '[' meta_item ']' ;
426+
attribute : "#!" ? '[' meta_item ']' ;
428427
meta_item : ident [ '=' literal
429428
| '(' meta_seq ')' ] ? ;
430429
meta_seq : meta_item [ ',' meta_seq ] ? ;
@@ -434,19 +433,26 @@ meta_seq : meta_item [ ',' meta_seq ] ? ;
434433

435434
## Statements
436435

437-
```antlr
438-
stmt : decl_stmt | expr_stmt ;
439-
```
436+
**FIXME:** grammar?
440437

441438
### Declaration statements
442439

443-
```antlr
444-
decl_stmt : item | let_decl ;
445-
```
440+
**FIXME:** grammar?
441+
442+
A _declaration statement_ is one that introduces one or more *names* into the
443+
enclosing statement block. The declared names may denote new variables or new
444+
items.
446445

447446
#### Item declarations
448447

449-
See [Items](#items).
448+
**FIXME:** grammar?
449+
450+
An _item declaration statement_ has a syntactic form identical to an
451+
[item](#items) declaration within a module. Declaring an item — a
452+
function, enumeration, structure, type, static, trait, implementation or module
453+
— locally within a statement block is simply a way of restricting its
454+
scope to a narrow region containing all of its uses; it is otherwise identical
455+
in meaning to declaring the item outside the statement block.
450456

451457
#### Variable declarations
452458

@@ -457,21 +463,11 @@ init : [ '=' ] expr ;
457463

458464
### Expression statements
459465

460-
```antlr
461-
expr_stmt : expr ';' ;
462-
```
466+
**FIXME:** grammar?
463467

464468
## Expressions
465469

466-
```antlr
467-
expr : literal | path | tuple_expr | unit_expr | struct_expr
468-
| block_expr | method_call_expr | field_expr | array_expr
469-
| idx_expr | range_expr | unop_expr | binop_expr
470-
| paren_expr | call_expr | lambda_expr | while_expr
471-
| loop_expr | break_expr | continue_expr | for_expr
472-
| if_expr | match_expr | if_let_expr | while_let_expr
473-
| return_expr ;
474-
```
470+
**FIXME:** grammar?
475471

476472
#### Lvalues, rvalues and temporaries
477473

@@ -483,23 +479,19 @@ expr : literal | path | tuple_expr | unit_expr | struct_expr
483479

484480
### Literal expressions
485481

486-
See [Literals](#literals).
482+
**FIXME:** grammar?
487483

488484
### Path expressions
489485

490-
See [Paths](#paths).
486+
**FIXME:** grammar?
491487

492488
### Tuple expressions
493489

494-
```antlr
495-
tuple_expr : '(' [ expr [ ',' expr ] * | expr ',' ] ? ')' ;
496-
```
490+
**FIXME:** grammar?
497491

498492
### Unit expressions
499493

500-
```antlr
501-
unit_expr : "()" ;
502-
```
494+
**FIXME:** grammar?
503495

504496
### Structure expressions
505497

@@ -515,7 +507,8 @@ struct_expr : expr_path '{' ident ':' expr
515507
### Block expressions
516508

517509
```antlr
518-
block_expr : '{' [ stmt ';' | item ] *
510+
block_expr : '{' [ view_item ] *
511+
[ stmt ';' | item ] *
519512
[ expr ] '}' ;
520513
```
521514

@@ -536,7 +529,7 @@ field_expr : expr '.' ident ;
536529
```antlr
537530
array_expr : '[' "mut" ? array_elems? ']' ;
538531
539-
array_elems : [expr [',' expr]*] | [expr ';' expr] ;
532+
array_elems : [expr [',' expr]*] | [expr ',' ".." expr] ;
540533
```
541534

542535
### Index expressions
@@ -556,60 +549,65 @@ range_expr : expr ".." expr |
556549

557550
### Unary operator expressions
558551

559-
```antlr
560-
unop_expr : unop expr ;
561-
unop : '-' | '*' | '!' ;
562-
```
552+
**FIXME:** grammar?
563553

564554
### Binary operator expressions
565555

566556
```antlr
567-
binop_expr : expr binop expr | type_cast_expr
568-
| assignment_expr | compound_assignment_expr ;
569-
binop : arith_op | bitwise_op | lazy_bool_op | comp_op
557+
binop_expr : expr binop expr ;
570558
```
571559

572560
#### Arithmetic operators
573561

574-
```antlr
575-
arith_op : '+' | '-' | '*' | '/' | '%' ;
576-
```
562+
**FIXME:** grammar?
577563

578564
#### Bitwise operators
579565

580-
```antlr
581-
bitwise_op : '&' | '|' | '^' | "<<" | ">>" ;
582-
```
566+
**FIXME:** grammar?
583567

584568
#### Lazy boolean operators
585569

586-
```antlr
587-
lazy_bool_op : "&&" | "||" ;
588-
```
570+
**FIXME:** grammar?
589571

590572
#### Comparison operators
591573

592-
```antlr
593-
comp_op : "==" | "!=" | '<' | '>' | "<=" | ">=" ;
594-
```
574+
**FIXME:** grammar?
595575

596576
#### Type cast expressions
597577

598-
```antlr
599-
type_cast_expr : value "as" type ;
600-
```
578+
**FIXME:** grammar?
601579

602580
#### Assignment expressions
603581

604-
```antlr
605-
assignment_expr : expr '=' expr ;
606-
```
582+
**FIXME:** grammar?
607583

608584
#### Compound assignment expressions
609585

610-
```antlr
611-
compound_assignment_expr : expr [ arith_op | bitwise_op ] '=' expr ;
612-
```
586+
**FIXME:** grammar?
587+
588+
#### Operator precedence
589+
590+
The precedence of Rust binary operators is ordered as follows, going from
591+
strong to weak:
592+
593+
```text
594+
* / %
595+
as
596+
+ -
597+
<< >>
598+
&
599+
^
600+
|
601+
< > <= >=
602+
== !=
603+
&&
604+
||
605+
=
606+
```
607+
608+
Operators at the same precedence level are evaluated left-to-right. [Unary
609+
operators](#unary-operator-expressions) have the same precedence level and it
610+
is stronger than any of the binary operators'.
613611

614612
### Grouped expressions
615613

branches/try/src/doc/reference.md

Lines changed: 17 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -653,10 +653,9 @@ There are several kinds of item:
653653
* [`use` declarations](#use-declarations)
654654
* [modules](#modules)
655655
* [functions](#functions)
656-
* [type aliases](#type-aliases)
656+
* [type definitions](#type-definitions)
657657
* [structures](#structures)
658658
* [enumerations](#enumerations)
659-
* [constant items](#constant-items)
660659
* [static items](#static-items)
661660
* [traits](#traits)
662661
* [implementations](#implementations)
@@ -673,16 +672,16 @@ which sub-item declarations may appear.
673672

674673
### Type Parameters
675674

676-
All items except modules, constants and statics may be *parameterized* by type.
677-
Type parameters are given as a comma-separated list of identifiers enclosed in
678-
angle brackets (`<...>`), after the name of the item and before its definition.
679-
The type parameters of an item are considered "part of the name", not part of
680-
the type of the item. A referencing [path](#paths) must (in principle) provide
681-
type arguments as a list of comma-separated types enclosed within angle
682-
brackets, in order to refer to the type-parameterized item. In practice, the
683-
type-inference system can usually infer such argument types from context. There
684-
are no general type-parametric types, only type-parametric items. That is, Rust
685-
has no notion of type abstraction: there are no first-class "forall" types.
675+
All items except modules may be *parameterized* by type. Type parameters are
676+
given as a comma-separated list of identifiers enclosed in angle brackets
677+
(`<...>`), after the name of the item and before its definition. The type
678+
parameters of an item are considered "part of the name", not part of the type
679+
of the item. A referencing [path](#paths) must (in principle) provide type
680+
arguments as a list of comma-separated types enclosed within angle brackets, in
681+
order to refer to the type-parameterized item. In practice, the type-inference
682+
system can usually infer such argument types from context. There are no
683+
general type-parametric types, only type-parametric items. That is, Rust has
684+
no notion of type abstraction: there are no first-class "forall" types.
686685

687686
### Modules
688687

@@ -744,7 +743,7 @@ mod thread {
744743
}
745744
```
746745

747-
#### Extern crate declarations
746+
##### Extern crate declarations
748747

749748
An _`extern crate` declaration_ specifies a dependency on an external crate.
750749
The external crate is then bound into the declaring scope as the `ident`
@@ -768,7 +767,7 @@ extern crate std; // equivalent to: extern crate std as std;
768767
extern crate std as ruststd; // linking to 'std' under another name
769768
```
770769

771-
#### Use declarations
770+
##### Use declarations
772771

773772
A _use declaration_ creates one or more local name bindings synonymous with
774773
some other [path](#paths). Usually a `use` declaration is used to shorten the
@@ -843,7 +842,7 @@ module declarations should be at the crate root if direct usage of the declared
843842
modules within `use` items is desired. It is also possible to use `self` and
844843
`super` at the beginning of a `use` item to refer to the current and direct
845844
parent modules respectively. All rules regarding accessing declared modules in
846-
`use` declarations apply to both module declarations and `extern crate`
845+
`use` declarations applies to both module declarations and `extern crate`
847846
declarations.
848847

849848
An example of what will and will not work for `use` items:
@@ -2565,19 +2564,12 @@ array is mutable, the resulting [lvalue](#lvalues,-rvalues-and-temporaries) can
25652564
be assigned to.
25662565

25672566
Indices are zero-based, and may be of any integral type. Vector access is
2568-
bounds-checked at compile-time for constant arrays being accessed with a constant index value.
2569-
Otherwise a check will be performed at run-time that will put the thread in a _panicked state_ if it fails.
2567+
bounds-checked at run-time. When the check fails, it will put the thread in a
2568+
_panicked state_.
25702569

25712570
```{should-fail}
25722571
([1, 2, 3, 4])[0];
2573-
2574-
let x = (["a", "b"])[10]; // compiler error: const index-expr is out of bounds
2575-
2576-
let n = 10;
2577-
let y = (["a", "b"])[n]; // panics
2578-
2579-
let arr = ["a", "b"];
2580-
arr[10]; // panics
2572+
(["a", "b"])[10]; // panics
25812573
```
25822574

25832575
### Range expressions
@@ -3072,20 +3064,6 @@ of a condition expression it expects a refutable let statement. If the value of
30723064
expression on the right hand side of the let statement matches the pattern, the corresponding
30733065
block will execute, otherwise flow proceeds to the first `else` block that follows.
30743066

3075-
```
3076-
let dish = ("Ham", "Eggs");
3077-
3078-
// this body will be skipped because the pattern is refuted
3079-
if let ("Bacon", b) = dish {
3080-
println!("Bacon is served with {}", b);
3081-
}
3082-
3083-
// this body will execute
3084-
if let ("Ham", b) = dish {
3085-
println!("Ham is served with {}", b);
3086-
}
3087-
```
3088-
30893067
### While let loops
30903068

30913069
A `while let` loop is semantically identical to a `while` loop but in place of a

branches/try/src/doc/trpl/guessing-game.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ information’. Why throw it away? Well, for a basic program, we just want to
273273
print a generic error, as basically any issue means we can’t continue. The
274274
[`ok()` method][ok] returns a value which has another method defined on it:
275275
`expect()`. The [`expect()` method][expect] takes a value it’s called on, and
276-
if it isn’t a successful one, [`panic!`][panic]s with a message you
276+
if it isn’t a successful one, [`panic!`][panic]s with a message you passed you
277277
passed it. A `panic!` like this will cause our program to crash, displaying
278278
the message.
279279

0 commit comments

Comments
 (0)