diff options
Diffstat (limited to 'lib/configuration/syntax.ml')
-rw-r--r-- | lib/configuration/syntax.ml | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/lib/configuration/syntax.ml b/lib/configuration/syntax.ml deleted file mode 100644 index ee47277..0000000 --- a/lib/configuration/syntax.ml +++ /dev/null @@ -1,93 +0,0 @@ -open StdLabels -module E = ImportExpression.T -module Table = ImportDataTypes.Table -module Path = ImportDataTypes.Path - -let toml_of_table Table.{ file; tab; name } = - let values = [ ("file", Otoml.string file); ("name", Otoml.string name) ] in - let values = - match tab with - | 1 -> values - | tab -> ("tab", Otoml.integer tab) :: values - in - - Otoml.table values - -module Extern = struct - type t = { - intern_key : Path.t E.t; - target : Table.t; - extern_key : Path.column E.t; - allow_missing : bool; - match_rule : string option; - } - [@@deriving show, eq] - (** Describe a relation beteween two tables *) - - let toml_of_extern extern = - let values = - [ - ( "intern_key", - Otoml.string - @@ ImportExpression.Repr.repr ~top:true Path.show extern.intern_key ); - ( "extern_key", - Otoml.string - @@ ImportExpression.Repr.repr ~top:true - (fun v -> ":" ^ ImportCSV.Csv.column_to_string v) - extern.extern_key ); - ("file", Otoml.string extern.target.file); - ("allow_missing", Otoml.boolean extern.allow_missing); - ] - in - - let values = - match extern.target.tab with - | 1 -> values - | tab -> ("tab", Otoml.integer tab) :: values - in - - Otoml.table values - - let toml externs = - List.map externs ~f:(fun e -> (e.target.name, toml_of_extern e)) - |> Otoml.table -end - -type t = { - version : int; - locale : string option; - source : Table.t; - externals : Extern.t list; - columns : Path.t E.t list; - filters : Path.t E.t list; - sort : Path.t E.t list; - uniq : Path.t E.t list; -} - -let repr t = - let repr_expression_list l = - Otoml.array - (List.map l ~f:(fun v -> - Otoml.string (ImportExpression.Repr.repr ~top:true Path.show v))) - in - - let sheet = - Otoml.table - [ - ("columns", repr_expression_list t.columns); - ("filters", repr_expression_list t.filters); - ("sort", repr_expression_list t.sort); - ("uniq", repr_expression_list t.uniq); - ] - in - - let values = - [ - ("version", Otoml.integer t.version); - ("source", toml_of_table t.source); - ("externals", Extern.toml t.externals); - ("sheet", sheet); - ] - in - - Otoml.table values |