`Automa.execute` gives wrong result in some case
Closed this issue · 1 comments
Kolaru commented
When usinge for example RegExp.rep
I get re.rep("a")
to parse "aYa"
through Automa.execute
:
using Automa
import Automa.RegExp: @re_str
const re = Automa.RegExp
a = re"a"
a.actions[:exit] = [:a]
withrep = Automa.compile(re.rep(a))
Automa.execute(withrep, "aYa") # return (0, [:a, :a])
Actually generating the machine code and executing correctly fails to parse "aYa"
. I believe the following should do the exact same thing as Automa.execute
:
context = Automa.CodeGenContext()
@eval function test_func(data)
$(Automa.generate_init_code(context, test))
p_end = p_eof = lastindex(data)
as = []
emit() = push!(as, :a)
$(Automa.generate_exec_code(context, test, Dict(:a => :(emit()))))
return cs, as
end
test_func("aYa") # (-2, Any[])
test_func("aa") # (0, Any["a", "a"])
I'm using Automa 0.8.2.
jakobnissen commented
Fixed in #79.
The fix is a single line, so you can add it to your own code if you want.