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
41
42
43
44
45
46
// // TODO: Remove all the #[allow(..)] after development.
// #![allow(dead_code)]
// mod ast;
// mod diagnostic;
// mod error;
// mod location;
// mod parser;
// use std::cell::RefCell;
// use diagnostic::{ParseDiagnostic, ParseDiagnosticBuilder};
// use location::Span;
// // region: Parsing context.
// #[derive(Clone, Debug)]
// struct ParseContext {
// diags: RefCell<Vec<ParseDiagnostic>>,
// }
// impl ParseContext {
// fn diag(&self, builder: ParseDiagnosticBuilder) {
// self.diags.borrow_mut().push(builder.build());
// }
// fn take_diags(&self) -> Vec<ParseDiagnostic> {
// self.diags.take()
// }
// }
// // endregion
// pub(crate) fn source_to_span(source_code: &str) -> Span {
// let context = ParseContext {
// diags: RefCell::new(Vec::new()),
// };
// nom_locate::LocatedSpan::new_extra(source_code, context)
// }
// #[allow(unused_variables)]
// pub fn parse(file_path: impl AsRef<str>, source_code: &str) {
// // HACK: When reporting errors, add a newline to the end of the source
// // so that miette can highlight the last character.
// parser::test(file_path, source_code);
// }