aboutsummaryrefslogtreecommitdiff
path: root/src/parser
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-07-29 12:37:48 +0100
committerAleksey Kladov <[email protected]>2018-07-29 12:37:48 +0100
commitad188d4c3db34f035408afbdd6d2f3c308121f0a (patch)
tree0c6cdea50ab664a361fa4c0f6b99cb53ce00529b /src/parser
parentc12450fb4e30c3418555e47d045bb9fd4318a10a (diff)
kill old tree
Diffstat (limited to 'src/parser')
-rw-r--r--src/parser/event.rs10
-rw-r--r--src/parser/mod.rs14
2 files changed, 3 insertions, 21 deletions
diff --git a/src/parser/event.rs b/src/parser/event.rs
index 0fbfaeb9f..83039c664 100644
--- a/src/parser/event.rs
+++ b/src/parser/event.rs
@@ -1,5 +1,5 @@
1use { 1use {
2 ErrorMsg, File, FileBuilder, Sink, SyntaxKind, Token, GreenBuilder, 2 Sink, SyntaxKind, Token,
3 syntax_kinds::TOMBSTONE, 3 syntax_kinds::TOMBSTONE,
4}; 4};
5use super::is_insignificant; 5use super::is_insignificant;
@@ -67,12 +67,6 @@ pub(crate) enum Event {
67 }, 67 },
68} 68}
69 69
70pub(super) fn to_file(text: String, tokens: &[Token], events: Vec<Event>) -> File {
71 let mut builder = FileBuilder::new(text);
72 process(&mut builder, tokens, events);
73 builder.finish()
74}
75
76pub(super) fn process(builder: &mut Sink, tokens: &[Token], events: Vec<Event>) { 70pub(super) fn process(builder: &mut Sink, tokens: &[Token], events: Vec<Event>) {
77 let mut idx = 0; 71 let mut idx = 0;
78 72
@@ -147,7 +141,7 @@ pub(super) fn process(builder: &mut Sink, tokens: &[Token], events: Vec<Event>)
147 } 141 }
148 builder.leaf(kind, len); 142 builder.leaf(kind, len);
149 } 143 }
150 &Event::Error { ref msg } => builder.error(ErrorMsg { msg: msg.clone() }), 144 &Event::Error { ref msg } => builder.error(msg.clone()),
151 } 145 }
152 } 146 }
153} 147}
diff --git a/src/parser/mod.rs b/src/parser/mod.rs
index 26fbb6e3d..b7d5e5832 100644
--- a/src/parser/mod.rs
+++ b/src/parser/mod.rs
@@ -7,7 +7,7 @@ mod grammar;
7 7
8use std::sync::Arc; 8use std::sync::Arc;
9use { 9use {
10 File, SyntaxKind, Token, 10 Token,
11 yellow::SyntaxNode, 11 yellow::SyntaxNode,
12 syntax_kinds::* 12 syntax_kinds::*
13}; 13};
@@ -16,18 +16,6 @@ use parser::event::process;
16 16
17 17
18/// Parse a sequence of tokens into the representative node tree 18/// Parse a sequence of tokens into the representative node tree
19pub fn parse(text: String, tokens: &[Token]) -> File {
20 let events = {
21 let input = input::ParserInput::new(&text, tokens);
22 let parser_impl = parser::imp::ParserImpl::new(&input);
23 let mut parser = parser::Parser(parser_impl);
24 grammar::file(&mut parser);
25 parser.0.into_events()
26 };
27 event::to_file(text, tokens, events)
28}
29
30/// Parse a sequence of tokens into the representative node tree
31pub fn parse_green(text: String, tokens: &[Token]) -> SyntaxNode { 19pub fn parse_green(text: String, tokens: &[Token]) -> SyntaxNode {
32 let events = { 20 let events = {
33 let input = input::ParserInput::new(&text, tokens); 21 let input = input::ParserInput::new(&text, tokens);