diff options
author | Chimrod <> | 2024-12-14 23:06:12 +0100 |
---|---|---|
committer | Chimrod <> | 2025-01-03 15:05:00 +0100 |
commit | 75f3eabb46eded01460f7700a75d094100047438 (patch) | |
tree | 4dcee7d2fc9310ff41776d9df8986f5efa0db229 /lib/syntax | |
parent | 289dc576624d4233116806e566bb791fee1de178 (diff) |
Diffstat (limited to 'lib/syntax')
-rw-r--r-- | lib/syntax/S.ml | 11 | ||||
-rw-r--r-- | lib/syntax/catalog.ml | 36 | ||||
-rw-r--r-- | lib/syntax/catalog.mli | 6 | ||||
-rw-r--r-- | lib/syntax/dune | 4 |
4 files changed, 35 insertions, 22 deletions
diff --git a/lib/syntax/S.ml b/lib/syntax/S.ml index 918d8e6..a3c74ca 100644 --- a/lib/syntax/S.ml +++ b/lib/syntax/S.ml @@ -8,11 +8,20 @@ (** {1 Generic types used in the module} *) -type pos = Lexing.position * Lexing.position +type position = Lexing.position = { + pos_fname : string; + pos_lnum : int; + pos_bol : int; + pos_cnum : int; +} +[@@deriving eq, ord] + +type pos = position * position [@@deriving eq, ord] (** The type pos is used to track the starting and ending position for the given location. *) type ('a, 'b) variable = { pos : 'a; name : string; index : 'b option } +[@@deriving eq, ord] (** Describe a variable, using the name in capitalized text, and an optionnal index. diff --git a/lib/syntax/catalog.ml b/lib/syntax/catalog.ml index b516976..5ad0bbd 100644 --- a/lib/syntax/catalog.ml +++ b/lib/syntax/catalog.ml @@ -18,31 +18,31 @@ type ex = -> ex (** Type of check to apply *) let build : + ?location_id:'a Type.Id.t -> + ?context_id:'b Type.Id.t -> (module S.Analyzer with type Expression.t = _ and type Expression.t' = _ and type Instruction.t = _ and type Instruction.t' = _ and type Location.t = 'a - and type context = _) -> - 'a Type.Id.t * ex = - fun module_ -> + and type context = 'b) -> + ex = + fun ?location_id ?context_id module_ -> let expr_witness = Type.Id.make () and expr' = Type.Id.make () and instr_witness = Type.Id.make () and instr' = Type.Id.make () - and location_witness = Type.Id.make () - and context = Type.Id.make () in - let t = - E - { - module_; - expr_witness; - expr'; - instr_witness; - instr'; - location_witness; - context; - } - in - (location_witness, t) + and location_witness = + match location_id with Some v -> v | None -> Type.Id.make () + and context = match context_id with Some v -> v | None -> Type.Id.make () in + E + { + module_; + expr_witness; + expr'; + instr_witness; + instr'; + location_witness; + context; + } diff --git a/lib/syntax/catalog.mli b/lib/syntax/catalog.mli index a256c17..a386d4a 100644 --- a/lib/syntax/catalog.mli +++ b/lib/syntax/catalog.mli @@ -18,13 +18,15 @@ type ex = -> ex (** Type of check to apply *) val build : + ?location_id:'a Type.Id.t -> + ?context_id:'b Type.Id.t -> (module S.Analyzer with type Expression.t = _ and type Expression.t' = _ and type Instruction.t = _ and type Instruction.t' = _ and type Location.t = 'a - and type context = _) -> - 'a Type.Id.t * ex + and type context = 'b) -> + ex (** Build a new check from a module following S.Analyzer signature. ypeid Return the result type which hold the final result value, and checker itself. *) diff --git a/lib/syntax/dune b/lib/syntax/dune index 666273f..9832809 100644 --- a/lib/syntax/dune +++ b/lib/syntax/dune @@ -2,5 +2,7 @@ (name qsp_syntax) (preprocess (pps - ppx_deriving.show ppx_deriving.enum + ppx_deriving.show + ppx_deriving.enum + ppx_deriving.ord ppx_deriving.eq ))) |