summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2015-09-23 13:36:00 +0800
committerJohn Hodge <tpg@mutabah.net>2015-09-23 13:36:00 +0800
commit6559c120c129cfd6418eaeb08ba3ecf0e1ebea91 (patch)
tree58433028aad025d411f6eed207a6c684648560a1
parentfd0c758bcc492f5b25550e7d4a5d67dc90eeba6a (diff)
downloadmrust-6559c120c129cfd6418eaeb08ba3ecf0e1ebea91.tar.gz
Now parses all of str/mod.rs
-rw-r--r--bnf/Makefile1
-rw-r--r--bnf/rust.lex2
-rw-r--r--bnf/rust.y5
3 files changed, 5 insertions, 3 deletions
diff --git a/bnf/Makefile b/bnf/Makefile
index 806ba272..57199bef 100644
--- a/bnf/Makefile
+++ b/bnf/Makefile
@@ -6,6 +6,7 @@ all: test.bin
TSTFILE := ../samples/1.rs
TSTFILE := ../../rust_os/libcore/lib.rs
TSTFILE := ../../rust_os/libcore/str/mod.rs
+TSTFILE := ../../rust_os/libcore/str/pattern.rs
test: test.bin $(TSTFILE)
./test.bin < $(TSTFILE)
diff --git a/bnf/rust.lex b/bnf/rust.lex
index 658fb8ee..cb45b9bb 100644
--- a/bnf/rust.lex
+++ b/bnf/rust.lex
@@ -121,7 +121,7 @@ ident_c [a-zA-Z_]
0x[0-9a-fA-F]* { yylval.integer = strtoull(yytext, NULL, 0); return INTEGER; }
b?'(.|\\['rn])' { yylval.text = strdup(yytext); return CHARLIT; }
-\"([^"])+\" { yylval.text = strdup(yytext); return STRING; }
+\"([^"])*\" { yylval.text = strdup(yytext); return STRING; }
. { fprintf(stderr, "\x1b[31m" "ERROR: Invalid character '%c' on line %i\x1b[0m\n", *yytext, yylineno); exit(1); }
diff --git a/bnf/rust.y b/bnf/rust.y
index 046db6b4..2310552b 100644
--- a/bnf/rust.y
+++ b/bnf/rust.y
@@ -69,10 +69,11 @@ tt_list: | tt_list tt_item;
tt_item: tt_paren | tt_brace | tt_square | tt_tok;
tt_tok
: IDENT | STRING | CHARLIT | LIFETIME | INTEGER | MACRO
- | '+' | '*' | '/' | '!' | ',' | ';' | '#'
+ | '+' | '*' | '/' | ',' | ';' | '#'
| RWD_self | RWD_super | RWD_mut | RWD_ref | RWD_let | RWD_where
| RWD_for | RWD_while | RWD_loop | RWD_if | RWD_else | RWD_match | RWD_return
| RWD_impl | RWD_pub | RWD_struct | RWD_enum | RWD_fn | RWD_type | RWD_static | RWD_const
+ | '!' | EXCLAMEQUAL
| '-' | THINARROW
| '&' | DOUBLEAMP
| ':' | DOUBLECOLON
@@ -422,7 +423,7 @@ block_lines: | block_lines block_line;
block_line
: RWD_let let_binding ';'
| MACRO IDENT tt_brace
- | attr item
+ | attrs item
| expr_blocks
| stmt
;