1
0
Fork 0
mirror of https://github.com/MillironX/XAM.jl.git synced 2024-11-23 10:19:56 +00:00

Correct header parsing

This commit is contained in:
Ciarán O'Mara 2020-03-21 16:49:15 +11:00
parent e69c6de586
commit d0e2560ec4

View file

@ -165,15 +165,8 @@ function appendfrom!(dst, dpos, src, spos, n)
return dst return dst
end end
const sam_actions_metainfo = Dict( const action_metainfo = quote
:mark => :(@mark),
:pos1 => :(pos1 = @relpos(p)),
:pos2 => :(pos2 = @relpos(p)),
:metainfo_tag => :(metainfo.tag = pos1:@relpos(p-1)),
:metainfo_val => :(metainfo.val = pos1:@relpos(p-1)),
:metainfo_dict_key => :(push!(metainfo.dictkey, pos2:@relpos(p-1))),
:metainfo_dict_val => :(push!(metainfo.dictval, pos2:@relpos(p-1))),
:metainfo => quote
let markpos = @markpos() let markpos = @markpos()
appendfrom!(metainfo.data, 1, data, markpos, length(markpos:p-1)) appendfrom!(metainfo.data, 1, data, markpos, length(markpos:p-1))
@ -182,13 +175,29 @@ const sam_actions_metainfo = Dict(
found_metainfo = true found_metainfo = true
end end
end
end
const sam_actions_metainfo = Dict(
:mark => :(@mark),
:pos1 => :(pos1 = @relpos(p)),
:pos2 => :(pos2 = @relpos(p)),
:metainfo_tag => :(metainfo.tag = pos1:@relpos(p-1)),
:metainfo_val => :(metainfo.val = pos1:@relpos(p-1)),
:metainfo_dict_key => :(push!(metainfo.dictkey, pos2:@relpos(p-1))),
:metainfo_dict_val => :(push!(metainfo.dictval, pos2:@relpos(p-1))),
:metainfo => action_metainfo
) )
const sam_actions_header = merge( const sam_actions_header = merge(
sam_actions_metainfo, sam_actions_metainfo,
Dict( Dict(
:countline => :(linenum += 1), :countline => :(linenum += 1),
:metainfo => quote
$(action_metainfo)
push!(header, metainfo)
metainfo = MetaInfo()
end,
:header => quote :header => quote
finish_header = true finish_header = true
@ -309,13 +318,6 @@ const sam_loopcode_header = quote
throw(ArgumentError("malformed metainfo at line $(linenum)")) throw(ArgumentError("malformed metainfo at line $(linenum)"))
end end
if found_metainfo
push!(header, metainfo)
found_metainfo = false
end
metainfo = MetaInfo()
if finish_header if finish_header
@goto __return__ @goto __return__
end end