summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2015-04-15 17:07:51 +0800
committerJohn Hodge <tpg@mutabah.net>2015-04-15 17:07:51 +0800
commitd0e38eff804b9f085bf8a3f0a3db4805fde72e05 (patch)
tree4d91e55edb4ecc8476259e2d10a2132bad95291e
parent1b62d9688a1be2da2825c59e73f3220b0dc352fa (diff)
downloadmrust-d0e38eff804b9f085bf8a3f0a3db4805fde72e05.tar.gz
BNF - Successfully parses test crate
-rw-r--r--bnf/rust.lex2
-rw-r--r--bnf/rust.y32
-rw-r--r--samples/1.rs2
3 files changed, 31 insertions, 5 deletions
diff --git a/bnf/rust.lex b/bnf/rust.lex
index b79119cd..dc06d06a 100644
--- a/bnf/rust.lex
+++ b/bnf/rust.lex
@@ -53,6 +53,7 @@ ident_c [a-zA-Z_]
"->" { return THINARROW; }
"=>" { return FATARROW; }
"#![" { return SUPER_ATTR; }
+"#[" { return SUB_ATTR; }
"==" { return DOUBLEEQUAL; }
"!=" { return EXCLAMEQUAL; }
@@ -71,6 +72,7 @@ ident_c [a-zA-Z_]
"=" { return *yytext; }
"{"|"}" { return *yytext; }
"("|")" { return *yytext; }
+"["|"]" { return *yytext; }
"<" { return *yytext; }
">" { return *yytext; }
"," { return *yytext; }
diff --git a/bnf/rust.y b/bnf/rust.y
index 1870b245..b6202661 100644
--- a/bnf/rust.y
+++ b/bnf/rust.y
@@ -240,6 +240,10 @@ expr_path_segs
| IDENT DOUBLECOLON expr_path_segs
| IDENT
;
+expr_path_seg
+ : IDENT DOUBLECOLON '<' type_exprs '>'
+ | IDENT
+ ;
type_path
: ufcs_path DOUBLECOLON IDENT
@@ -384,11 +388,31 @@ expr_9
expr_cast: expr_11 | expr_cast RWD_as type { bnf_trace("expr:cast"); };
/* 11: Times/Div/Modulo */
expr_11
+ : expr_11n
+ | expr_11 '*' expr_11n {}
+ | expr_11 '/' expr_11n {}
+ | expr_11 '%' expr_11n {}
+ ;
+expr_11n: expr_12;
+expr_12
+ : expr_fc
+ | '-' expr_12
+ | '-' expr_12
+ | '*' expr_12
+/* | RWD_box expr_12 */
+ | '&' expr_12
+ | '&' RWD_mut expr_12
+ | DOUBLEAMP expr_12 { }
+ | DOUBLEAMP RWD_mut expr_12 { }
+ ;
+
+expr_fc
: expr_value
- | expr_11 '*' expr_value {}
- | expr_11 '/' expr_value {}
- | expr_11 '%' expr_value {}
- ;
+ | expr_fc '(' ')'
+ | expr_fc '[' expr ']'
+ | expr_fc '.' INTEGER
+ | expr_fc '.' expr_path_seg '(' ')'
+ | expr_fc '.' expr_path_seg
expr_value
: CHARLIT | INTEGER | FLOAT | STRING
diff --git a/samples/1.rs b/samples/1.rs
index 05e91240..6bc434cb 100644
--- a/samples/1.rs
+++ b/samples/1.rs
@@ -101,7 +101,7 @@ impl<T:Reader> UTF8Reader<T>
/// Implmentation of the same interface as 'Chars' provides, returns None at the end of the stream
impl<T:Reader> Iterator for UTF8Reader<T>
{
- type Item = IoResult<char>;
+ type Item = IoResult<char>;
fn next(&mut self) -> Option<IoResult<char>>
{
// Get result from decoder