diff --git a/Cargo.toml b/Cargo.toml index 0048e0f..69c4922 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "purrchance" -version = "0.2.0" +version = "0.1.0" authors = ["xenofem "] description = "An unofficial Rust implementation of the Perchance grammar engine" repository = "https://git.xeno.science/xenofem/purrchance" diff --git a/src/bin/purrchance.rs b/src/bin/purrchance.rs deleted file mode 100644 index 87d1664..0000000 --- a/src/bin/purrchance.rs +++ /dev/null @@ -1,25 +0,0 @@ -use purrchance::*; -use purrchance::parser::*; - -use std::env; -use std::fs::read_to_string; -use std::process::exit; - -fn main() { - let args: Vec = env::args().collect(); - - if args.len() < 2 { - eprintln!("too few arguments!"); - exit(1); - } - - let raw_grammar = read_to_string(&args[1]).unwrap(); - let grammar = load_grammar(&raw_grammar); - if args.len() < 3 { - eprintln!("{:?}", grammar); - exit(0); - } - - let sym = Symbol::NonTerminal(args[2].clone()); - println!("{}", sym.eval(&grammar).unwrap()); -} diff --git a/src/lib.rs b/src/lib.rs index 038fea9..b2c529a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,6 @@ pub trait Purrchance { fn eval(&self, g: &Grammar) -> Option; } -#[derive(Debug)] pub enum Symbol { Terminal(String), NonTerminal(String), @@ -25,7 +24,6 @@ impl Purrchance for Symbol { } } -#[derive(Debug)] pub struct Expr(Vec); impl Purrchance for Expr { @@ -34,7 +32,6 @@ impl Purrchance for Expr { } } -#[derive(Debug)] pub struct List(Vec<(Expr, f64)>); impl Purrchance for List { @@ -43,7 +40,6 @@ impl Purrchance for List { } } -#[derive(Debug)] pub struct Grammar(HashMap); #[cfg(test)] @@ -146,19 +142,6 @@ test test foo ^1000000 bar ^1/1000000 -"); - let nt = Symbol::NonTerminal(String::from("test")); - assert_eq!(nt.eval(&g), Some(String::from("foo"))); - } - - #[test] - fn eval_loaded_grammar_multiple_lists() { - let g = load_grammar(" -test - [test1] - -test1 - foo "); let nt = Symbol::NonTerminal(String::from("test")); assert_eq!(nt.eval(&g), Some(String::from("foo"))); diff --git a/src/parser.rs b/src/parser.rs index 16397ce..57ef599 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -25,7 +25,7 @@ fn whitespace(input: &str) -> IResult<&str, ()> { } fn empty_line(input: &str) -> IResult<&str, ()> { - map(tuple((whitespace, opt(comment), tag("\n"))), |_| ())(input) + map(tuple((opt(comment), tag("\n"))), |_| ())(input) } pub fn take_until_any>(tags: Vec) -> impl Fn(Input) -> IResult