Skip to content

Commit

Permalink
Use glc 0.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
yds12 committed Aug 20, 2023
1 parent 71a7384 commit 9fa7c0b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ float-cmp = "0.9"
meval = "0.2"
fasteval = "0.2"
evalexpr = "8.1"
glc = "0.4"
glc = "0.4.2"

[[bench]]
name = "benchmarks"
Expand Down
66 changes: 32 additions & 34 deletions tests/integration.rs
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
use glc::{nt_seq_rule, t_or_rule, Expression, Grammar};
#![recursion_limit = "256"]
use glc::{grammar, Expression, Grammar};

fn grammar() -> Grammar {
Grammar(
"E".into(),
vec![
nt_seq_rule!("E" => "T", "E'"),
nt_seq_rule!("E'" => "PM", "T", "E'"),
t_or_rule!("E'" => ""),
t_or_rule!("E'" => ""), // increase prob. by duplicating rule
t_or_rule!("E'" => ""), // increase prob. by duplicating rule
t_or_rule!("PM" => "+", "-"),
nt_seq_rule!("T" => "F", "T'"),
nt_seq_rule!("T'" => "MD", "F", "T'"),
t_or_rule!("MD" => "*", "/"),
t_or_rule!("T'" => ""),
t_or_rule!("T'" => ""), // increase prob.
t_or_rule!("T'" => ""), // increase prob.
nt_seq_rule!("F" => "LP", "E", "RP"),
nt_seq_rule!("F" => "M", "LP", "E", "RP"),
nt_seq_rule!("F" => "N"),
nt_seq_rule!("F" => "M", "N"),
t_or_rule!("LP" => "("),
t_or_rule!("RP" => ")"),
t_or_rule!("M" => "-"),
nt_seq_rule!("N" => "D", "DEC"),
nt_seq_rule!("D" => "D", "OD"),
nt_seq_rule!("OD" => "D"),
t_or_rule!("OD" => ""),
t_or_rule!("OD" => ""), // increase probability
t_or_rule!("OD" => ""), // increase probability
t_or_rule!("D" => "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"),
nt_seq_rule!("DEC" => "P", "D"),
t_or_rule!("P" => "."),
],
)
grammar!{
E => T E_;
E_ => PM T E_;
E_ => "";
E_ => "";
E_ => "";
PM => "+", "-";
T => F T_;
T_ => MD F T_;
MD => "*", "/";
T_ => "";
T_ => "";
T_ => "";
F => LP E RP;
F => M LP E RP;
F => N;
F => M N;
LP => "(";
RP => ")";
M => "-";
N => D DEC;
D => D OD;
OD => D;
OD => "";
OD => "";
OD => "";
D => "0", "1", "2", "3", "4", "5", "6", "7", "8", "9";
DEC => P D;
P => "."
}
}

#[test]
Expand Down

0 comments on commit 9fa7c0b

Please sign in to comment.