blob: 3814837e11a214e2d68108fe2d619e277dfdb6f5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
use {File, SyntaxKind, Token};
use syntax_kinds::*;
#[macro_use]
mod token_set;
mod parser;
mod input;
mod event;
mod grammar;
/// Parse a sequence of tokens into the representative node tree
pub fn parse(text: String, tokens: &[Token]) -> File {
let events = {
let input = input::ParserInput::new(&text, tokens);
let parser_impl = parser::imp::ParserImpl::new(&input);
let mut parser = parser::Parser(parser_impl);
grammar::file(&mut parser);
parser.0.into_events()
};
event::to_file(text, tokens, events)
}
fn is_insignificant(kind: SyntaxKind) -> bool {
match kind {
WHITESPACE | COMMENT => true,
_ => false,
}
}
|