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
30
31
32
33
34
35
36
37
38
39
40
#![cfg_attr(can_show_location_of_runtime_parse_error, feature(proc_macro_span))]
#![deny(rust_2018_idioms, unsafe_code)]
#[allow(clippy::useless_attribute)]
extern crate proc_macro;
use proc_macro_hack::proc_macro_hack;
mod context;
mod error;
mod gtk;
mod lexer;
mod parser;
#[proc_macro_hack]
pub fn gtk(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let stream: lexer::Tokens = input.into();
let result = parser::grammar::GtkElementParser::new().parse(stream.lexer());
match result {
Err(err) => error::parse_error(&stream, &err),
Ok(element) => gtk::expand_gtk(&element),
}
.into()
}