aboutsummaryrefslogtreecommitdiff
path: root/lib/syntax
diff options
context:
space:
mode:
authorChimrod <>2023-10-25 22:23:06 +0200
committerChimrod <>2023-10-25 22:23:06 +0200
commitfc235a1d2b7f10e6b5b1d7ed4328e2f9f7714171 (patch)
tree99530ff84778167ed02b267dbc1ef7f9c1aff2ac /lib/syntax
parent319c1e4474f4fefde688720b78e8abf315513a32 (diff)
Updated the documentation
Diffstat (limited to 'lib/syntax')
-rw-r--r--lib/syntax/S.ml14
-rw-r--r--lib/syntax/check.ml4
-rw-r--r--lib/syntax/check.mli36
-rw-r--r--lib/syntax/dead_end.mli7
-rw-r--r--lib/syntax/type_of.mli4
5 files changed, 42 insertions, 23 deletions
diff --git a/lib/syntax/S.ml b/lib/syntax/S.ml
index 4a6b3e2..108dac9 100644
--- a/lib/syntax/S.ml
+++ b/lib/syntax/S.ml
@@ -6,15 +6,13 @@
- Expression : the finest part of the QSP syntax.
- Instruction : if/act block,
- Location
-
- All the elements of the syntax are represented with a dedicated function
- (instead of a big sum type). The module [Tree] provide an implementation
- which build the AST.
-
*)
+(** {1 Generic types used in the module } *)
+
type pos = Lexing.position * Lexing.position
-(** 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
@@ -24,6 +22,8 @@ type ('a, 'b) variable = { pos : 'a; name : string; index : 'b option }
type ('a, 'b) clause = pos * 'a * 'b list
+(** {1 Checker Signature} *)
+
(** Represent the evaluation over an expression *)
module type Expression = sig
type t
@@ -99,6 +99,8 @@ module type Location = sig
val location : pos -> instruction list -> t * Report.t list
end
+(** {1 Unified module used by the parser } *)
+
module type Analyzer = sig
module Expression : Expression
module Instruction : Instruction with type expression = Expression.t'
diff --git a/lib/syntax/check.ml b/lib/syntax/check.ml
index 54eb295..7db3286 100644
--- a/lib/syntax/check.ml
+++ b/lib/syntax/check.ml
@@ -1,5 +1,3 @@
-open StdLabels
-
(** This module provide a way to create new Id dynamically in the runtime,
and some fonctions for comparing them. *)
module Id : sig
@@ -89,6 +87,8 @@ module type App = sig
val t : t array
end
+open StdLabels
+
module Helper = struct
type 'a expr_list = { witness : 'a Id.typeid; values : 'a list }
diff --git a/lib/syntax/check.mli b/lib/syntax/check.mli
index 28ff49e..759a07a 100644
--- a/lib/syntax/check.mli
+++ b/lib/syntax/check.mli
@@ -1,3 +1,19 @@
+(** This module is a meta-checker. It will take many checkers and aggregate
+ their result together before providing an unified result.
+
+ The modules required to be declared before being used, using the [build]
+ method, and provided as an array :
+
+ {[
+ let _, e1 = build (module …)
+ let _, e2 = build (module …)
+
+ module Check = Make (struct
+ let t = [| e1; e2 |]
+ end)
+ ]}
+*)
+
module Id : sig
type 'a typeid
(** The type created on-the-fly. *)
@@ -19,20 +35,16 @@ val build :
Return the result type which hold the final result value, and checker
itself. *)
-module type App = sig
- val t : t array
-end
-
type result
val get : 'a Id.typeid -> result -> 'a option
-(** Retrieve the information with the given type *)
-
-module Make (A : App) : sig
- include
- S.Analyzer
- with type Location.t = result array
- and type Instruction.t' = result array
- and type Expression.t' = result array
+(** The method [get] can be used to get the internal value for one of the
+ checker used.
+ *)
+
+module Make (A : sig
+ val t : t array
+end) : sig
+ include S.Analyzer with type Location.t = result array
end
[@@warning "-67"]
diff --git a/lib/syntax/dead_end.mli b/lib/syntax/dead_end.mli
index ce48791..451fe58 100644
--- a/lib/syntax/dead_end.mli
+++ b/lib/syntax/dead_end.mli
@@ -1 +1,6 @@
-include S.Analyzer with type Location.t = unit
+(** Checker looking for the dead ends in the source.
+
+ A dead end is a state where the user does not have any action.
+ *)
+
+include S.Analyzer
diff --git a/lib/syntax/type_of.mli b/lib/syntax/type_of.mli
index a7850e5..551f9ac 100644
--- a/lib/syntax/type_of.mli
+++ b/lib/syntax/type_of.mli
@@ -1,7 +1,7 @@
-(* The module [type_of] populate the report with differents inconsistency
+include S.Analyzer
+(** The module [type_of] populate the report with differents inconsistency
errors in the types.
- Assigning a [string] value in an [integer] variable
- Comparing a [string] with an [integer]
- Giving the wrong type in the argument for a function and so one. *)
-include S.Analyzer with type Location.t = unit