aboutsummaryrefslogtreecommitdiff
path: root/src/parser/grammar
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-02-10 11:17:38 +0000
committerAleksey Kladov <[email protected]>2018-02-10 11:17:38 +0000
commite792ec3eca6214329d053715a6477cc4f7a05672 (patch)
tree983d71dd78990607924edce788a0326db1bfad20 /src/parser/grammar
parentfa2131365e8ff2a6fa4fcb47aa04e6d51a32943e (diff)
G: use name refs in paths
Diffstat (limited to 'src/parser/grammar')
-rw-r--r--src/parser/grammar/mod.rs10
-rw-r--r--src/parser/grammar/paths.rs3
2 files changed, 12 insertions, 1 deletions
diff --git a/src/parser/grammar/mod.rs b/src/parser/grammar/mod.rs
index 6e82d7c69..abf9fe86c 100644
--- a/src/parser/grammar/mod.rs
+++ b/src/parser/grammar/mod.rs
@@ -60,6 +60,16 @@ fn name(p: &mut Parser) {
60 } 60 }
61} 61}
62 62
63fn name_ref(p: &mut Parser) {
64 if p.at(IDENT) {
65 let m = p.start();
66 p.bump();
67 m.complete(p, NAME_REF);
68 } else {
69 p.error("expected identifier");
70 }
71}
72
63fn error_block(p: &mut Parser, message: &str) { 73fn error_block(p: &mut Parser, message: &str) {
64 assert!(p.at(L_CURLY)); 74 assert!(p.at(L_CURLY));
65 let err = p.start(); 75 let err = p.start();
diff --git a/src/parser/grammar/paths.rs b/src/parser/grammar/paths.rs
index a7fc90774..6ed315c3d 100644
--- a/src/parser/grammar/paths.rs
+++ b/src/parser/grammar/paths.rs
@@ -42,7 +42,8 @@ fn path_segment(p: &mut Parser, first: bool) {
42 p.eat(COLONCOLON); 42 p.eat(COLONCOLON);
43 } 43 }
44 match p.current() { 44 match p.current() {
45 IDENT | SELF_KW | SUPER_KW => p.bump(), 45 IDENT => name_ref(p),
46 SELF_KW | SUPER_KW => p.bump(),
46 _ => { 47 _ => {
47 p.error("expected identifier"); 48 p.error("expected identifier");
48 } 49 }