aboutsummaryrefslogtreecommitdiff
path: root/lib/ast_types.ml
diff options
context:
space:
mode:
authorMarc Coquand <marc@mccd.space>2023-12-26 10:46:11 -0600
committerMarc Coquand <marc@mccd.space>2023-12-26 10:46:11 -0600
commit2a664a47c73e232b6ff0d261833e2561d4abc4d0 (patch)
tree8ad1f0c88f6151bff69f63d61e1e447d2ae5b034 /lib/ast_types.ml
parentd96e1839eb800bf26bcc38272072d98af69f5d83 (diff)
downloadfixgen-2a664a47c73e232b6ff0d261833e2561d4abc4d0.tar.gz
fixgen-2a664a47c73e232b6ff0d261833e2561d4abc4d0.tar.bz2
fixgen-2a664a47c73e232b6ff0d261833e2561d4abc4d0.zip
Support list
Diffstat (limited to 'lib/ast_types.ml')
-rw-r--r--lib/ast_types.ml7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/ast_types.ml b/lib/ast_types.ml
index c278d59..c192c60 100644
--- a/lib/ast_types.ml
+++ b/lib/ast_types.ml
@@ -6,6 +6,7 @@ type ast_row =
| Name of string * ast_row
| Int of string * int * int * ast_row
| Const of string * string * ast_row
+ | List of string * string list * ast_row
| Foreign of string * string * string * ast_row
(* parent, row, child_name, row *)
| End
@@ -15,11 +16,16 @@ type ast_table =
| Table of string * int * ast_row * ast_table
| End
[@@deriving show, eq]
+(** In hindsight, this could've been represented as a list of tables instead using separated list command
+ TODO: Rewrite this to use a list of tables instead of a tree *)
let rec print_row = function
| Uuidv4 (s, r) ->
printf "UUIDv4(%s)," s;
print_row r
+ | List (s, l, r) ->
+ printf "List(%s, %s)," s (String.concat ", " l);
+ print_row r
| Const (s, v, r) ->
printf "Const(%s, %s)," s v;
print_row r
@@ -65,6 +71,7 @@ let rec ast_row_to_fixtures = function
| Name (s, r) -> PRow (Fixture.Name s) :: ast_row_to_fixtures r
| Int (s, min, max, r) -> PRow (Fixture.Int (s, min, max)) :: ast_row_to_fixtures r
| Const (s, v, r) -> PRow (Fixture.Const (s, v)) :: ast_row_to_fixtures r
+ | List (s, l, r) -> PRow (Fixture.List (s, l)) :: ast_row_to_fixtures r
| End -> []