| 3 |
open Location |
open Location |
| 4 |
open Ident |
open Ident |
| 5 |
|
|
| 6 |
|
type schema_item_kind = [ `Type | `Element | `Attribute | `Any ] |
| 7 |
|
|
| 8 |
type pprog = pmodule_item list |
type pprog = pmodule_item list |
| 9 |
|
|
| 10 |
and pmodule_item = pmodule_item' located |
and pmodule_item = pmodule_item' located |
| 11 |
and pmodule_item' = |
and pmodule_item' = |
| 12 |
| TypeDecl of string * ppat |
| TypeDecl of string * ppat |
| 13 |
|
| SchemaDecl of string * Schema_types.schema (* name, schema *) |
| 14 |
| LetDecl of ppat * pexpr |
| LetDecl of ppat * pexpr |
| 15 |
| FunDecl of pexpr |
| FunDecl of pexpr |
| 16 |
| EvalStatement of pexpr |
| EvalStatement of pexpr |
| 51 |
| Map of pexpr * branches |
| Map of pexpr * branches |
| 52 |
| Transform of pexpr * branches |
| Transform of pexpr * branches |
| 53 |
| Xtrans of pexpr * branches |
| Xtrans of pexpr * branches |
| 54 |
|
| Validate of pexpr * string * string (* exp, schema name, element name *) |
| 55 |
| Dot of pexpr* label |
| Dot of pexpr* label |
| 56 |
| RemoveField of pexpr * label |
| RemoveField of pexpr * label |
| 57 |
|
|
| 71 |
and ppat = ppat' located |
and ppat = ppat' located |
| 72 |
and ppat' = |
and ppat' = |
| 73 |
| PatVar of string |
| PatVar of string |
| 74 |
|
| SchemaVar of (* type/pattern schema variable *) |
| 75 |
|
schema_item_kind * string * string |
| 76 |
| Recurs of ppat * (string * ppat) list |
| Recurs of ppat * (string * ppat) list |
| 77 |
| Internal of Types.descr |
| Internal of Types.descr |
| 78 |
| Or of ppat * ppat |
| Or of ppat * ppat |
| 86 |
| Capture of id |
| Capture of id |
| 87 |
| Constant of id * Types.const |
| Constant of id * Types.const |
| 88 |
| Regexp of regexp * ppat |
| Regexp of regexp * ppat |
| 89 |
|
(* regular expression, continuation: [ re ; cont ], e.g: [ re ; nil ] *) |
| 90 |
|
|
| 91 |
and regexp = |
and regexp = |
| 92 |
| Epsilon |
| Epsilon |
| 96 |
| Star of regexp |
| Star of regexp |
| 97 |
| WeakStar of regexp |
| WeakStar of regexp |
| 98 |
| SeqCapture of id * regexp |
| 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 |
|
*) |