I am trying to define a boolean expression grammar which has changing rules. I would like to reference a vector of strings, to then change certain production rules of the grammar.
The following minimal working example is how the examples provided by the package suggest one defines a grammar:
using ExprRules
using ExprOptimization
grammarExample = @grammar begin
bexp = (bexp)
bexp = !bexp
bexp = bexp && bexp
bexp = bexp || bexp
bexp = true
bexp = false
bexp = |(a,b,c)
end
S = SymbolTable(grammarExample)
tree = RuleNode(3, [RuleNode(7), RuleNode(8)])
ex = get_executable(tree, grammarExample)
S[:a] = true
S[:b] = true
Core.eval(S, ex)
I would like to do the following:
using ExprRules
using ExprOptimization
vect = ["a","b","c"]
grammarExample = @grammar begin
bexp = (bexp)
bexp = !bexp
bexp = bexp && bexp
bexp = bexp || bexp
bexp = true
bexp = false
bexp = |(vect[:])
end
S = SymbolTable(grammarExample)
tree = RuleNode(3, [RuleNode(7), RuleNode(8)])
ex = get_executable(tree, grammarExample)
S[:a] = true
S[:b] = true
Core.eval(S, ex)
The resulting grammar and the SymbolTable seem to be the same in both cases, but the Core.eval(S, ex)
gives the following error:
LoadError: TypeError: non-boolean (String) used in boolean context
Stacktrace:
[1] interpret(tab::Dict{Symbol, Any}, ex::Expr)
@ ExprRules.Interpreter ~/.julia/packages/ExprRules/uZyj0/src/interpreter.jl:62
[2] eval(tab::Dict{Symbol, Any}, ex::Expr)
@ ExprRules ~/.julia/packages/ExprRules/uZyj0/src/ExprRules.jl:417