From 1f1c0849523273ab7db3f376addfd03ad84bbab6 Mon Sep 17 00:00:00 2001 From: Tilman Hinnerichs Date: Tue, 14 May 2024 15:57:06 +0200 Subject: [PATCH] Add typecheck for right hande side of rules + check equality with == --- src/grammar_base.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/grammar_base.jl b/src/grammar_base.jl index 14e140c..ef99883 100644 --- a/src/grammar_base.jl +++ b/src/grammar_base.jl @@ -214,7 +214,7 @@ function add_rule!(g::AbstractGrammar, e::Expr) # Only add a rule if it does not exist yet. Check for existance # with strict equality so that true and 1 are not considered # equal. that means we can't use `in` or `∈` for equality checking. - if !any(r === rule for rule ∈ g.rules) + if !any(r === rule || typeof(r)==Expr && r == rule for rule ∈ g.rules) push!(g.rules, r) push!(g.iseval, iseval(rule)) push!(g.types, s)