diff options
Diffstat (limited to 'lib/syntax')
-rw-r--r-- | lib/syntax/S.ml | 27 | ||||
-rw-r--r-- | lib/syntax/catalog.ml | 48 | ||||
-rw-r--r-- | lib/syntax/catalog.mli | 30 |
3 files changed, 90 insertions, 15 deletions
diff --git a/lib/syntax/S.ml b/lib/syntax/S.ml index b467863..918d8e6 100644 --- a/lib/syntax/S.ml +++ b/lib/syntax/S.ml @@ -1,18 +1,16 @@ -(** - This module describe the type an analyzer must implement in order to be - used with the parser. +(** This module describe the type an analyzer must implement in order to be used + with the parser. The module is divided in three modules : - - Expression : the finest part of the QSP syntax. - - Instruction : if/act block, - - Location - *) + - Expression : the finest part of the QSP syntax. + - Instruction : if/act block, + - Location *) -(** {1 Generic types used in the module } *) +(** {1 Generic types used in the module} *) type pos = Lexing.position * Lexing.position -(** The type pos is used to track the starting and ending position for the - given location. *) +(** 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 } (** Describe a variable, using the name in capitalized text, and an optionnal @@ -101,7 +99,7 @@ module type Location = sig val location : context -> pos -> instruction list -> t end -(** {1 Unified module used by the parser } *) +(** {1 Unified module used by the parser} *) module type Analyzer = sig val identifier : string @@ -115,7 +113,7 @@ module type Analyzer = sig val is_global : bool (** Declare the checker as global. It requires to run over the whole file and - will be disabled if the application only check a single location. + will be disabled if the application only check a single location. Also, the test will be disabled if a syntax error is reported during the parsing, because this tell that I haven’t been able to analyse the whole @@ -137,11 +135,10 @@ module type Analyzer = sig end (** Helper module used in order to convert elements from the differents - representation levels. + representation levels. Thoses functions are intended to be used in the menhir parser, in order to - limit the code in the mly file. -*) + limit the code in the mly file. *) module Helper (E : sig type t (** Internal type used in the evaluation *) diff --git a/lib/syntax/catalog.ml b/lib/syntax/catalog.ml new file mode 100644 index 0000000..b516976 --- /dev/null +++ b/lib/syntax/catalog.ml @@ -0,0 +1,48 @@ +type ex = + | E : { + module_ : + (module S.Analyzer + with type Expression.t = 'a + and type Expression.t' = 'b + and type Instruction.t = 'c + and type Instruction.t' = 'd + and type Location.t = 'e + and type context = 'f); + expr_witness : 'a Type.Id.t; + expr' : 'b Type.Id.t; + instr_witness : 'c Type.Id.t; + instr' : 'd Type.Id.t; + location_witness : 'e Type.Id.t; + context : 'f Type.Id.t; + } + -> ex (** Type of check to apply *) + +let build : + (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_ -> + 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) diff --git a/lib/syntax/catalog.mli b/lib/syntax/catalog.mli new file mode 100644 index 0000000..a256c17 --- /dev/null +++ b/lib/syntax/catalog.mli @@ -0,0 +1,30 @@ +type ex = + | E : { + module_ : + (module S.Analyzer + with type Expression.t = 'a + and type Expression.t' = 'b + and type Instruction.t = 'c + and type Instruction.t' = 'd + and type Location.t = 'e + and type context = 'f); + expr_witness : 'a Type.Id.t; + expr' : 'b Type.Id.t; + instr_witness : 'c Type.Id.t; + instr' : 'd Type.Id.t; + location_witness : 'e Type.Id.t; + context : 'f Type.Id.t; + } + -> ex (** Type of check to apply *) + +val build : + (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 +(** 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. *) |