aboutsummaryrefslogtreecommitdiff
path: root/lib/syntax/tree.ml
diff options
context:
space:
mode:
authorChimrod <>2024-02-03 17:42:16 +0100
committerChimrod <>2024-02-08 14:16:41 +0100
commitd7a13b0e5d6e746993e67a291376bd79766e0ed1 (patch)
tree80c621cbdb97ce69fd666a4e8f90f4952d237027 /lib/syntax/tree.ml
parent6fd720c07e3e361932e01bfbdbe4637c8f610649 (diff)
Added a new check to ensure that every call to another location points to an existing one
Diffstat (limited to 'lib/syntax/tree.ml')
-rw-r--r--lib/syntax/tree.ml26
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/syntax/tree.ml b/lib/syntax/tree.ml
index 6f6e7f2..b7d9d15 100644
--- a/lib/syntax/tree.ml
+++ b/lib/syntax/tree.ml
@@ -2,11 +2,13 @@ open StdLabels
let identifier = "tree"
let description = "Build the AST"
+let is_global = false
let active = ref true
type context = unit
let initialize = Fun.id
+let finalize () = []
module Ast = struct
type 'a literal = 'a T.literal = Text of string | Expression of 'a
@@ -72,28 +74,27 @@ end
module Instruction :
S.Instruction
- with type expression = Expression.t'
- and type t' = S.pos Ast.statement = struct
+ with type t' = S.pos Ast.statement
+ and type expression = Expression.t' = struct
type t = S.pos Ast.statement
type t' = t
+ type expression = Expression.t'
let v : t -> t' = fun t -> t
- type expression = Expression.t'
-
- let call : S.pos -> T.keywords -> expression list -> t =
+ let call : S.pos -> T.keywords -> Expression.t' list -> t =
fun pos name args -> Ast.Call (pos, name, args)
let location : S.pos -> string -> t =
fun loc label -> Ast.Location (loc, label)
let comment : S.pos -> t = fun pos -> Ast.Comment pos
- let expression : expression -> t = fun expr -> Ast.Expression expr
+ let expression : Expression.t' -> t = fun expr -> Ast.Expression expr
let if_ :
S.pos ->
- (expression, t) S.clause ->
- elifs:(expression, t) S.clause list ->
+ (Expression.t', t) S.clause ->
+ elifs:(Expression.t', t) S.clause list ->
else_:(S.pos * t list) option ->
t =
fun pos predicate ~elifs ~else_ ->
@@ -105,14 +106,14 @@ module Instruction :
Ast.If { loc = pos; then_ = clause predicate; elifs; else_ }
- let act : S.pos -> label:expression -> t list -> t =
+ let act : S.pos -> label:Expression.t' -> t list -> t =
fun pos ~label statements -> Ast.Act { loc = pos; label; statements }
let assign :
S.pos ->
- (S.pos, expression) S.variable ->
+ (S.pos, Expression.t') S.variable ->
T.assignation_operator ->
- expression ->
+ Expression.t' ->
t =
fun pos_loc { pos; name; index } op expr ->
(*let index = Option.map (fun i -> fst @@ Expression.observe (i [])) index*)
@@ -120,11 +121,10 @@ module Instruction :
end
module Location = struct
- type instruction = Instruction.t'
type t = S.pos * S.pos Ast.statement list
let v _ = []
- let location : unit -> S.pos -> instruction list -> t =
+ let location : unit -> S.pos -> Instruction.t' list -> t =
fun () pos block -> (pos, block)
end