From 2a664a47c73e232b6ff0d261833e2561d4abc4d0 Mon Sep 17 00:00:00 2001 From: Marc Coquand Date: Tue, 26 Dec 2023 10:46:11 -0600 Subject: Support list --- lib/ast_types.ml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/ast_types.ml') 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 -> [] -- cgit v1.2.3