From 8b8b730d3ba98d6c9e4e6274844641043b5fefbb Mon Sep 17 00:00:00 2001
From: Sébastien Dailly <sebastien@dailly.me>
Date: Mon, 17 Mar 2025 09:11:25 +0100
Subject: Moved the syntax module in its own library

---
 lib/analysers/dependency.ml | 36 +++++++++++++++++++++---------------
 1 file changed, 21 insertions(+), 15 deletions(-)

(limited to 'lib/analysers/dependency.ml')

diff --git a/lib/analysers/dependency.ml b/lib/analysers/dependency.ml
index d0ea8b3..38bc23c 100644
--- a/lib/analysers/dependency.ml
+++ b/lib/analysers/dependency.ml
@@ -1,6 +1,5 @@
 open StdLabels
 module IntSet = ImportContainers.IntSet
-module Syntax = ImportConf.Syntax
 module Table = ImportDataTypes.Table
 module Path = ImportDataTypes.Path
 module Expression = ImportExpression.T
@@ -61,11 +60,15 @@ type 'a expression_extractor = {
     The function may raise [Unknown_source] if the the path describe an unknown
     table. *)
 let add_path_in_map :
-    f:'a expression_extractor -> conf:Syntax.t -> 'a -> build_map -> build_map =
+    f:'a expression_extractor ->
+    conf:ImporterSyntax.t ->
+    'a ->
+    build_map ->
+    build_map =
  fun ~f ~conf path map ->
   let table_source, column = f.of_path path in
   let table =
-    try ImportConf.get_table_for_name conf table_source with
+    try ImporterSyntax.get_table_for_name conf table_source with
     | Not_found -> raise (ImportErrors.Unknown_source (Option.get table_source))
   in
 
@@ -81,7 +84,7 @@ let add_path_in_map :
 
 let add_expression_in_map :
     f:'a expression_extractor ->
-    conf:Syntax.t ->
+    conf:ImporterSyntax.t ->
     'a Expression.t ->
     build_map ->
     build_map =
@@ -91,7 +94,7 @@ let add_expression_in_map :
 
 let add_columns_in_map :
     f:'a expression_extractor ->
-    conf:Syntax.t ->
+    conf:ImporterSyntax.t ->
     'a Expression.t list ->
     build_map ->
     build_map =
@@ -109,9 +112,9 @@ let add_columns_in_map :
 
    This function is called for each path declared inside the expression. *)
 let add_dependancies :
-    conf:Syntax.t -> Syntax.Extern.t -> deps -> Path.t -> deps =
+    conf:ImporterSyntax.t -> ImporterSyntax.Extern.t -> deps -> Path.t -> deps =
  fun ~conf extern graph path ->
-  let source_table = ImportConf.get_table_for_name conf path.Path.alias in
+  let source_table = ImporterSyntax.get_table_for_name conf path.Path.alias in
 
   let source = ImportContainers.Source.from_table source_table in
   let target = ImportContainers.Source.from_table extern.target in
@@ -121,14 +124,17 @@ let add_dependancies :
   | _ -> (target, [ source ]) :: graph
 
 let add_external_in_map :
-    conf:Syntax.t -> Syntax.Extern.t -> build_map * deps -> build_map * deps =
+    conf:ImporterSyntax.t ->
+    ImporterSyntax.Extern.t ->
+    build_map * deps ->
+    build_map * deps =
  fun ~conf extern (map, graph) ->
   let dest = ImportContainers.KeyName.from_table extern.target in
   (* Pre-check that every source is already declared in the configuration. *)
   let _ =
     Expression.fold_values extern.intern_key ~init:() ~f:(fun () path ->
         try
-          let _ = ImportConf.get_table_for_name conf path.Path.alias in
+          let _ = ImporterSyntax.get_table_for_name conf path.Path.alias in
           ()
         with
         | Not_found -> (
@@ -177,7 +183,7 @@ let add_external_in_map :
         {
           of_path =
             (fun Path.{ alias; column } ->
-              let table = ImportConf.get_table_for_name conf alias in
+              let table = ImporterSyntax.get_table_for_name conf alias in
               (Some table.name, column));
           to_mapping =
             (fun mapping column ->
@@ -194,11 +200,11 @@ let mapper =
     of_path = (fun ({ alias; column } : Path.t) -> (alias, column));
   }
 
-let get_mapping : Syntax.t -> build_map * deps =
+let get_mapping : ImporterSyntax.t -> build_map * deps =
  fun conf ->
-  let root = ImportContainers.Source.from_table (ImportConf.root_table conf)
+  let root = ImportContainers.Source.from_table (ImporterSyntax.root_table conf)
   and root' =
-    ImportContainers.KeyName.from_table (ImportConf.root_table conf)
+    ImportContainers.KeyName.from_table (ImporterSyntax.root_table conf)
   in
   let graph = [ (root, []) ] in
 
@@ -207,7 +213,7 @@ let get_mapping : Syntax.t -> build_map * deps =
   let init =
     ( ImportContainers.Externals.singleton root'
         {
-          table = ImportConf.root_table conf;
+          table = ImporterSyntax.root_table conf;
           columns = IntSet.empty;
           keys = [];
         },
@@ -229,7 +235,7 @@ let get_mapping : Syntax.t -> build_map * deps =
   in
   (map, graph)
 
-let get_process_order : Syntax.t -> t list =
+let get_process_order : ImporterSyntax.t -> t list =
  fun map ->
   let map, graph = get_mapping map in
 
-- 
cgit v1.2.3