@@ -253,7 +253,7 @@ The two values of the boolean type are written `true` and `false`.
253
253
### Symbols
254
254
255
255
``` antlr
256
- symbol : "::" | "->"
256
+ symbol : "::" "->"
257
257
| '#' | '[' | ']' | '(' | ')' | '{' | '}'
258
258
| ',' | ';' ;
259
259
```
@@ -304,7 +304,7 @@ transcriber : '(' transcriber * ')' | '[' transcriber * ']'
304
304
## Items
305
305
306
306
``` 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
308
308
| const_item | static_item | trait_item | impl_item | extern_block ;
309
309
```
310
310
@@ -322,7 +322,7 @@ mod : [ view_item | item ] * ;
322
322
#### View items
323
323
324
324
``` antlr
325
- view_item : extern_crate_decl | use_decl ';' ;
325
+ view_item : extern_crate_decl | use_decl ;
326
326
```
327
327
328
328
##### Extern crate declarations
@@ -335,14 +335,14 @@ crate_name: ident | ( ident "as" ident )
335
335
##### Use declarations
336
336
337
337
``` antlr
338
- use_decl : vis ? "use" [ path "as" ident
339
- | path_glob ] ;
338
+ use_decl : "pub" ? "use" [ path "as" ident
339
+ | path_glob ] ;
340
340
341
341
path_glob : ident [ "::" [ path_glob
342
342
| '*' ] ] ?
343
343
| '{' path_item [ ',' path_item ] * '}' ;
344
344
345
- path_item : ident | "self " ;
345
+ path_item : ident | "mod " ;
346
346
```
347
347
348
348
### Functions
@@ -414,17 +414,16 @@ extern_block : [ foreign_fn ] * ;
414
414
415
415
## Visibility and Privacy
416
416
417
- ``` antlr
418
- vis : "pub" ;
419
- ```
417
+ ** FIXME:** grammar?
418
+
420
419
### Re-exporting and Visibility
421
420
422
- See [ Use declarations ] ( #use-declarations ) .
421
+ ** FIXME: ** grammar?
423
422
424
423
## Attributes
425
424
426
425
``` antlr
427
- attribute : '#' '!' ? '[' meta_item ']' ;
426
+ attribute : "#!" ? '[' meta_item ']' ;
428
427
meta_item : ident [ '=' literal
429
428
| '(' meta_seq ')' ] ? ;
430
429
meta_seq : meta_item [ ',' meta_seq ] ? ;
@@ -434,19 +433,26 @@ meta_seq : meta_item [ ',' meta_seq ] ? ;
434
433
435
434
## Statements
436
435
437
- ``` antlr
438
- stmt : decl_stmt | expr_stmt ;
439
- ```
436
+ ** FIXME:** grammar?
440
437
441
438
### Declaration statements
442
439
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.
446
445
447
446
#### Item declarations
448
447
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 &mdash ; a
452
+ function, enumeration, structure, type, static, trait, implementation or module
453
+ &mdash ; 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.
450
456
451
457
#### Variable declarations
452
458
@@ -457,21 +463,11 @@ init : [ '=' ] expr ;
457
463
458
464
### Expression statements
459
465
460
- ``` antlr
461
- expr_stmt : expr ';' ;
462
- ```
466
+ ** FIXME:** grammar?
463
467
464
468
## Expressions
465
469
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?
475
471
476
472
#### Lvalues, rvalues and temporaries
477
473
@@ -483,23 +479,19 @@ expr : literal | path | tuple_expr | unit_expr | struct_expr
483
479
484
480
### Literal expressions
485
481
486
- See [ Literals ] ( #literals ) .
482
+ ** FIXME: ** grammar?
487
483
488
484
### Path expressions
489
485
490
- See [ Paths ] ( #paths ) .
486
+ ** FIXME: ** grammar?
491
487
492
488
### Tuple expressions
493
489
494
- ``` antlr
495
- tuple_expr : '(' [ expr [ ',' expr ] * | expr ',' ] ? ')' ;
496
- ```
490
+ ** FIXME:** grammar?
497
491
498
492
### Unit expressions
499
493
500
- ``` antlr
501
- unit_expr : "()" ;
502
- ```
494
+ ** FIXME:** grammar?
503
495
504
496
### Structure expressions
505
497
@@ -515,7 +507,8 @@ struct_expr : expr_path '{' ident ':' expr
515
507
### Block expressions
516
508
517
509
``` antlr
518
- block_expr : '{' [ stmt ';' | item ] *
510
+ block_expr : '{' [ view_item ] *
511
+ [ stmt ';' | item ] *
519
512
[ expr ] '}' ;
520
513
```
521
514
@@ -536,7 +529,7 @@ field_expr : expr '.' ident ;
536
529
``` antlr
537
530
array_expr : '[' "mut" ? array_elems? ']' ;
538
531
539
- array_elems : [expr [',' expr]*] | [expr ';' expr] ;
532
+ array_elems : [expr [',' expr]*] | [expr ',' ".." expr] ;
540
533
```
541
534
542
535
### Index expressions
@@ -556,60 +549,65 @@ range_expr : expr ".." expr |
556
549
557
550
### Unary operator expressions
558
551
559
- ``` antlr
560
- unop_expr : unop expr ;
561
- unop : '-' | '*' | '!' ;
562
- ```
552
+ ** FIXME:** grammar?
563
553
564
554
### Binary operator expressions
565
555
566
556
``` 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 ;
570
558
```
571
559
572
560
#### Arithmetic operators
573
561
574
- ``` antlr
575
- arith_op : '+' | '-' | '*' | '/' | '%' ;
576
- ```
562
+ ** FIXME:** grammar?
577
563
578
564
#### Bitwise operators
579
565
580
- ``` antlr
581
- bitwise_op : '&' | '|' | '^' | "<<" | ">>" ;
582
- ```
566
+ ** FIXME:** grammar?
583
567
584
568
#### Lazy boolean operators
585
569
586
- ``` antlr
587
- lazy_bool_op : "&&" | "||" ;
588
- ```
570
+ ** FIXME:** grammar?
589
571
590
572
#### Comparison operators
591
573
592
- ``` antlr
593
- comp_op : "==" | "!=" | '<' | '>' | "<=" | ">=" ;
594
- ```
574
+ ** FIXME:** grammar?
595
575
596
576
#### Type cast expressions
597
577
598
- ``` antlr
599
- type_cast_expr : value "as" type ;
600
- ```
578
+ ** FIXME:** grammar?
601
579
602
580
#### Assignment expressions
603
581
604
- ``` antlr
605
- assignment_expr : expr '=' expr ;
606
- ```
582
+ ** FIXME:** grammar?
607
583
608
584
#### Compound assignment expressions
609
585
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'.
613
611
614
612
### Grouped expressions
615
613
0 commit comments