diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-02-04 14:07:09 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-02-04 14:07:09 +0000 |
commit | 550b17d7cf321c2aebff75d00b1654b55beca53c (patch) | |
tree | a7759795877d2d5fef25915997c2679af0cd3e94 /tools/src/bin | |
parent | b86e87c8885895e5b3fcec021ee65003d64c4cbe (diff) | |
parent | 351107d0b143e2c3497bd0f424f0d76bc51df0c0 (diff) |
Merge #43
43: Ctx r=matklad a=matklad
Diffstat (limited to 'tools/src/bin')
-rw-r--r-- | tools/src/bin/gen.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/src/bin/gen.rs b/tools/src/bin/gen.rs index 17cdea7a1..7cb164316 100644 --- a/tools/src/bin/gen.rs +++ b/tools/src/bin/gen.rs | |||
@@ -20,6 +20,7 @@ fn main() { | |||
20 | #[derive(Deserialize)] | 20 | #[derive(Deserialize)] |
21 | struct Grammar { | 21 | struct Grammar { |
22 | keywords: Vec<String>, | 22 | keywords: Vec<String>, |
23 | contextual_keywords: Vec<String>, | ||
23 | tokens: Vec<String>, | 24 | tokens: Vec<String>, |
24 | nodes: Vec<String>, | 25 | nodes: Vec<String>, |
25 | } | 26 | } |
@@ -38,10 +39,11 @@ impl Grammar { | |||
38 | acc.push_str("use tree::SyntaxInfo;\n"); | 39 | acc.push_str("use tree::SyntaxInfo;\n"); |
39 | acc.push_str("\n"); | 40 | acc.push_str("\n"); |
40 | 41 | ||
41 | let syntax_kinds: Vec<String> = self.keywords | 42 | let syntax_kinds: Vec<String> = self.tokens |
42 | .iter() | 43 | .iter() |
43 | .map(|kw| kw_token(kw)) | 44 | .cloned() |
44 | .chain(self.tokens.iter().cloned()) | 45 | .chain(self.keywords.iter().map(|kw| kw_token(kw))) |
46 | .chain(self.contextual_keywords.iter().map(|kw| kw_token(kw))) | ||
45 | .chain(self.nodes.iter().cloned()) | 47 | .chain(self.nodes.iter().cloned()) |
46 | .collect(); | 48 | .collect(); |
47 | 49 | ||
@@ -86,6 +88,7 @@ impl Grammar { | |||
86 | // fn ident_to_keyword | 88 | // fn ident_to_keyword |
87 | acc.push_str("pub(crate) fn ident_to_keyword(ident: &str) -> Option<SyntaxKind> {\n"); | 89 | acc.push_str("pub(crate) fn ident_to_keyword(ident: &str) -> Option<SyntaxKind> {\n"); |
88 | acc.push_str(" match ident {\n"); | 90 | acc.push_str(" match ident {\n"); |
91 | // NB: no contextual_keywords here! | ||
89 | for kw in self.keywords.iter() { | 92 | for kw in self.keywords.iter() { |
90 | write!(acc, " {:?} => Some({}),\n", kw, kw_token(kw)).unwrap(); | 93 | write!(acc, " {:?} => Some({}),\n", kw, kw_token(kw)).unwrap(); |
91 | } | 94 | } |