ast.ml 1.79 KB
Newer Older
1
2
3
(*  Abstract syntax as produced by the parsed *)

open Location
4
open Ident
5
6
7
8
9
10
11
12
13
14

type pprog = pmodule_item list

and pmodule_item = pmodule_item' located
and pmodule_item' =
  | TypeDecl of string * ppat
  | PatDecl of string * ppat
  | FunDecl of abstr
  | LetDecl of ppat * pexpr
  | EvalStatement of pexpr
15
16
17
18
  | Debug of debug_directive
and debug_directive =
  [ `Filter of ppat * ppat
  | `Accept of ppat
19
20
  | `Compile of ppat * ppat list 
  | `Normal_record of ppat
21
  | `Compile2 of ppat * ppat list
22
  | `Subtype of ppat * ppat
23
  ]
24

25
26
27

and pexpr = pexpr' located
and pexpr' = 
28
  | Forget of pexpr * ppat    
29
  (* CDuce is a Lambda-calculus ... *)
30
  | Var of id
31
32
33
34
35
36
  | Apply of pexpr * pexpr
  | Abstraction of abstr
      
  (* Data constructors *)
  | Cst of Types.const
  | Pair of pexpr * pexpr
37
  | Xml of pexpr * pexpr
38
39
40
  | RecordLitt of (Types.label * pexpr) list
      
  (* Data destructors *)
41
  | Op of string * pexpr list
42
43
  | Match of pexpr * branches
  | Map of pexpr * branches
44
  | Dot of (pexpr* Types.label)
45
46
47
48

  (* Exceptions *)
  | Try of pexpr * branches

49
and abstr = { 
50
  fun_name : id option; 
51
52
53
54
55
56
57
58
59
60
61
62
63
64
  fun_iface : (ppat * ppat) list;
  fun_body : branches
}

and branches = (ppat * pexpr) list
    
(* A common syntactic class for patterns and types *) 

and ppat = ppat' located
and ppat' =
  | PatVar of string
  | Recurs of ppat * (string * ppat) list
  | Internal of Types.descr
  | Or of ppat * ppat
65
  | And of ppat * ppat
66
67
  | Diff of ppat * ppat
  | Prod of ppat * ppat
68
  | XmlT of ppat * ppat
69
  | Arrow of ppat * ppat
70
  | Record of bool * (Types.label * bool * ppat) list
71
72
  | Capture of id
  | Constant of id * Types.const
73
74
75
76
77
78
79
80
81
  | Regexp of regexp * ppat

and regexp =
  | Epsilon
  | Elem of ppat
  | Seq of regexp * regexp
  | Alt of regexp * regexp
  | Star of regexp
  | WeakStar of regexp
82
  | SeqCapture of id * regexp
83