reimplement parsing code (but program does not compile yet because I have to change type of 'USE_SQUARES' constructure)
This commit is contained in:
20
dotscape.mlb
20
dotscape.mlb
@@ -3,6 +3,23 @@ $(SML_LIB)/basis/basis.mlb
|
|||||||
(* FUNCTIONAL CORE *)
|
(* FUNCTIONAL CORE *)
|
||||||
fcore/grid.sml
|
fcore/grid.sml
|
||||||
fcore/layer-tree.sml
|
fcore/layer-tree.sml
|
||||||
|
|
||||||
|
(* parser *)
|
||||||
|
ann
|
||||||
|
"allowVectorExps true"
|
||||||
|
in
|
||||||
|
fcore/parser/space-dfa.sml
|
||||||
|
fcore/parser/int-dfa.sml
|
||||||
|
fcore/parser/brace-dfa.sml
|
||||||
|
fcore/parser/all-dfa.sml
|
||||||
|
end
|
||||||
|
|
||||||
|
fcore/parser/tokens.sml
|
||||||
|
fcore/parser/lexer.sml
|
||||||
|
fcore/parser/parse-grid.sml
|
||||||
|
fcore/parser/parser.sml
|
||||||
|
(* end of parser *)
|
||||||
|
|
||||||
fcore/app-type.sml
|
fcore/app-type.sml
|
||||||
|
|
||||||
ann
|
ann
|
||||||
@@ -30,9 +47,6 @@ fcore/browse-mode.sml
|
|||||||
fcore/move-mode.sml
|
fcore/move-mode.sml
|
||||||
fcore/app-update.sml
|
fcore/app-update.sml
|
||||||
|
|
||||||
(* pure file parsing functions *)
|
|
||||||
fcore/parser/parser.mlb
|
|
||||||
|
|
||||||
(* IMPERATIVE SHELL *)
|
(* IMPERATIVE SHELL *)
|
||||||
$(SML_LIB)/basis/mlton.mlb
|
$(SML_LIB)/basis/mlton.mlb
|
||||||
$(SML_LIB)/cml/cml.mlb
|
$(SML_LIB)/cml/cml.mlb
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ struct
|
|||||||
in NODE {key = minKey, value = grid, left = LEAF, right = LEAF}
|
in NODE {key = minKey, value = grid, left = LEAF, right = LEAF}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fun singleton grid =
|
||||||
|
NODE {key = minKey, value = grid, left = LEAF, right = LEAF}
|
||||||
|
|
||||||
fun insert (newKey, newValue, tree) =
|
fun insert (newKey, newValue, tree) =
|
||||||
case tree of
|
case tree of
|
||||||
LEAF => NODE {key = newKey, value = newValue, left = LEAF, right = LEAF}
|
LEAF => NODE {key = newKey, value = newValue, left = LEAF, right = LEAF}
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ int ::= (0-9)+
|
|||||||
|
|
||||||
item ::= **{** int int int int int int int int **}**
|
item ::= **{** int int int int int int int int **}**
|
||||||
|
|
||||||
grid ::= **[** item **]**
|
layer ::= **[** item **]**
|
||||||
|
|
||||||
grid_list ::= int int **{** (grid)+ **}**
|
layer_tree ::= int int **{** (layer)* **}**
|
||||||
```
|
```
|
||||||
|
|
||||||
The first two `int`s in the grid `int int **{** (item)+ **}**` always follow the order: `canvasWidth canvasHeight`.
|
The first two `int`s in the grid `int int **{** (item)+ **}**` always follow the order: `canvasWidth canvasHeight`.
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
$(SML_LIB)/basis/basis.mlb
|
|
||||||
|
|
||||||
ann
|
|
||||||
"allowVectorExps true"
|
|
||||||
in
|
|
||||||
space-dfa.sml
|
|
||||||
int-dfa.sml
|
|
||||||
brace-dfa.sml
|
|
||||||
all-dfa.sml
|
|
||||||
end
|
|
||||||
|
|
||||||
tokens.sml
|
|
||||||
lexer.sml
|
|
||||||
|
|
||||||
parse-grid.sml
|
|
||||||
parser.sml
|
|
||||||
@@ -18,20 +18,32 @@ struct
|
|||||||
end
|
end
|
||||||
| _ => SOME (tokens, grid)
|
| _ => SOME (tokens, grid)
|
||||||
|
|
||||||
|
fun parseLayers (tokens, canvasWidth, canvasHeight, tree, counter) =
|
||||||
|
let
|
||||||
|
val grid = ParseGrid.make (canvasWidth, canvasHeight)
|
||||||
|
in
|
||||||
|
case parseItems (tokens, grid) of
|
||||||
|
SOME (tokens, grid) =>
|
||||||
|
let val tree = LayerTree.insert (counter, grid, tree)
|
||||||
|
in parseLayers (tokens, canvasWidth, canvasHeight, tree, counter + 1)
|
||||||
|
end
|
||||||
|
| NONE => (tokens, tree)
|
||||||
|
end
|
||||||
|
|
||||||
fun parse string =
|
fun parse string =
|
||||||
case Lexer.scan string of
|
case Lexer.scan string of
|
||||||
SOME tokens =>
|
SOME tokens =>
|
||||||
(case tokens of
|
(case tokens of
|
||||||
T.INT canvasWidth :: T.INT canvasHeight :: T.L_BRACE :: tl =>
|
T.INT canvasWidth :: T.INT canvasHeight :: tl =>
|
||||||
let
|
let
|
||||||
val grid = ParseGrid.make (canvasWidth, canvasHeight)
|
val maxSide = Int.max (canvasWidth, canvasHeight)
|
||||||
|
val tree = LayerTree.init maxSide
|
||||||
|
val (tokens, tree) = parseLayers
|
||||||
|
(tl, canvasWidth, canvasHeight, tree, 1)
|
||||||
in
|
in
|
||||||
case parseItems (tl, grid) of
|
case tokens of
|
||||||
SOME (tokens, grid) =>
|
[T.R_BRACE] => SOME tree
|
||||||
(case tokens of
|
| _ => NONE
|
||||||
[T.R_BRACE] => SOME (canvasWidth, canvasHeight, grid)
|
|
||||||
| _ => NONE)
|
|
||||||
| NONE => NONE
|
|
||||||
end
|
end
|
||||||
| _ => NONE)
|
| _ => NONE)
|
||||||
| NONE => NONE
|
| NONE => NONE
|
||||||
|
|||||||
Reference in New Issue
Block a user