mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
20 lines
428 B
Rust
20 lines
428 B
Rust
![]() |
use {Token, TextUnit, SyntaxKind};
|
||
|
|
||
|
use syntax_kinds::*;
|
||
|
mod grammar;
|
||
|
mod parser;
|
||
|
|
||
|
pub(crate) enum Event {
|
||
|
Start { kind: SyntaxKind },
|
||
|
Finish,
|
||
|
Token {
|
||
|
kind: SyntaxKind,
|
||
|
n_raw_tokens: u8,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
pub(crate) fn parse<'t>(text: &'t str, raw_tokens: &'t [Token]) -> Vec<Event> {
|
||
|
let mut parser = parser::Parser::new(text, raw_tokens);
|
||
|
grammar::parse_file(&mut parser);
|
||
|
parser.into_events()
|
||
|
}
|