From 415c891d641fa305e7ddbbbcc78db990dd5d3564 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 29 Jul 2018 15:16:07 +0300 Subject: Reorganize --- src/parser/mod.rs | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) (limited to 'src/parser/mod.rs') diff --git a/src/parser/mod.rs b/src/parser/mod.rs index b7d5e5832..e72ab05af 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -5,18 +5,16 @@ mod input; mod event; mod grammar; -use std::sync::Arc; use { - Token, - yellow::SyntaxNode, - syntax_kinds::* + lexer::Token, + parser::event::{process} }; -use GreenBuilder; -use parser::event::process; + +pub(crate) use self::event::Sink; /// Parse a sequence of tokens into the representative node tree -pub fn parse_green(text: String, tokens: &[Token]) -> SyntaxNode { +pub(crate) fn parse(text: String, tokens: &[Token]) -> S::Tree { let events = { let input = input::ParserInput::new(&text, tokens); let parser_impl = parser::imp::ParserImpl::new(&input); @@ -24,15 +22,7 @@ pub fn parse_green(text: String, tokens: &[Token]) -> SyntaxNode { grammar::file(&mut parser); parser.0.into_events() }; - let mut builder = GreenBuilder::new(text); - process(&mut builder, tokens, events); - let (green, errors) = builder.finish(); - SyntaxNode::new(Arc::new(green), errors) -} - -fn is_insignificant(kind: SyntaxKind) -> bool { - match kind { - WHITESPACE | COMMENT => true, - _ => false, - } + let mut sink = S::new(text); + process(&mut sink, tokens, events); + sink.finish() } -- cgit v1.2.3