derive Clone for grammars
This commit is contained in:
parent
3beb298a6d
commit
f99f22f477
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "purrchance"
|
name = "purrchance"
|
||||||
version = "0.3.0"
|
version = "0.4.0"
|
||||||
authors = ["xenofem <xenofem@xeno.science>"]
|
authors = ["xenofem <xenofem@xeno.science>"]
|
||||||
description = "An unofficial Rust implementation of the Perchance grammar engine"
|
description = "An unofficial Rust implementation of the Perchance grammar engine"
|
||||||
repository = "https://git.xeno.science/xenofem/purrchance"
|
repository = "https://git.xeno.science/xenofem/purrchance"
|
||||||
|
|
|
@ -10,7 +10,7 @@ pub trait Purrchance {
|
||||||
fn eval(&self, g: &Grammar) -> Option<String>;
|
fn eval(&self, g: &Grammar) -> Option<String>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Symbol {
|
pub enum Symbol {
|
||||||
Terminal(String),
|
Terminal(String),
|
||||||
NonTerminal(String),
|
NonTerminal(String),
|
||||||
|
@ -25,7 +25,7 @@ impl Purrchance for Symbol {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Expr(Vec<Symbol>);
|
pub struct Expr(Vec<Symbol>);
|
||||||
|
|
||||||
impl Purrchance for Expr {
|
impl Purrchance for Expr {
|
||||||
|
@ -34,7 +34,7 @@ impl Purrchance for Expr {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct List(Vec<(Expr, f64)>);
|
pub struct List(Vec<(Expr, f64)>);
|
||||||
|
|
||||||
impl Purrchance for List {
|
impl Purrchance for List {
|
||||||
|
@ -43,7 +43,7 @@ impl Purrchance for List {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Grammar(HashMap<String,List>);
|
pub struct Grammar(HashMap<String,List>);
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
Loading…
Reference in a new issue