Switch to pest-generated parser
This commit is contained in:
parent
9c9e5764f2
commit
1e58672e21
9 changed files with 262 additions and 250 deletions
14
src/main.rs
14
src/main.rs
|
|
@ -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(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue