From 71f33986378cbf01ea33490a095244a28a907f15 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Wed, 20 May 2015 15:22:00 +0800 Subject: (old) BNF update --- bnf/Makefile | 1 + bnf/rust.lex | 1 + bnf/rust.y | 7 ++++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/bnf/Makefile b/bnf/Makefile index 75465648..1bd962d4 100644 --- a/bnf/Makefile +++ b/bnf/Makefile @@ -5,6 +5,7 @@ all: test.bin test: test.bin ../samples/1.rs ./test.bin < ../samples/1.rs +# ./test.bin < ../../../RustPorts/OS/libcore/lib.rs test.bin: rust.tab.c rust.lex.c gcc rust.tab.c rust.lex.c -o $@ diff --git a/bnf/rust.lex b/bnf/rust.lex index dc06d06a..21de6d92 100644 --- a/bnf/rust.lex +++ b/bnf/rust.lex @@ -38,6 +38,7 @@ ident_c [a-zA-Z_] "pub" { return RWD_pub; } "let" { return RWD_let; } +"ref" { return RWD_ref; } "self" { return RWD_self; } "super" { return RWD_super; } diff --git a/bnf/rust.y b/bnf/rust.y index b6202661..81b7aa40 100644 --- a/bnf/rust.y +++ b/bnf/rust.y @@ -6,7 +6,7 @@ %token DOUBLEEQUAL EXCLAMEQUAL DOUBLEPIPE DOUBLEAMP %token DOUBLELT DOUBLEGT %token RWD_mod RWD_fn RWD_const RWD_static RWD_use RWD_struct RWD_enum RWD_trait RWD_impl RWD_type -%token RWD_as RWD_mut RWD_pub RWD_where +%token RWD_as RWD_mut RWD_ref RWD_pub RWD_where %token RWD_let %token RWD_self RWD_super %token RWD_match RWD_if RWD_while RWD_loop RWD_for RWD_else @@ -300,7 +300,12 @@ struct_pattern refutable_pattern : IDENT { /* maybe bind */ } | IDENT '@' nonbind_pattern + | RWD_ref IDENT + | RWD_ref IDENT '@' nonbind_pattern + | RWD_ref RWD_mut IDENT + | RWD_ref RWD_mut IDENT '@' nonbind_pattern | '&' refutable_pattern + | '&' RWD_mut refutable_pattern | nonbind_pattern; nonbind_pattern -- cgit v1.2.3