aboutsummaryrefslogtreecommitdiff
path: root/src/parser/event_parser/mod.rs
blob: 1228236a963847127f177198b29325d0145fa0d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use {Token, TextUnit, SyntaxKind};

use syntax_kinds::*;
mod grammar;
mod parser;

#[derive(Debug)]
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::file(&mut parser);
    parser.into_events()
}