mirror of
https://github.com/kalmarek/SmallHyperbolic
synced 2024-11-23 23:40:28 +01:00
add new parsing of presentation
This commit is contained in:
parent
1899c7b5d8
commit
b8ed94adf3
28
data/parse_presentations.jl
Normal file
28
data/parse_presentations.jl
Normal 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
|
Loading…
Reference in New Issue
Block a user