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

mod grammar;
mod parser;

#[derive(Debug)]
pub(crate) enum Event {
    Start { kind: SyntaxKind },
    Finish,
    Token {
        kind: SyntaxKind,
        n_raw_tokens: u8,
    },
    Error {
        message: String,
    },
}

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()
}