change BNF (but not implementation of BNF) for parsing, to handle layers, and also change minimum key in layer tree to be 1
This commit is contained in:
@@ -45,7 +45,7 @@ struct
|
|||||||
, g = 0
|
, g = 0
|
||||||
, b = 0
|
, b = 0
|
||||||
, a = 1
|
, a = 1
|
||||||
, layer = 0
|
, layer = LayerTree.minKey
|
||||||
, layerTree = layerTree
|
, layerTree = layerTree
|
||||||
, modalNum = 0
|
, modalNum = 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -746,7 +746,7 @@ struct
|
|||||||
, modalNum
|
, modalNum
|
||||||
} = app
|
} = app
|
||||||
|
|
||||||
val layer = modalNum
|
val layer = Int.max (modalNum, 1)
|
||||||
in
|
in
|
||||||
{ mode = mode
|
{ mode = mode
|
||||||
, mouseX = mouseX
|
, mouseX = mouseX
|
||||||
@@ -770,7 +770,7 @@ struct
|
|||||||
, a = a
|
, a = a
|
||||||
, layer = layer
|
, layer = layer
|
||||||
, layerTree = layerTree
|
, layerTree = layerTree
|
||||||
, modalNum = modalNum
|
, modalNum = 0
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ structure LayerTree =
|
|||||||
struct
|
struct
|
||||||
datatype t = NODE of {key: int, value: Grid.t, left: t, right: t} | LEAF
|
datatype t = NODE of {key: int, value: Grid.t, left: t, right: t} | LEAF
|
||||||
|
|
||||||
|
val minKey = 1
|
||||||
|
|
||||||
fun init maxSide =
|
fun init maxSide =
|
||||||
let val grid = Grid.makeEmpty maxSide
|
let val grid = Grid.makeEmpty maxSide
|
||||||
in NODE {key = 0, value = grid, left = LEAF, right = LEAF}
|
in NODE {key = minKey, value = grid, left = LEAF, right = LEAF}
|
||||||
end
|
end
|
||||||
|
|
||||||
fun insert (newKey, newValue, tree) =
|
fun insert (newKey, newValue, tree) =
|
||||||
|
|||||||
@@ -5,8 +5,13 @@ struct
|
|||||||
val final = 2
|
val final = 2
|
||||||
|
|
||||||
fun makeStart i =
|
fun makeStart i =
|
||||||
let val chr = Char.chr i
|
let
|
||||||
in if chr = #"{" orelse chr = #"}" then final else dead
|
val chr = Char.chr i
|
||||||
|
in
|
||||||
|
if chr = #"{" orelse chr = #"}" orelse chr = #"[" orelse chr = #"]" then
|
||||||
|
final
|
||||||
|
else
|
||||||
|
dead
|
||||||
end
|
end
|
||||||
|
|
||||||
val deadTable = SpaceDfa.deadTable
|
val deadTable = SpaceDfa.deadTable
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ struct
|
|||||||
else if min = lastBrace then
|
else if min = lastBrace then
|
||||||
if str = "{" then SOME (lastBrace, T.L_BRACE :: acc)
|
if str = "{" then SOME (lastBrace, T.L_BRACE :: acc)
|
||||||
else if str = "}" then SOME (lastBrace, T.R_BRACE :: acc)
|
else if str = "}" then SOME (lastBrace, T.R_BRACE :: acc)
|
||||||
|
else if str = "[" then SOME (lastBrace, T.L_BRACKET :: acc)
|
||||||
|
else if str = "]" then SOME (lastBrace, T.R_BRACKET :: acc)
|
||||||
else NONE
|
else NONE
|
||||||
else
|
else
|
||||||
NONE
|
NONE
|
||||||
|
|||||||
@@ -4,14 +4,16 @@ The parsing functionality is for saving and loading from a custom file format.
|
|||||||
|
|
||||||
The BNF for the custom file format is below.
|
The BNF for the custom file format is below.
|
||||||
|
|
||||||
Terminals are surrounded by `**` to the left and right. (rule)+ means "1 o more".
|
Terminals are surrounded by `**` to the left and right. (rule)+ means "1 or more".
|
||||||
|
|
||||||
```
|
```
|
||||||
int ::= (0-9)+
|
int ::= (0-9)+
|
||||||
|
|
||||||
item ::= **{** int int int int int int int int **}**
|
item ::= **{** int int int int int int int int **}**
|
||||||
|
|
||||||
grid ::= int int **{** (item)+ **}**
|
grid ::= **[** item **]**
|
||||||
|
|
||||||
|
grid_list ::= int int **{** (grid)+ **}**
|
||||||
```
|
```
|
||||||
|
|
||||||
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,7 +1,2 @@
|
|||||||
structure Tokens =
|
structure Tokens =
|
||||||
struct
|
struct datatype t = L_BRACE | R_BRACE | L_BRACKET | R_BRACKET | INT of int end
|
||||||
datatype t =
|
|
||||||
L_BRACE
|
|
||||||
| R_BRACE
|
|
||||||
| INT of int
|
|
||||||
end
|
|
||||||
|
|||||||
Reference in New Issue
Block a user