Switch to pest-generated parser

This commit is contained in:
Joscha 2021-11-18 02:49:38 +01:00
parent 9c9e5764f2
commit 1e58672e21
9 changed files with 262 additions and 250 deletions

View file

@ -1,7 +1,11 @@
use std::fs;
use std::path::PathBuf;
use pest::Parser;
use structopt::StructOpt;
use parse::{MyParser, Rule};
mod commands;
mod parse;
@ -11,10 +15,10 @@ pub struct Opt {
file: PathBuf,
}
fn main() {
fn main() -> anyhow::Result<()> {
let opt = Opt::from_args();
println!("{:#?}", opt);
let commands = parse::parse(&opt.file);
println!("{:#?}", commands);
let content = fs::read_to_string(&opt.file)?;
let parsed = MyParser::parse(Rule::file, &content)?.next().unwrap();
println!("{:#?}", parsed);
Ok(())
}