Skip to content

Commit 8be6d01

Browse files
committed
Update interpret_sygus
1 parent ddc9b76 commit 8be6d01

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

src/data/SyGuS/PBE_SLIA_Track_2019/string_functions.jl

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,13 @@ leq_cvc(str1::String, str2::String) = cmp(str1, str2) <= 0
3232

3333
isdigit_cvc(str::String) = tryparse(Int, str) !== nothing
3434

35+
3536
"""
36-
Gets the relevant symbol to easily match grammar rules to operations in `interpret` function
37-
"""
38-
function get_relevant_tags(grammar::ContextSensitiveGrammar)
39-
tags = Dict{Int,Any}()
40-
for (ind, r) in pairs(grammar.rules)
41-
tags[ind] = if typeof(r) != Expr
42-
r
43-
else
44-
@match r.head begin
45-
:block => :OpSeq
46-
:call => r.args[1]
47-
:if => :IF
48-
end
49-
end
50-
end
51-
return tags
52-
end
37+
interpret_sygus(prog::AbstractRuleNode, grammar_tags::Dict{Int,Any}, input::Dict{Symbol,Any})
5338
54-
function interpret_sygus(prog::AbstractRuleNode, grammar_tags::Dict{Int,Any})
39+
Custom intepret function for the SyGuS SLIA benchmark.
40+
"""
41+
function interpret_sygus(prog::AbstractRuleNode, grammar_tags::Dict{Int,Any}, input::Dict{Symbol,Any})
5542
r = get_rule(prog)
5643
c = get_children(prog)
5744

@@ -74,6 +61,16 @@ function interpret_sygus(prog::AbstractRuleNode, grammar_tags::Dict{Int,Any})
7461

7562
:IF => interpret_sygus(c[1], grammar_tags) ? interpret_sygus(c[2], grammar_tags) : interpret_sygus(c[3], grammar_tags)
7663

77-
_ => grammar_tags[r]
64+
_ =>
65+
begin
66+
tag = grammar_tags[r]
67+
if tag isa Symbol && occursin("_arg_", String(tag))
68+
# This is an input variable; look it up in the environment
69+
return input[tag]
70+
else
71+
# default behavior
72+
return tag
73+
end
74+
end
7875
end
7976
end

0 commit comments

Comments
 (0)