ast.ml 1.8 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
(*  Abstract syntax as produced by the parsed *)

open Location

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
14
15
16
17
  | Debug of debug_directive
and debug_directive =
  [ `Filter of ppat * ppat
  | `Accept of ppat
18
19
  | `Compile of ppat * ppat list 
  | `Normal_record of ppat
20
  | `Compile2 of ppat * ppat list
21
  ]
22

23
24
25

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

  (* Exceptions *)
  | Try of pexpr * branches

47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
and abstr = { 
  fun_name : string option; 
  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
63
  | And of ppat * ppat
64
65
  | Diff of ppat * ppat
  | Prod of ppat * ppat
66
  | XmlT of ppat * ppat
67
  | Arrow of ppat * ppat
68
  | Record of bool * (Types.label * bool * ppat) list
69
70
71
72
73
74
75
76
77
78
79
80
81
  | Capture of Patterns.capture
  | Constant of Patterns.capture * Types.const
  | Regexp of regexp * ppat

and regexp =
  | Epsilon
  | Elem of ppat
  | Seq of regexp * regexp
  | Alt of regexp * regexp
  | Star of regexp
  | WeakStar of regexp
  | SeqCapture of Patterns.capture * regexp