diff options
author | Philipp Gesang <pgesang@ix.urz.uni-heidelberg.de> | 2010-08-13 14:25:04 +0200 |
---|---|---|
committer | Philipp Gesang <pgesang@ix.urz.uni-heidelberg.de> | 2010-08-13 14:25:04 +0200 |
commit | 731fea55e3c23336abc487907df1d0a9c1ed79d2 (patch) | |
tree | 4fb2f8db64a7aec0b9caca41428b5350c701056c | |
parent | 0424a2a795fb3da1c18284e2c86dc76c9ac4c0d3 (diff) | |
download | automata-backgrounds-731fea55e3c23336abc487907df1d0a9c1ed79d2.tar.gz |
lpegified file loader. stubs for other formats.
-rw-r--r-- | life.lua | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -140,12 +140,13 @@ function gol.apply_rule (cell, cnt, rule, fade, keep) return new end +gol.formats = {} -function gol.parse_file (fname) +gol.formats[".gol"] = function (fname) local tmp = {} -- return an array local len -- check for equal line length - if fname:sub(-4,-1) ~= ".gol" then -- check extension + if fname:sub(-4,-1) ~= ".gol" then fname = fname .. ".gol" end @@ -177,6 +178,16 @@ function gol.parse_file (fname) end end + +function gol.parse_file (fname) + local p_suf = P"." * (1-P".")^3 * -P(1) + local p_fn = (1-p_suf)^1 * C(p_suf) + local suffix = p_fn:match(fname) or ".gol" -- assume .gol format as default + + return gol.formats[suffix] ( fname ) +end + + --- Computing single lines and whole frames and intervals thereof function gol.next_line (rows, rule) |