2019-02-21 15:24:42 +03:00
|
|
|
//! Lexing, bridging to ra_parser (which does the actual parsing) and
|
|
|
|
//! incremental reparsing.
|
|
|
|
|
2019-02-20 15:47:32 +03:00
|
|
|
mod lexer;
|
2019-02-23 16:07:29 +03:00
|
|
|
mod text_token_source;
|
|
|
|
mod text_tree_sink;
|
2019-02-20 16:24:39 +03:00
|
|
|
mod reparsing;
|
2019-02-20 15:47:32 +03:00
|
|
|
|
2019-07-04 23:05:17 +03:00
|
|
|
use crate::{syntax_node::GreenNode, SyntaxError};
|
2020-01-26 20:44:49 +02:00
|
|
|
use text_token_source::TextTokenSource;
|
|
|
|
use text_tree_sink::TextTreeSink;
|
2019-02-20 15:47:32 +03:00
|
|
|
|
2020-01-26 20:44:49 +02:00
|
|
|
pub use lexer::*;
|
2019-02-20 15:47:32 +03:00
|
|
|
|
|
|
|
pub(crate) use self::reparsing::incremental_reparse;
|
|
|
|
|
|
|
|
pub(crate) fn parse_text(text: &str) -> (GreenNode, Vec<SyntaxError>) {
|
2020-01-26 20:44:49 +02:00
|
|
|
let ParsedTokens { tokens, errors } = tokenize(&text);
|
|
|
|
let mut token_source = TextTokenSource::new(text, &tokens);
|
|
|
|
let mut tree_sink = TextTreeSink::new(text, &tokens, errors);
|
2019-05-25 20:31:53 +08:00
|
|
|
ra_parser::parse(&mut token_source, &mut tree_sink);
|
2019-02-21 12:03:42 +03:00
|
|
|
tree_sink.finish()
|
2019-02-20 15:47:32 +03:00
|
|
|
}
|