From 9fa7c0b8ecc2dce8d450887ebb5b987577d0f267 Mon Sep 17 00:00:00 2001 From: yds12 Date: Sun, 20 Aug 2023 17:33:42 +0200 Subject: [PATCH] Use glc 0.4.2 --- Cargo.toml | 2 +- tests/integration.rs | 66 +++++++++++++++++++++----------------------- 2 files changed, 33 insertions(+), 35 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 928614a..8bc1f0b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/tests/integration.rs b/tests/integration.rs index ee50587..51dc1fd 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -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]