#![allow(unused_variables)]
#![allow(unused_imports)]
use pest::{
error::{ErrorVariant, LineColLocation},
Parser,
};
use std::{fs, include_str};
use ux_compiler::{Rule, UxParser};
pub mod ast;
fn pretty_error(positives: Vec<Rule>, line: usize, col: usize, input: &str) {
let mut input_lines = input.lines();
if let Some(data) = input_lines.nth(line - 1) {
println!(
r#"UnrecognizedToken "{:?}" at {} line, {} col"#,
positives, line, col
);
println!();
println!("{:4}|{}", line, data);
println!("{:width$}^", "", width = col + 5);
} else {
println!("Empty line: {}", line);
}
}
fn main() {
let input = fs::read_to_string("tests/data/01.html").expect("cannot read file");
match UxParser::parse(Rule::file, &input) {
Ok(pairs) => {
println!("Is Ok");
}
Err(err) => {
match err.variant {
ErrorVariant::ParsingError {
positives,
negatives,
} => match err.line_col {
LineColLocation::Pos((line, col)) => {
pretty_error(positives, line, col, &input);
}
_ => {
}
},
_ => {}
}
}
}
}
#[test]
fn tests() {
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum CalculatorError {
InputTooBig,
OddNumber,
}