-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathlib.rs
More file actions
34 lines (31 loc) · 1009 Bytes
/
Copy pathlib.rs
File metadata and controls
34 lines (31 loc) · 1009 Bytes
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
pub mod ast;
pub mod errors;
pub mod infer;
#[allow(clippy::all)]
#[allow(clippy::unwrap_in_result)]
mod parser_impl {
use lalrpop_util::lalrpop_mod;
lalrpop_mod!(pub parser);
}
pub use errors::{InferenceError, ParseError, Span};
pub use infer::{infer_type, TypeResult};
pub use parser_impl::parser;
pub fn process_test_lines(input_content: &str) -> Vec<String> {
let mut results = Vec::new();
for line in input_content.lines() {
let trimmed = line.trim();
if trimmed.is_empty() || trimmed.starts_with('#') {
results.push(trimmed.to_string());
continue;
}
let result = match parser::TopParser::new().parse(trimmed) {
Ok(term) => match infer_type(&term) {
Ok(ty) => format!("{} : {}", trimmed, ty),
Err(e) => format!("{} : ERROR: {}", trimmed, e),
},
Err(e) => format!("{} : PARSE ERROR: {}", trimmed, e),
};
results.push(result);
}
results
}