From d71540973618a545bc0ea98506285e1bad7bd2bb Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Mon, 27 Apr 2015 22:02:16 -0400 Subject: [PATCH 1/3] Make item sections match item EBNF `enum_item` appeared in the `item` list but did not have an associated section; `const_item` had a section but did not appear in the list. --- src/doc/grammar.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/doc/grammar.md b/src/doc/grammar.md index cceab31c61db1..4b6790c763b9c 100644 --- a/src/doc/grammar.md +++ b/src/doc/grammar.md @@ -297,7 +297,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 +369,10 @@ path_item : ident | "mod" ; **FIXME:** grammar? +### Enumerations + +**FIXME:** grammar? + ### Constant items ```antlr From 3e521bfd96597d89dc2f0e8026caf8beee8959d9 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Tue, 28 Apr 2015 21:09:28 -0400 Subject: [PATCH 2/3] Add boolean literal to the grammar To make this rule match the definition of Lit_ in https://github.com/rust-lang/rust/blob/master/src/libsyntax/ast.rs --- src/doc/grammar.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/doc/grammar.md b/src/doc/grammar.md index 4b6790c763b9c..ad4c0c1711baf 100644 --- a/src/doc/grammar.md +++ b/src/doc/grammar.md @@ -176,7 +176,7 @@ 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 ?; ``` #### Character and string literals @@ -238,7 +238,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`. From 0ddee94cfeec045d23be3ce98d06b2f3f774a134 Mon Sep 17 00:00:00 2001 From: Carol Nichols Date: Tue, 28 Apr 2015 22:02:53 -0400 Subject: [PATCH 3/3] Move explanation that references lexical grammar to the grammar Reword so that the references to things above/below are up to date and a bit more specific. --- src/doc/grammar.md | 6 ++++++ src/doc/reference.md | 5 ----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/doc/grammar.md b/src/doc/grammar.md index ad4c0c1711baf..80a4b63cc5f79 100644 --- a/src/doc/grammar.md +++ b/src/doc/grammar.md @@ -179,6 +179,12 @@ lit_suffix : ident; 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 diff --git a/src/doc/reference.md b/src/doc/reference.md index a71f8cf4250a6..474e09b2c413f 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -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