aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-08 21:09:40 +0100
committerAleksey Kladov <[email protected]>2018-08-08 21:09:40 +0100
commit1f6c442a3f2f660803f598d70f3f69b469637829 (patch)
tree6fa236aa3a1cdfaef96603c9f3c6a76ec78246c8 /src
parent8c598d3d8a9d6fe0b8303250c88c252ff98883fd (diff)
Fix panic with EOF token
Diffstat (limited to 'src')
-rw-r--r--src/parser_api.rs9
-rw-r--r--src/syntax_kinds/generated.rs12
-rw-r--r--src/syntax_kinds/generated.rs.tera13
3 files changed, 22 insertions, 12 deletions
diff --git a/src/parser_api.rs b/src/parser_api.rs
index 58002a8fc..c78c6e43a 100644
--- a/src/parser_api.rs
+++ b/src/parser_api.rs
@@ -29,6 +29,15 @@ macro_rules! token_set_union {
29 ($($ts:expr),* ,) => { token_set_union!($($ts),*) }; 29 ($($ts:expr),* ,) => { token_set_union!($($ts),*) };
30} 30}
31 31
32#[test]
33fn token_set_works_for_tokens() {
34 use SyntaxKind::*;
35 let ts = token_set! { EOF, SHEBANG };
36 assert!(ts.contains(EOF));
37 assert!(ts.contains(SHEBANG));
38 assert!(!ts.contains(PLUS));
39}
40
32/// `Parser` struct provides the low-level API for 41/// `Parser` struct provides the low-level API for
33/// navigating through the stream of tokens and 42/// navigating through the stream of tokens and
34/// constructing the parse tree. The actual parsing 43/// constructing the parse tree. The actual parsing
diff --git a/src/syntax_kinds/generated.rs b/src/syntax_kinds/generated.rs
index 9a9c1f223..655ec4ea5 100644
--- a/src/syntax_kinds/generated.rs
+++ b/src/syntax_kinds/generated.rs
@@ -5,6 +5,12 @@ use super::SyntaxInfo;
5/// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`. 5/// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`.
6#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] 6#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
7pub enum SyntaxKind { 7pub enum SyntaxKind {
8 // Technical SyntaxKinds: they appear temporally during parsing,
9 // but never end up in the final tree
10 #[doc(hidden)]
11 TOMBSTONE,
12 #[doc(hidden)]
13 EOF,
8 SEMI, 14 SEMI,
9 COMMA, 15 COMMA,
10 L_PAREN, 16 L_PAREN,
@@ -192,12 +198,6 @@ pub enum SyntaxKind {
192 PARAM, 198 PARAM,
193 SELF_PARAM, 199 SELF_PARAM,
194 ARG_LIST, 200 ARG_LIST,
195 // Technical SyntaxKinds: they appear temporally during parsing,
196 // but never end up in the final tree
197 #[doc(hidden)]
198 TOMBSTONE,
199 #[doc(hidden)]
200 EOF,
201} 201}
202use self::SyntaxKind::*; 202use self::SyntaxKind::*;
203 203
diff --git a/src/syntax_kinds/generated.rs.tera b/src/syntax_kinds/generated.rs.tera
index 4e2ee56c3..197f720e1 100644
--- a/src/syntax_kinds/generated.rs.tera
+++ b/src/syntax_kinds/generated.rs.tera
@@ -5,6 +5,13 @@ use super::SyntaxInfo;
5/// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`. 5/// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`.
6#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] 6#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
7pub enum SyntaxKind { 7pub enum SyntaxKind {
8 // Technical SyntaxKinds: they appear temporally during parsing,
9 // but never end up in the final tree
10 #[doc(hidden)]
11 TOMBSTONE,
12 #[doc(hidden)]
13 EOF,
14
8{%- for t in concat(a=single_byte_tokens, b=multi_byte_tokens) %} 15{%- for t in concat(a=single_byte_tokens, b=multi_byte_tokens) %}
9 {{t.1}}, 16 {{t.1}},
10{%- endfor -%} 17{%- endfor -%}
@@ -14,12 +21,6 @@ pub enum SyntaxKind {
14{% for t in concat(a=tokens, b=nodes) %} 21{% for t in concat(a=tokens, b=nodes) %}
15 {{t}}, 22 {{t}},
16{%- endfor %} 23{%- endfor %}
17 // Technical SyntaxKinds: they appear temporally during parsing,
18 // but never end up in the final tree
19 #[doc(hidden)]
20 TOMBSTONE,
21 #[doc(hidden)]
22 EOF,
23} 24}
24use self::SyntaxKind::*; 25use self::SyntaxKind::*;
25 26