(** 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 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. *) type pos = Lexing.position * Lexing.position type ('a, 'b) variable = { pos : 'a; name : string; index : 'b option } (** Represent the evaluation over an expression *) module type Expression = sig type 'a obs type t type repr = Report.t list -> t * Report.t list type variable = { pos : pos; name : string; index : repr option } (** Describe a variable, using the name in capitalized text, and an optionnal index. If missing, the index should be considered as [0]. *) val ident : variable -> repr (* Basic values, text, number… *) val integer : pos -> string -> repr val literal : pos -> string -> repr val function_ : pos -> T.function_ -> repr list -> repr (** Call a function. The functions list is hardcoded in lib/lexer.mll *) val uoperator : pos -> T.uoperator -> repr -> repr (** Unary operator like [-123] or [+'Text']*) val boperator : pos -> T.boperator -> repr -> repr -> repr (** Binary operator, for a comparaison, or an operation *) end module type Instruction = sig type repr type expression type variable val call : pos -> T.keywords -> expression list -> repr (** Call for an instruction like [GT] or [*CLR] *) val location : pos -> string -> repr (** Label for a loop *) val comment : pos -> repr (** Comment *) val expression : expression -> repr (** Raw expression *) type clause = pos * expression * repr list val if_ : pos -> clause -> elifs:clause list -> else_:repr list -> repr val act : pos -> label:expression -> repr list -> repr val assign : pos -> variable -> T.assignation_operator -> expression -> repr end module type Location = sig type repr type instruction val location : pos -> instruction list -> repr end module type Analyzer = sig module Expression : Expression module Instruction : Instruction with type expression = Expression.repr and type variable = Expression.variable module Location : Location with type instruction = Instruction.repr end