From e792ec3eca6214329d053715a6477cc4f7a05672 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 10 Feb 2018 14:17:38 +0300 Subject: G: use name refs in paths --- src/parser/grammar/mod.rs | 10 ++++++++++ src/parser/grammar/paths.rs | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src') 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) { } } +fn name_ref(p: &mut Parser) { + if p.at(IDENT) { + let m = p.start(); + p.bump(); + m.complete(p, NAME_REF); + } else { + p.error("expected identifier"); + } +} + fn error_block(p: &mut Parser, message: &str) { assert!(p.at(L_CURLY)); 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) { p.eat(COLONCOLON); } match p.current() { - IDENT | SELF_KW | SUPER_KW => p.bump(), + IDENT => name_ref(p), + SELF_KW | SUPER_KW => p.bump(), _ => { p.error("expected identifier"); } -- cgit v1.2.3