Start with Pest Parser

This commit is contained in:
2021-10-19 12:19:08 +02:00
committed by Raymon Zutekouw
parent 269bdf0389
commit 3d60b6cb5d
5 changed files with 163 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
alpha = { 'a'..'z' | 'A'..'Z' }
+17
View File
@@ -4,6 +4,17 @@ use std::io::Write;
use anyhow::{Context, Result};
use structopt::StructOpt;
extern crate pest;
#[macro_use]
extern crate pest_derive;
use pest::Parser;
#[derive(Parser)]
#[grammar = "grammars/mblf.pest"]
struct MblfParser;
#[derive(StructOpt)]
struct Cli {
#[structopt(parse(from_os_str))]
@@ -19,6 +30,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_context(|| format!("could not read source file {:?}", args.input_file))?;
let mut out = File::create(args.output_file)?;
let _pairs = MblfParser::parse(Rule::alpha, "a").unwrap();
out.write_all(&content.as_bytes())?;
out.sync_all()?;