Allows you do nearly effortlessly generate code from a Machine while disregarding its actions by passing nothing as the actions. This is useful to create validating parsers, e.g. here is a validating FASTA parser which uses the existing FASTX.FASTA.machine and its context.
import Automa
import FASTX
@eval function validate_fasta(data::Vector{UInt8})
$(Automa.generate_init_code(FASTA.context, FASTA.machine))
p_end = p_eof = lastindex(data)
$(Automa.generate_exec_code(FASTA.context, FASTA.machine, nothing))
return iszero(cs)
end
It's much easier to do than building a new machine, the code is smaller, and the machine is faster (the above validator validates a 150 MB FASTA file in 57 ms on my laptop). Remarkably, Automa already had an option to pass nothing as the actions, but it didn't actually work.
Allows you do nearly effortlessly generate code from a
Machine
while disregarding its actions by passingnothing
as the actions. This is useful to create validating parsers, e.g. here is a validating FASTA parser which uses the existingFASTX.FASTA.machine
and its context.It's much easier to do than building a new machine, the code is smaller, and the machine is faster (the above validator validates a 150 MB FASTA file in 57 ms on my laptop). Remarkably,
Automa
already had an option to passnothing
as the actions, but it didn't actually work.