aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-08 17:44:16 +0100
committerAleksey Kladov <[email protected]>2018-08-08 17:44:16 +0100
commitcc4c90aa2cf4da819dd324a7bbf8b36f6a068a6d (patch)
treea9e0018e9ef2821e3e329dbefefde8cd1cd93f00
parenteb8e9043e227682e6e7db2711091dc74d847e766 (diff)
minor
-rw-r--r--src/lib.rs2
-rw-r--r--src/yellow/green.rs60
2 files changed, 31 insertions, 31 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 94d843db3..0ae8082f1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -35,9 +35,9 @@ mod grammar;
35mod parser_impl; 35mod parser_impl;
36 36
37mod syntax_kinds; 37mod syntax_kinds;
38mod yellow;
38/// Utilities for simple uses of the parser. 39/// Utilities for simple uses of the parser.
39pub mod utils; 40pub mod utils;
40mod yellow;
41 41
42pub use { 42pub use {
43 ast::File, 43 ast::File,
diff --git a/src/yellow/green.rs b/src/yellow/green.rs
index 8ddcc74b8..3ade46f45 100644
--- a/src/yellow/green.rs
+++ b/src/yellow/green.rs
@@ -79,6 +79,36 @@ fn assert_send_sync() {
79} 79}
80 80
81#[derive(Clone, Debug)] 81#[derive(Clone, Debug)]
82pub(crate) struct GreenBranch {
83 text_len: TextUnit,
84 kind: SyntaxKind,
85 children: Vec<GreenNode>,
86}
87
88impl GreenBranch {
89 fn new(kind: SyntaxKind, children: Vec<GreenNode>) -> GreenBranch {
90 let text_len = children.iter().map(|x| x.text_len()).sum::<TextUnit>();
91 GreenBranch {
92 text_len,
93 kind,
94 children,
95 }
96 }
97
98 pub fn kind(&self) -> SyntaxKind {
99 self.kind
100 }
101
102 pub fn text_len(&self) -> TextUnit {
103 self.text_len
104 }
105
106 pub fn children(&self) -> &[GreenNode] {
107 self.children.as_slice()
108 }
109}
110
111#[derive(Clone, Debug)]
82pub(crate) enum GreenLeaf { 112pub(crate) enum GreenLeaf {
83 Whitespace { 113 Whitespace {
84 newlines: u8, 114 newlines: u8,
@@ -143,33 +173,3 @@ const N_NEWLINES: usize = 16;
143const N_SPACES: usize = 64; 173const N_SPACES: usize = 64;
144const WS: &str = 174const WS: &str =
145 "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n "; 175 "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n ";
146
147#[derive(Clone, Debug)]
148pub(crate) struct GreenBranch {
149 text_len: TextUnit,
150 kind: SyntaxKind,
151 children: Vec<GreenNode>,
152}
153
154impl GreenBranch {
155 fn new(kind: SyntaxKind, children: Vec<GreenNode>) -> GreenBranch {
156 let text_len = children.iter().map(|x| x.text_len()).sum::<TextUnit>();
157 GreenBranch {
158 text_len,
159 kind,
160 children,
161 }
162 }
163
164 pub fn kind(&self) -> SyntaxKind {
165 self.kind
166 }
167
168 pub fn text_len(&self) -> TextUnit {
169 self.text_len
170 }
171
172 pub fn children(&self) -> &[GreenNode] {
173 self.children.as_slice()
174 }
175}