aboutsummaryrefslogtreecommitdiff
path: root/src/tree
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-01-07 09:13:01 +0000
committerAleksey Kladov <[email protected]>2018-01-07 09:13:01 +0000
commitf797c81155e9b7371b24801efac3fcbd236fc9ab (patch)
tree27a2fd9e640962489e07d18b6225d3d30096bb39 /src/tree
parent8671a892c5169fe608d0467270a2af7797df8c36 (diff)
Smart eof for blocks
Diffstat (limited to 'src/tree')
-rw-r--r--src/tree/file_builder.rs2
-rw-r--r--src/tree/mod.rs7
2 files changed, 5 insertions, 4 deletions
diff --git a/src/tree/file_builder.rs b/src/tree/file_builder.rs
index a1b004892..ddb29a6b9 100644
--- a/src/tree/file_builder.rs
+++ b/src/tree/file_builder.rs
@@ -154,7 +154,7 @@ impl<'f> ErrorBuilder<'f> {
154 self 154 self
155 } 155 }
156 156
157 pub fn build(self) { 157 pub fn emit(self) {
158 let message = self.message.expect("Error message not set"); 158 let message = self.message.expect("Error message not set");
159 let node = self.builder.current_id(); 159 let node = self.builder.current_id();
160 self.builder.errors.push(SyntaxErrorData { node, message }) 160 self.builder.errors.push(SyntaxErrorData { node, message })
diff --git a/src/tree/mod.rs b/src/tree/mod.rs
index 00d33cbc7..3980b23ce 100644
--- a/src/tree/mod.rs
+++ b/src/tree/mod.rs
@@ -73,7 +73,7 @@ impl<'f> Node<'f> {
73 Children { next: self.as_node(self.data().first_child) } 73 Children { next: self.as_node(self.data().first_child) }
74 } 74 }
75 75
76 pub fn SyntaxErrors(&self) -> SyntaxErrors<'f> { 76 pub fn errors(&self) -> SyntaxErrors<'f> {
77 let pos = self.file.errors.iter().position(|e| e.node == self.idx); 77 let pos = self.file.errors.iter().position(|e| e.node == self.idx);
78 let next = pos 78 let next = pos
79 .map(|i| ErrorIdx(i as u32)) 79 .map(|i| ErrorIdx(i as u32))
@@ -112,12 +112,13 @@ impl<'f> SyntaxError<'f> {
112 } 112 }
113 113
114 fn next(&self) -> Option<SyntaxError<'f>> { 114 fn next(&self) -> Option<SyntaxError<'f>> {
115 if self.file.errors.len() == self.idx.0 as usize { 115 let next_idx = self.idx.0 + 1;
116 if !((next_idx as usize) < self.file.errors.len()) {
116 return None; 117 return None;
117 } 118 }
118 let result = SyntaxError { 119 let result = SyntaxError {
119 file: self.file, 120 file: self.file,
120 idx: ErrorIdx(self.idx.0 + 1) 121 idx: ErrorIdx(next_idx)
121 }; 122 };
122 if result.data().node != self.data().node { 123 if result.data().node != self.data().node {
123 return None; 124 return None;