diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-02-10 11:23:41 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-02-10 11:23:41 +0000 |
commit | b814d931514cdc250f9156dabd874edf685569d0 (patch) | |
tree | 6de85e5e662bc0c6eca78715496a02867da1eff9 /src/parser/grammar/mod.rs | |
parent | c3b009b6d24225ad2add62fce8206918fceba3eb (diff) | |
parent | 199b3a1604095beee9eaeec541c8f158e85493ea (diff) |
Merge #46
46: Names r=matklad a=matklad
bors r+
Diffstat (limited to 'src/parser/grammar/mod.rs')
-rw-r--r-- | src/parser/grammar/mod.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/parser/grammar/mod.rs b/src/parser/grammar/mod.rs index b949583ff..abf9fe86c 100644 --- a/src/parser/grammar/mod.rs +++ b/src/parser/grammar/mod.rs | |||
@@ -44,12 +44,32 @@ fn alias(p: &mut Parser) -> bool { | |||
44 | if p.at(AS_KW) { | 44 | if p.at(AS_KW) { |
45 | let alias = p.start(); | 45 | let alias = p.start(); |
46 | p.bump(); | 46 | p.bump(); |
47 | p.expect(IDENT); | 47 | name(p); |
48 | alias.complete(p, ALIAS); | 48 | alias.complete(p, ALIAS); |
49 | } | 49 | } |
50 | true //FIXME: return false if three are errors | 50 | true //FIXME: return false if three are errors |
51 | } | 51 | } |
52 | 52 | ||
53 | fn name(p: &mut Parser) { | ||
54 | if p.at(IDENT) { | ||
55 | let m = p.start(); | ||
56 | p.bump(); | ||
57 | m.complete(p, NAME); | ||
58 | } else { | ||
59 | p.error("expected a name"); | ||
60 | } | ||
61 | } | ||
62 | |||
63 | fn 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 | |||
53 | fn error_block(p: &mut Parser, message: &str) { | 73 | fn error_block(p: &mut Parser, message: &str) { |
54 | assert!(p.at(L_CURLY)); | 74 | assert!(p.at(L_CURLY)); |
55 | let err = p.start(); | 75 | let err = p.start(); |