| 1 |
(* Abstract syntax as produced by the parsed *)
|
| 2 |
|
| 3 |
open Location
|
| 4 |
open Ident
|
| 5 |
|
| 6 |
type schema_item_kind = [ `Type | `Element | `Attribute | `Any ]
|
| 7 |
|
| 8 |
type pprog = pmodule_item list
|
| 9 |
|
| 10 |
and pmodule_item = pmodule_item' located
|
| 11 |
and pmodule_item' =
|
| 12 |
| TypeDecl of U.t * ppat
|
| 13 |
| SchemaDecl of string * Schema_types.schema (* name, schema *)
|
| 14 |
| LetDecl of ppat * pexpr
|
| 15 |
| FunDecl of pexpr
|
| 16 |
| Namespace of U.t * Ns.t
|
| 17 |
| EvalStatement of pexpr
|
| 18 |
| Debug of debug_directive
|
| 19 |
| Directive of toplevel_directive
|
| 20 |
and debug_directive =
|
| 21 |
[ `Filter of ppat * ppat
|
| 22 |
| `Sample of ppat
|
| 23 |
| `Accept of ppat
|
| 24 |
| `Compile of ppat * ppat list
|
| 25 |
| `Subtype of ppat * ppat
|
| 26 |
]
|
| 27 |
and toplevel_directive =
|
| 28 |
[ `Quit
|
| 29 |
| `Env
|
| 30 |
| `Reinit_ns
|
| 31 |
]
|
| 32 |
|
| 33 |
|
| 34 |
and pconst =
|
| 35 |
| Const_internal of Types.const
|
| 36 |
| Const_atom of U.t
|
| 37 |
|
| 38 |
and pexpr =
|
| 39 |
| LocatedExpr of loc * pexpr
|
| 40 |
|
| 41 |
(* CDuce is a Lambda-calculus ... *)
|
| 42 |
| Var of id
|
| 43 |
| Apply of pexpr * pexpr
|
| 44 |
| Abstraction of abstr
|
| 45 |
|
| 46 |
(* Data constructors *)
|
| 47 |
| Cst of pconst
|
| 48 |
| Pair of pexpr * pexpr
|
| 49 |
| Xml of pexpr * pexpr
|
| 50 |
| RecordLitt of (label * pexpr) list
|
| 51 |
| String of U.uindex * U.uindex * U.t * pexpr
|
| 52 |
|
| 53 |
(* Data destructors *)
|
| 54 |
| Match of pexpr * branches
|
| 55 |
| Map of pexpr * branches
|
| 56 |
| Transform of pexpr * branches
|
| 57 |
| Xtrans of pexpr * branches
|
| 58 |
| Validate of pexpr * string * string (* exp, schema name, element name *)
|
| 59 |
| Dot of pexpr * label
|
| 60 |
| RemoveField of pexpr * label
|
| 61 |
|
| 62 |
(* Exceptions *)
|
| 63 |
| Try of pexpr * branches
|
| 64 |
|
| 65 |
(* Other *)
|
| 66 |
| NamespaceIn of U.t * Ns.t * pexpr
|
| 67 |
| Forget of pexpr * ppat
|
| 68 |
| Op of string * pexpr list
|
| 69 |
| Ref of pexpr * ppat
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
and label = U.t
|
| 74 |
|
| 75 |
and abstr = {
|
| 76 |
fun_name : id option;
|
| 77 |
fun_iface : (ppat * ppat) list;
|
| 78 |
fun_body : branches
|
| 79 |
}
|
| 80 |
|
| 81 |
and branches = (ppat * pexpr) list
|
| 82 |
|
| 83 |
(* A common syntactic class for patterns and types *)
|
| 84 |
|
| 85 |
and ppat = ppat' located
|
| 86 |
and ppat' =
|
| 87 |
| PatVar of U.t
|
| 88 |
| SchemaVar of (* type/pattern schema variable *)
|
| 89 |
schema_item_kind * string * string
|
| 90 |
| AtomT of U.t
|
| 91 |
| NsT of U.t
|
| 92 |
| Recurs of ppat * (U.t * ppat) list
|
| 93 |
| Internal of Types.descr
|
| 94 |
| Or of ppat * ppat
|
| 95 |
| And of ppat * ppat
|
| 96 |
| Diff of ppat * ppat
|
| 97 |
| Prod of ppat * ppat
|
| 98 |
| XmlT of ppat * ppat
|
| 99 |
| Arrow of ppat * ppat
|
| 100 |
| Optional of ppat
|
| 101 |
| Record of bool * (label * ppat) list
|
| 102 |
| Capture of id
|
| 103 |
| Constant of id * pconst
|
| 104 |
| Regexp of regexp * ppat
|
| 105 |
(* regular expression, continuation: [ re ; cont ], e.g: [ re ; nil ] *)
|
| 106 |
|
| 107 |
and regexp =
|
| 108 |
| Epsilon
|
| 109 |
| Elem of ppat
|
| 110 |
| Seq of regexp * regexp
|
| 111 |
| Alt of regexp * regexp
|
| 112 |
| Star of regexp
|
| 113 |
| WeakStar of regexp
|
| 114 |
| SeqCapture of id * regexp
|
| 115 |
|
| 116 |
open Printf
|