1
0
mirror of https://github.com/kalmarek/SmallHyperbolic synced 2024-12-25 02:15:29 +01:00

add new parsing of presentation

This commit is contained in:
Marek Kaluba 2022-01-17 21:49:49 +01:00
parent 1899c7b5d8
commit b8ed94adf3
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15

View File

@ -0,0 +1,28 @@
include("../src/groupparse.jl")
function parse_grouppresentations_abstract(filename::AbstractString)
lines = strip.(readlines(filename))
groups = let t = (; generators = String[], relations = String[])
Dict{String,typeof(t)}()
end
group_regex = r"(?<name>\w.*)\s?:=\s?(?<group_str>Group.*)"
for line in lines
isempty(line) && continue
newline = if iscomment(line)
line[3:end]
else
line[1:end]
end
m = match(group_regex, newline)
if isnothing(m)
@debug "Can't parse line as group presentation \n $line"
continue
else
name = strip(m[:name])
group_str = m[:group_str]
gens, rels = split_magma_presentation(group_str)
groups[name] = (generators = String.(gens), relations = String.(rels))
end
end
return groups
end