]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #24924 - carols10cents:grammar-improvements, r=pnkfelix
authorbors <bors@rust-lang.org>
Thu, 30 Apr 2015 17:07:14 +0000 (17:07 +0000)
committerbors <bors@rust-lang.org>
Thu, 30 Apr 2015 17:07:14 +0000 (17:07 +0000)
I'm interested in helping out with #16676 but more in the grammar than the reference-- here's my first chunk, more to come!! :tada:

I did pull a bit *out* of the reference, though, that was more relevant to the grammar but wasn't moved over as part of #24729.

I'm looking at, e.g. https://github.com/rust-lang/rust/blob/master/src/libsyntax/ast.rs, as the source of truth, please let me know if I should be checking against something else instead/in addition.

r? @steveklabnik

src/doc/grammar.md
src/doc/reference.md

index cceab31c61db1da60b0887face14d1492b33e557..80a4b63cc5f7965cae166534add0100c33b1b159 100644 (file)
@@ -176,9 +176,15 @@ excluded from the `ident` rule.
 
 ```antlr
 lit_suffix : ident;
-literal : [ string_lit | char_lit | byte_string_lit | byte_lit | num_lit ] lit_suffix ?;
+literal : [ string_lit | char_lit | byte_string_lit | byte_lit | num_lit | bool_lit ] lit_suffix ?;
 ```
 
+The optional `lit_suffix` production is only used for certain numeric literals,
+but is reserved for future extension. That is, the above gives the lexical
+grammar, but a Rust parser will reject everything but the 12 special cases
+mentioned in [Number literals](reference.html#number-literals) in the
+reference.
+
 #### Character and string literals
 
 ```antlr
@@ -238,7 +244,9 @@ dec_lit : [ dec_digit | '_' ] + ;
 
 #### Boolean literals
 
-**FIXME:** write grammar
+```antlr
+bool_lit : [ "true" | "false" ] ;
+```
 
 The two values of the boolean type are written `true` and `false`.
 
@@ -297,7 +305,7 @@ transcriber : '(' transcriber * ')' | '[' transcriber * ']'
 
 ```antlr
 item : mod_item | fn_item | type_item | struct_item | enum_item
-     | static_item | trait_item | impl_item | extern_block ;
+     | const_item | static_item | trait_item | impl_item | extern_block ;
 ```
 
 ### Type Parameters
@@ -369,6 +377,10 @@ path_item : ident | "mod" ;
 
 **FIXME:** grammar?
 
+### Enumerations
+
+**FIXME:** grammar?
+
 ### Constant items
 
 ```antlr
index 19cbd6f90a58146402abf38283d285cac38cae85..4485704c3d523b83983904ecd5721d372593c829 100644 (file)
@@ -130,11 +130,6 @@ of tokens, that immediately and directly denotes the value it evaluates to,
 rather than referring to it by name or some other evaluation rule. A literal is
 a form of constant expression, so is evaluated (primarily) at compile time.
 
-The optional suffix is only used for certain numeric literals, but is
-reserved for future extension, that is, the above gives the lexical
-grammar, but a Rust parser will reject everything but the 12 special
-cases mentioned in [Number literals](#number-literals) below.
-
 #### Examples
 
 ##### Characters and strings