diff --git a/src/codegen.jl b/src/codegen.jl index 97e38c8b..187f12bd 100644 --- a/src/codegen.jl +++ b/src/codegen.jl @@ -212,8 +212,6 @@ function generate_goto_code(machine::Machine, actions::Dict{Symbol,Expr}, check: if p > p_eof ≥ 0 && cs ∈ $(machine.final_states) $(eof_action_code) cs = 0 - elseif cs < 0 - p -= 1 end end end diff --git a/test/runtests.jl b/test/runtests.jl index c73838b2..5d9588b4 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -715,6 +715,39 @@ module Test13 @test validate(b"abrad") == ([], :error) end +module Test14 + import Automa + import Automa.RegExp: @re_str + const re = Automa.RegExp + using Base.Test + + a = re"a*" + machine = Automa.compile(a) + @eval function validate_table(data) + $(Automa.generate_init_code(machine)) + p_end = p_eof = sizeof(data) + $(Automa.generate_exec_code(machine, code=:table)) + return p, cs + end + @eval function validate_inline(data) + $(Automa.generate_init_code(machine)) + p_end = p_eof = sizeof(data) + $(Automa.generate_exec_code(machine, code=:inline)) + return p, cs + end + @eval function validate_goto(data) + $(Automa.generate_init_code(machine)) + p_end = p_eof = sizeof(data) + $(Automa.generate_exec_code(machine, code=:goto)) + return p, cs + end + + @test validate_table(b"") == validate_inline(b"") == validate_goto(b"") + @test validate_table(b"a") == validate_inline(b"a") == validate_goto(b"a") + @test validate_table(b"b") == validate_inline(b"b") == validate_goto(b"b") + @test validate_table(b"ab") == validate_inline(b"ab") == validate_goto(b"ab") +end + module TestDOT import Automa import Automa.RegExp: @re_str