aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-02-10 11:00:23 +0000
committerAleksey Kladov <[email protected]>2018-02-10 11:00:23 +0000
commitfc0a9e266b9d663b1eeca3963495c68ca3384be2 (patch)
tree324632ed4e19f1b2499d8d1be9b4bc631878a3ba /src
parentc3b009b6d24225ad2add62fce8206918fceba3eb (diff)
G: introduce names
Diffstat (limited to 'src')
-rw-r--r--src/parser/grammar/items/mod.rs5
-rw-r--r--src/parser/grammar/mod.rs12
-rw-r--r--src/syntax_kinds.rs4
3 files changed, 18 insertions, 3 deletions
diff --git a/src/parser/grammar/items/mod.rs b/src/parser/grammar/items/mod.rs
index ffe86fa97..d671568b1 100644
--- a/src/parser/grammar/items/mod.rs
+++ b/src/parser/grammar/items/mod.rs
@@ -196,8 +196,9 @@ fn extern_crate_item(p: &mut Parser) {
196 p.bump(); 196 p.bump();
197 assert!(p.at(CRATE_KW)); 197 assert!(p.at(CRATE_KW));
198 p.bump(); 198 p.bump();
199 199 name(p);
200 p.expect(IDENT) && alias(p) && p.expect(SEMI); 200 alias(p);
201 p.expect(SEMI);
201} 202}
202 203
203fn extern_block(p: &mut Parser) { 204fn extern_block(p: &mut Parser) {
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 {
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
53fn 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
53fn error_block(p: &mut Parser, message: &str) { 63fn error_block(p: &mut Parser, message: &str) {
54 assert!(p.at(L_CURLY)); 64 assert!(p.at(L_CURLY));
55 let err = p.start(); 65 let err = p.start();
diff --git a/src/syntax_kinds.rs b/src/syntax_kinds.rs
index dc287f0f4..7450f9d6f 100644
--- a/src/syntax_kinds.rs
+++ b/src/syntax_kinds.rs
@@ -116,6 +116,8 @@ pub enum SyntaxKind {
116 LIFETIME_PARAM, 116 LIFETIME_PARAM,
117 TYPE_PARAM, 117 TYPE_PARAM,
118 ABI, 118 ABI,
119 NAME,
120 NAME_REF,
119 121
120 // Technical SyntaxKinds: they appear temporally during parsing, 122 // Technical SyntaxKinds: they appear temporally during parsing,
121 // but never end up in the final tree 123 // but never end up in the final tree
@@ -239,6 +241,8 @@ impl SyntaxKind {
239 LIFETIME_PARAM => &SyntaxInfo { name: "LIFETIME_PARAM" }, 241 LIFETIME_PARAM => &SyntaxInfo { name: "LIFETIME_PARAM" },
240 TYPE_PARAM => &SyntaxInfo { name: "TYPE_PARAM" }, 242 TYPE_PARAM => &SyntaxInfo { name: "TYPE_PARAM" },
241 ABI => &SyntaxInfo { name: "ABI" }, 243 ABI => &SyntaxInfo { name: "ABI" },
244 NAME => &SyntaxInfo { name: "NAME" },
245 NAME_REF => &SyntaxInfo { name: "NAME_REF" },
242 246
243 TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" }, 247 TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" },
244 EOF => &SyntaxInfo { name: "EOF" }, 248 EOF => &SyntaxInfo { name: "EOF" },