From fc0a9e266b9d663b1eeca3963495c68ca3384be2 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 10 Feb 2018 14:00:23 +0300 Subject: G: introduce names --- src/parser/grammar/mod.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/parser/grammar/mod.rs') diff --git a/src/parser/grammar/mod.rs b/src/parser/grammar/mod.rs index b949583ff..6e82d7c69 100644 --- a/src/parser/grammar/mod.rs +++ b/src/parser/grammar/mod.rs @@ -44,12 +44,22 @@ fn alias(p: &mut Parser) -> bool { if p.at(AS_KW) { let alias = p.start(); p.bump(); - p.expect(IDENT); + name(p); alias.complete(p, ALIAS); } true //FIXME: return false if three are errors } +fn name(p: &mut Parser) { + if p.at(IDENT) { + let m = p.start(); + p.bump(); + m.complete(p, NAME); + } else { + p.error("expected a name"); + } +} + fn error_block(p: &mut Parser, message: &str) { assert!(p.at(L_CURLY)); let err = p.start(); -- cgit v1.2.3