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:
2025-08-09 11:10:34 +01:00
parent d3ace298d3
commit b765e406c7
8 changed files with 20 additions and 14 deletions

View File

@@ -5,8 +5,13 @@ struct
val final = 2
fun makeStart i =
let val chr = Char.chr i
in if chr = #"{" orelse chr = #"}" then final else dead
let
val chr = Char.chr i
in
if chr = #"{" orelse chr = #"}" orelse chr = #"[" orelse chr = #"]" then
final
else
dead
end
val deadTable = SpaceDfa.deadTable

View File

@@ -26,6 +26,8 @@ struct
else if min = lastBrace then
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.L_BRACKET :: acc)
else if str = "]" then SOME (lastBrace, T.R_BRACKET :: acc)
else NONE
else
NONE

View File

@@ -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.
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)+
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`.

View File

@@ -1,7 +1,2 @@
structure Tokens =
struct
datatype t =
L_BRACE
| R_BRACE
| INT of int
end
struct datatype t = L_BRACE | R_BRACE | L_BRACKET | R_BRACKET | INT of int end