andrewcooke / ParserCombinator.jl

A parser combinator library for Julia
Other
107 stars 20 forks source link

GML parsing error: Underscore in key name #32

Open diegozea opened 5 years ago

diegozea commented 5 years ago

I have a GML file that has underscores in key names:


        graph [
            directed 1
            id 42
            label "splice graph of s-exons"

                node [
                    id 1
                    label "start"
                    conservation 100.0
                    transcript_fraction 100.0
                    genes "ENSBTAG00000007876,ENSG00000107643,ENSGGOG00000011771,ENSMMUG00000004060,ENSMODG00000002193,ENSMUSG00000021936,ENSOANG00000012095,ENSRNOG00000020155,ENSSSCG00000010380,ENSXETG00000021691"            
                ]
.
.
.

This is failing with the following error:

ParserError{Int64}("Expected ] at (11,21)\n                    transcript_fraction 100.0\n                    ^\n", 253)

Stacktrace:
 [1] check_channel_state at ./channels.jl:125 [inlined]
 [2] take_unbuffered(::Channel{Any}) at ./channels.jl:327
 [3] take! at ./channels.jl:315 [inlined]
 [4] iterate(::Channel{Any}, ::Nothing) at ./channels.jl:395
 [5] iterate at ./channels.jl:394 [inlined]
 [6] once at /home/elin/.julia/packages/ParserCombinator/Rc0cd/src/core/parsers.jl:184 [inlined]
 [7] #single_result#36 at /home/elin/.julia/packages/ParserCombinator/Rc0cd/src/core/parsers.jl:192 [inlined]
 [8] (::getfield(ParserCombinator, Symbol("#kw##single_result#38")))(::NamedTuple{(:debug,),Tuple{Bool}}, ::getfield(ParserCombinator, Symbol("#single_result#38")){getfield(ParserCombinator, Symbol("##single_result#36#37")){Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},UnionAll}}, ::String, ::Trace) at ./none:0
 [9] #parse_raw#6(::Bool, ::Function, ::String) at /home/elin/.julia/packages/ParserCombinator/Rc0cd/src/gml/GML.jl:80
 [10] #parse_raw at ./none:0 [inlined]
 [11] #parse_dict#9(::Bool, ::Array{Symbol,1}, ::Bool, ::Function, ::String) at /home/elin/.julia/packages/ParserCombinator/Rc0cd/src/gml/GML.jl:162
 [12] parse_dict(::String) at /home/elin/.julia/packages/ParserCombinator/Rc0cd/src/gml/GML.jl:162
 [13] loadgml(::IOStream, ::String) at /home/elin/.julia/packages/GraphIO/IpSAL/src/GML/Gml.jl:33
 [14] loadgraph at /home/elin/.julia/packages/GraphIO/IpSAL/src/GML/Gml.jl:95 [inlined]
 [15] #119 at /home/elin/.julia/packages/LightGraphs/HsNig/src/persistence/common.jl:15 [inlined]
 [16] #open#310(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::getfield(LightGraphs, Symbol("##119#120")){String,GraphIO.GML.GMLFormat}, ::String, ::Vararg{String,N} where N) at ./iostream.jl:369
 [17] open at ./iostream.jl:367 [inlined]
 [18] loadgraph(::String, ::String, ::GraphIO.GML.GMLFormat) at /home/elin/.julia/packages/LightGraphs/HsNig/src/persistence/common.jl:14
 [19] top-level scope at In[17]:1

I think that the problem is that the key regex doesn't support underscores:

"[a-zA-Z][a-zA-Z0-9]*"

Is there ir a reason to avoid underscore (or other symbols) in key names?