/[svn]/parser/ast.ml
ViewVC logotype

Contents of /parser/ast.ml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 501 - (show annotations)
Tue Jul 10 17:39:47 2007 UTC (5 years, 10 months ago) by abate
File size: 2702 byte(s)
[r2003-06-12 13:15:56 by cvscast] Merging schema branch

Original author: cvscast
Date: 2003-06-12 13:16:00+00:00
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 string * ppat
13 | SchemaDecl of string * Schema_types.schema (* name, schema *)
14 | LetDecl of ppat * pexpr
15 | FunDecl of pexpr
16 | EvalStatement of pexpr
17 | Debug of debug_directive
18 | Directive of toplevel_directive
19 and debug_directive =
20 [ `Filter of ppat * ppat
21 | `Sample of ppat
22 | `Accept of ppat
23 | `Compile of ppat * ppat list
24 | `Subtype of ppat * ppat
25 ]
26 and toplevel_directive =
27 [ `Quit
28 | `Env
29 ]
30
31
32 and pexpr =
33 | LocatedExpr of loc * pexpr
34
35 | Forget of pexpr * ppat
36 | Op of string * pexpr list
37
38 (* CDuce is a Lambda-calculus ... *)
39 | Var of id
40 | Apply of pexpr * pexpr
41 | Abstraction of abstr
42
43 (* Data constructors *)
44 | Cst of Types.const
45 | Pair of pexpr * pexpr
46 | Xml of pexpr * pexpr
47 | RecordLitt of pexpr label_map
48
49 (* Data destructors *)
50 | Match of pexpr * branches
51 | Map of pexpr * branches
52 | Transform of pexpr * branches
53 | Xtrans of pexpr * branches
54 | Validate of pexpr * string * string (* exp, schema name, element name *)
55 | Dot of pexpr * label
56 | RemoveField of pexpr * label
57
58 (* Exceptions *)
59 | Try of pexpr * branches
60
61 and abstr = {
62 fun_name : id option;
63 fun_iface : (ppat * ppat) list;
64 fun_body : branches
65 }
66
67 and branches = (ppat * pexpr) list
68
69 (* A common syntactic class for patterns and types *)
70
71 and ppat = ppat' located
72 and ppat' =
73 | PatVar of string
74 | SchemaVar of (* type/pattern schema variable *)
75 schema_item_kind * string * string
76 | Recurs of ppat * (string * ppat) list
77 | Internal of Types.descr
78 | Or of ppat * ppat
79 | And of ppat * ppat
80 | Diff of ppat * ppat
81 | Prod of ppat * ppat
82 | XmlT of ppat * ppat
83 | Arrow of ppat * ppat
84 | Optional of ppat
85 | Record of bool * ppat label_map
86 | Capture of id
87 | Constant of id * Types.const
88 | Regexp of regexp * ppat
89 (* regular expression, continuation: [ re ; cont ], e.g: [ re ; nil ] *)
90
91 and regexp =
92 | Epsilon
93 | Elem of ppat
94 | Seq of regexp * regexp
95 | Alt of regexp * regexp
96 | Star of regexp
97 | WeakStar of regexp
98 | SeqCapture of id * regexp
99
100 open Printf
101
102 (*
103 let rec string_of_regexp = function
104 | Epsilon -> "e"
105 | Elem _ -> "ELEM"
106 | Seq (re1, re2) -> sprintf "(%s),(%s)" (string_of_regexp re1) (string_of_regexp re2)
107 | Alt (re1, re2) -> sprintf "(%s)|(%s)" (string_of_regexp re1) (string_of_regexp re2)
108 | Star re -> sprintf "(%s)*" (string_of_regexp re)
109 | WeakStar _ -> assert false
110 | SeqCapture _ -> assert false
111 *)

CVS Admin">CVS Admin
ViewVC Help
Powered by ViewVC 1.1.5