From c59a1576755f109e989545e2510a433487b4ec3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciar=C3=A1n=20O=27Mara?= Date: Tue, 27 Aug 2019 08:52:35 +1000 Subject: [PATCH] Quick fix for BioCore.Ragel.State This fix is likely to be replaced when migrating to TranscodingStreams. --- src/sam/reader.jl | 4 ++-- src/sam/sam.jl | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) 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")