diff --git a/src/sam/reader.jl b/src/sam/reader.jl index 5e4f0ea..1dc206b 100644 --- a/src/sam/reader.jl +++ b/src/sam/reader.jl @@ -2,11 +2,11 @@ # ========= mutable struct Reader <: BioGenerics.IO.AbstractReader - state::BioGenerics.Ragel.State + state::State header::Header function Reader(input::BufferedStreams.BufferedInputStream) - reader = new(BioGenerics.Ragel.State(sam_header_machine.start_state, input), Header()) + reader = new(State(sam_header_machine.start_state, input), Header()) readheader!(reader) reader.state.cs = sam_body_machine.start_state return reader diff --git a/src/sam/sam.jl b/src/sam/sam.jl index f7b6c92..628b085 100644 --- a/src/sam/sam.jl +++ b/src/sam/sam.jl @@ -46,6 +46,21 @@ function unsafe_parse_decimal(::Type{T}, data::Vector{UInt8}, range::UnitRange{I return sign * x end +#TODO: update BioCore.Ragel.State (will likely change with TrnscodingStreams). +import BufferedStreams: BufferedStreams, BufferedInputStream +# A type keeping track of a ragel-based parser's state. +mutable struct State{T<:BufferedInputStream} + stream::T # input stream + cs::Int # current DFA state of Ragel + linenum::Int # line number: parser is responsible for updating this + finished::Bool # true if finished (regardless of where in the stream we are) +end + +function State(initstate::Int, input::BufferedInputStream) + return State(input, initstate, 1, false) +end + + include("flags.jl") include("metainfo.jl") include("record.jl")