aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/gen.rs14
-rw-r--r--src/lib.rs2
-rw-r--r--src/syntax_kinds.rs4
3 files changed, 14 insertions, 6 deletions
diff --git a/src/bin/gen.rs b/src/bin/gen.rs
index 4acf381e3..f5a66d9f2 100644
--- a/src/bin/gen.rs
+++ b/src/bin/gen.rs
@@ -17,7 +17,8 @@ fn main() {
17 17
18#[derive(Deserialize)] 18#[derive(Deserialize)]
19struct Grammar { 19struct Grammar {
20 syntax_kinds: Vec<String>, 20 tokens: Vec<String>,
21 nodes: Vec<String>,
21} 22}
22 23
23impl Grammar { 24impl Grammar {
@@ -31,7 +32,12 @@ impl Grammar {
31 acc.push_str("// Generated from grammar.ron\n"); 32 acc.push_str("// Generated from grammar.ron\n");
32 acc.push_str("use tree::{SyntaxKind, SyntaxInfo};\n"); 33 acc.push_str("use tree::{SyntaxKind, SyntaxInfo};\n");
33 acc.push_str("\n"); 34 acc.push_str("\n");
34 for (idx, kind) in self.syntax_kinds.iter().enumerate() { 35
36 let syntax_kinds: Vec<&String> =
37 self.tokens.iter().chain(self.nodes.iter())
38 .collect();
39
40 for (idx, kind) in syntax_kinds.iter().enumerate() {
35 let sname = scream(kind); 41 let sname = scream(kind);
36 write!( 42 write!(
37 acc, 43 acc,
@@ -40,8 +46,8 @@ impl Grammar {
40 ).unwrap(); 46 ).unwrap();
41 } 47 }
42 acc.push_str("\n"); 48 acc.push_str("\n");
43 write!(acc, "static INFOS: [SyntaxInfo; {}] = [\n", self.syntax_kinds.len()).unwrap(); 49 write!(acc, "static INFOS: [SyntaxInfo; {}] = [\n", syntax_kinds.len()).unwrap();
44 for kind in self.syntax_kinds.iter() { 50 for kind in syntax_kinds.iter() {
45 let sname = scream(kind); 51 let sname = scream(kind);
46 write!( 52 write!(
47 acc, 53 acc,
diff --git a/src/lib.rs b/src/lib.rs
index 82213e2b3..0685e3f2c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -6,5 +6,5 @@ mod lexer;
6 6
7pub mod syntax_kinds; 7pub mod syntax_kinds;
8pub use text::{TextUnit, TextRange}; 8pub use text::{TextUnit, TextRange};
9pub use tree::{SyntaxKind, Token}; 9pub use tree::{SyntaxKind, Token, FileBuilder, File, Node};
10pub use lexer::{next_token, tokenize}; 10pub use lexer::{next_token, tokenize};
diff --git a/src/syntax_kinds.rs b/src/syntax_kinds.rs
index ec2a036b9..b83f48dd8 100644
--- a/src/syntax_kinds.rs
+++ b/src/syntax_kinds.rs
@@ -52,8 +52,9 @@ pub const THIN_ARROW: SyntaxKind = SyntaxKind(47);
52pub const COMMENT: SyntaxKind = SyntaxKind(48); 52pub const COMMENT: SyntaxKind = SyntaxKind(48);
53pub const DOC_COMMENT: SyntaxKind = SyntaxKind(49); 53pub const DOC_COMMENT: SyntaxKind = SyntaxKind(49);
54pub const SHEBANG: SyntaxKind = SyntaxKind(50); 54pub const SHEBANG: SyntaxKind = SyntaxKind(50);
55pub const FILE: SyntaxKind = SyntaxKind(51);
55 56
56static INFOS: [SyntaxInfo; 51] = [ 57static INFOS: [SyntaxInfo; 52] = [
57 SyntaxInfo { name: "ERROR" }, 58 SyntaxInfo { name: "ERROR" },
58 SyntaxInfo { name: "IDENT" }, 59 SyntaxInfo { name: "IDENT" },
59 SyntaxInfo { name: "UNDERSCORE" }, 60 SyntaxInfo { name: "UNDERSCORE" },
@@ -105,6 +106,7 @@ static INFOS: [SyntaxInfo; 51] = [
105 SyntaxInfo { name: "COMMENT" }, 106 SyntaxInfo { name: "COMMENT" },
106 SyntaxInfo { name: "DOC_COMMENT" }, 107 SyntaxInfo { name: "DOC_COMMENT" },
107 SyntaxInfo { name: "SHEBANG" }, 108 SyntaxInfo { name: "SHEBANG" },
109 SyntaxInfo { name: "FILE" },
108]; 110];
109 111
110pub(crate) fn syntax_info(kind: SyntaxKind) -> &'static SyntaxInfo { 112pub(crate) fn syntax_info(kind: SyntaxKind) -> &'static SyntaxInfo {