diff options
Diffstat (limited to 'lib/syntax/tree.ml')
-rw-r--r-- | lib/syntax/tree.ml | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/lib/syntax/tree.ml b/lib/syntax/tree.ml index 0074df8..c3edcdc 100644 --- a/lib/syntax/tree.ml +++ b/lib/syntax/tree.ml @@ -7,9 +7,12 @@ let active = ref true type context = unit +let depends = [] let initialize = Fun.id let finalize () = [] +type ex = Identifier.t + module Ast = struct type 'a literal = 'a T.literal = Text of string | Expression of 'a [@@deriving eq, show] @@ -88,24 +91,36 @@ end = struct Hashtbl.hash (f pos, name, List.map ~f:(hash f) args) let v : t -> t' = fun t -> t - let integer : S.pos -> string -> t = fun pos i -> Ast.Integer (pos, i) - - let literal : S.pos -> t T.literal list -> t = - fun pos l -> Ast.Literal (pos, l) - - let function_ : S.pos -> T.function_ -> t list -> t = - fun pos name args -> Ast.Function (pos, name, args) - - let uoperator : S.pos -> T.uoperator -> t -> t = - fun pos op expression -> Ast.Op (pos, op, expression) - let boperator : S.pos -> T.boperator -> t -> t -> t = - fun pos op op1 op2 -> + let integer : ctx:S.extract_context -> S.pos -> string -> t = + fun ~ctx pos i -> + ignore ctx; + Ast.Integer (pos, i) + + let literal : ctx:S.extract_context -> S.pos -> t T.literal list -> t = + fun ~ctx pos l -> + ignore ctx; + Ast.Literal (pos, l) + + let function_ : ctx:S.extract_context -> S.pos -> T.function_ -> t list -> t = + fun ~ctx pos name args -> + ignore ctx; + Ast.Function (pos, name, args) + + let uoperator : ctx:S.extract_context -> S.pos -> T.uoperator -> t -> t = + fun ~ctx pos op expression -> + ignore ctx; + Ast.Op (pos, op, expression) + + let boperator : ctx:S.extract_context -> S.pos -> T.boperator -> t -> t -> t = + fun ~ctx pos op op1 op2 -> + ignore ctx; let op1 = op1 and op2 = op2 in Ast.BinaryOp (pos, op, op1, op2) - let ident : (S.pos, t) S.variable -> t = - fun { pos; name; index } -> + let ident : ctx:S.extract_context -> (S.pos, t) S.variable -> t = + fun ~ctx { pos; name; index } -> + ignore ctx; let index = Option.map (fun i -> i) index in Ast.Ident { pos; name; index } end |