fix lexer/parser bugs, add code in file-thread.sml to handle loading/saving of files (but loading is not completely finished yet)
This commit is contained in:
@@ -18,18 +18,21 @@ struct
|
||||
end
|
||||
| _ => SOME (tokens, grid)
|
||||
|
||||
fun parse tokens =
|
||||
case tokens of
|
||||
T.INT canvasWidth :: T.INT canvasHeight :: T.L_BRACE :: tl =>
|
||||
let
|
||||
val grid = ParseGrid.make (canvasWidth, canvasHeight)
|
||||
in
|
||||
case parseItems (tl, grid) of
|
||||
SOME (tokens, grid) =>
|
||||
(case tokens of
|
||||
[T.R_BRACE] => SOME grid
|
||||
| _ => NONE)
|
||||
| NONE => NONE
|
||||
end
|
||||
| _ => NONE
|
||||
fun parse string =
|
||||
case Lexer.scan string of
|
||||
SOME tokens =>
|
||||
(case tokens of
|
||||
T.INT canvasWidth :: T.INT canvasHeight :: T.L_BRACE :: tl =>
|
||||
let
|
||||
val grid = ParseGrid.make (canvasWidth, canvasHeight)
|
||||
in
|
||||
case parseItems (tl, grid) of
|
||||
SOME (tokens, grid) =>
|
||||
(case tokens of
|
||||
[T.R_BRACE] => SOME (canvasWidth, canvasHeight, grid)
|
||||
| _ => NONE)
|
||||
| NONE => NONE
|
||||
end
|
||||
| _ => NONE)
|
||||
| NONE => NONE
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user