fix compile errors left in previous commit
This commit is contained in:
@@ -35,7 +35,7 @@ struct
|
||||
SOME (tokens, grid) => loopParseItems (tokens, grid)
|
||||
| NONE => NONE
|
||||
|
||||
fun parseLayers (tokens, canvasWidth, canvasHeight, tree, counter) =
|
||||
fun parseLayer (tokens, canvasWidth, canvasHeight, tree, counter) =
|
||||
case tokens of
|
||||
T.L_BRACKET :: tl =>
|
||||
let
|
||||
@@ -44,12 +44,23 @@ struct
|
||||
case startParseItems (tl, grid) of
|
||||
SOME (T.R_BRACKET :: tl, grid) =>
|
||||
let val tree = LayerTree.insert (counter, grid, tree)
|
||||
in parseLayers (tl, canvasWidth, canvasHeight, tree, counter + 1)
|
||||
in SOME (tl, tree)
|
||||
end
|
||||
| SOME _ => NONE
|
||||
| NONE => (tokens, tree)
|
||||
| NONE => NONE
|
||||
end
|
||||
| _ => (tokens, tree)
|
||||
| _ => NONE
|
||||
|
||||
fun parseLayerLoop (tokens, canvasWidth, canvasHeight, tree, counter) =
|
||||
case parseLayer (tokens, canvasWidth, canvasHeight, tree, counter) of
|
||||
SOME (tl, tree) =>
|
||||
parseLayerLoop (tl, canvasWidth, canvasHeight, tree, counter + 1)
|
||||
| NONE => SOME (tokens, tree)
|
||||
|
||||
fun startParseLayer (tokens, canvasWidth, canvasHeight, tree) =
|
||||
case parseLayer (tokens, canvasWidth, canvasHeight, tree, 1) of
|
||||
SOME (tl, tree) => parseLayerLoop (tl, canvasWidth, canvasHeight, tree, 2)
|
||||
| NONE => NONE
|
||||
|
||||
fun parse string =
|
||||
case Lexer.scan string of
|
||||
@@ -59,12 +70,12 @@ struct
|
||||
let
|
||||
val maxSide = Int.max (canvasWidth, canvasHeight)
|
||||
val tree = LayerTree.init maxSide
|
||||
val (tokens, tree) = parseLayers
|
||||
(tl, canvasWidth, canvasHeight, tree, 1)
|
||||
in
|
||||
case tokens of
|
||||
[T.R_BRACE] => SOME (canvasWidth, canvasHeight, tree)
|
||||
| _ => NONE
|
||||
case startParseLayer (tl, canvasWidth, canvasHeight, tree) of
|
||||
SOME ([T.R_BRACE], tree) =>
|
||||
SOME (canvasWidth, canvasHeight, tree)
|
||||
| SOME _ => NONE
|
||||
| NONE => NONE
|
||||
end
|
||||
| _ => NONE)
|
||||
| NONE => NONE
|
||||
|
||||
Reference in New Issue
Block a user