diff --git a/dotscape b/dotscape index b9f2d3d..cb8b756 100755 Binary files a/dotscape and b/dotscape differ diff --git a/dotscape.mlb b/dotscape.mlb index 9719888..10e6668 100644 --- a/dotscape.mlb +++ b/dotscape.mlb @@ -28,7 +28,7 @@ fcore/browse-mode.sml fcore/app-update.sml (* pure file parsing functions *) -fcore/parse-file.sml +fcore/parser/parser.mlb (* IMPERATIVE SHELL *) $(SML_LIB)/basis/mlton.mlb diff --git a/fcore/parse-file.sml b/fcore/parse-file.sml deleted file mode 100644 index da5fe38..0000000 --- a/fcore/parse-file.sml +++ /dev/null @@ -1,5 +0,0 @@ -structure ParseFile = -struct - (* unimplemented *) - fun parseLine line = NONE -end diff --git a/fcore/parsing/all-dfa.sml b/fcore/parser/all-dfa.sml similarity index 100% rename from fcore/parsing/all-dfa.sml rename to fcore/parser/all-dfa.sml diff --git a/fcore/parsing/brace-dfa.sml b/fcore/parser/brace-dfa.sml similarity index 100% rename from fcore/parsing/brace-dfa.sml rename to fcore/parser/brace-dfa.sml diff --git a/fcore/parsing/int-dfa.sml b/fcore/parser/int-dfa.sml similarity index 100% rename from fcore/parsing/int-dfa.sml rename to fcore/parser/int-dfa.sml diff --git a/fcore/parsing/lexer.sml b/fcore/parser/lexer.sml similarity index 100% rename from fcore/parsing/lexer.sml rename to fcore/parser/lexer.sml diff --git a/fcore/parsing/parse-grid.sml b/fcore/parser/parse-grid.sml similarity index 71% rename from fcore/parsing/parse-grid.sml rename to fcore/parser/parse-grid.sml index 4eae661..84aabb0 100644 --- a/fcore/parsing/parse-grid.sml +++ b/fcore/parser/parse-grid.sml @@ -3,24 +3,23 @@ struct fun make (canvasWidth, canvasHeight) = let val maxPoints = Int.max (canvasWidth, canvasHeight) - val emptyYAxis = Vector.tabulate (maxPoints, fn _ => - {r = 0, g = 0, b = 0, a = 0}) + val emptyYAxis = Vector.tabulate (maxPoints, fn _ => {r = 0, g = 0, b = 0, a = 0}) in Vector.tabulate (maxPoints, fn _ => emptyYAxis) end local fun loopY (yAxis, x, ex, y, ey, colour) = - if y > ey then - yAxis + if y > ey then yAxis else - let val yAxis = Vector.update (yAxis, y, colour) - in loopY (yAxis, x, ex, y + 1, ey, colour) + let + val yAxis = Vector.update (yAxis, y, colour) + in + loopY (yAxis, x, ex, y + 1, ey, colour) end fun loopX (grid, x, ex, y, ey, colour) = - if x > ex then - grid + if x > ex then grid else let val yAxis = Vector.sub (grid, x) diff --git a/fcore/parsing/parsing.md b/fcore/parser/parser.md similarity index 100% rename from fcore/parsing/parsing.md rename to fcore/parser/parser.md diff --git a/fcore/parsing/parser.mlb b/fcore/parser/parser.mlb similarity index 100% rename from fcore/parsing/parser.mlb rename to fcore/parser/parser.mlb diff --git a/fcore/parsing/parser.sml b/fcore/parser/parser.sml similarity index 100% rename from fcore/parsing/parser.sml rename to fcore/parser/parser.sml diff --git a/fcore/parsing/space-dfa.sml b/fcore/parser/space-dfa.sml similarity index 100% rename from fcore/parsing/space-dfa.sml rename to fcore/parser/space-dfa.sml diff --git a/fcore/parser/tokens.sml b/fcore/parser/tokens.sml new file mode 100644 index 0000000..965ef34 --- /dev/null +++ b/fcore/parser/tokens.sml @@ -0,0 +1,7 @@ +structure Tokens = +struct + datatype t = + L_BRACE + | R_BRACE + | INT of int +end diff --git a/fcore/parsing/tokens.sml b/fcore/parsing/tokens.sml deleted file mode 100644 index a5021c7..0000000 --- a/fcore/parsing/tokens.sml +++ /dev/null @@ -1 +0,0 @@ -structure Tokens = struct datatype t = L_BRACE | R_BRACE | INT of int end diff --git a/fcore/quad-tree.sml b/fcore/quad-tree.sml index 4d03872..de0e144 100644 --- a/fcore/quad-tree.sml +++ b/fcore/quad-tree.sml @@ -500,4 +500,39 @@ struct in Vector.concat vec end + + fun toStringFolder ({x, ex, y, ey, data = {r, g, b, a}}, acc) = + let + val item = String.concat + [ "{" + , Int.toString x + , " " + , Int.toString y + , " " + , Int.toString ex + , " " + , Int.toString ey + , " " + , Int.toString r + , " " + , Int.toString g + , " " + , Int.toString b + , " " + , Int.toString a + , " }" + ] + in + item :: acc + end + + fun toString (squares, size) = + let + val qtree = buildTree (0, 0, size, squares) + val bintree = merge (qtree, squares) + + val vec = BinTree.foldr (toStringFolder, bintree, []) + in + Vector.concat vec + end end