References

References

Data

SizedMemory(data)

Create a SizedMemory object from data.

data must implement Automa.pointerstart and Automa.pointerend methods. These are used to get the range of the contiguous data memory of data. These have default methods which uses Base.pointer and Base.sizeof methods. For example, String and Vector{UInt8} support these Base methods.

Note that it is user's responsibility to keep the data object alive during SizedMemory's lifetime because it does not have a reference to the object.

source
Automa.pointerendFunction.
pointerend(data)::Ptr{UInt8}

Return the end position of data.

The default implementation is Automa.pointerstart(data) + sizeof(data) - 1.

source
Automa.pointerstartFunction.
pointerstart(data)::Ptr{UInt8}

Return the start position of data.

The default implementation is convert(Ptr{UInt8}, pointer(data)).

source

Code generator

Variable names used in generated code.

The following variable names may be used in the code.

  • p::Int: current position of data

  • p_end::Int: end position of data

  • p_eof::Int: end position of file stream

  • ts::Int: start position of token (tokenizer only)

  • te::Int: end position of token (tokenizer only)

  • cs::Int: current state

  • data::Any: input data

  • mem::SizedMemory: input data memory

  • byte::UInt8: current data byte

source
CodeGenContext(;
    vars=Variables(:p, :p_end, :p_eof, :ts, :te, :cs, :data, gensym(), gensym()),
    generator=:table,
    checkbounds=true,
    loopunroll=0,
    getbyte=Base.getindex,
    clean=false
)

Create a code generation context.

Arguments

  • vars: variable names used in generated code

  • generator: code generator (:table, :inline or :goto)

  • checkbounds: flag of bounds check

  • loopunroll: loop unroll factor (≥ 0)

  • getbyte: function of byte access (i.e. getbyte(data, p))

  • clean: flag of code cleansing

source
generate_init_code(context::CodeGenContext, machine::Machine)::Expr

Generate variable initialization code.

source
generate_exec_code(ctx::CodeGenContext, machine::Machine, actions=nothing)::Expr

Generate machine execution code with actions.

source