| 28 |
let tuple_queue = |
let tuple_queue = |
| 29 |
List.fold_right (fun x q -> mk x.loc (Pair (x, q))) |
List.fold_right (fun x q -> mk x.loc (Pair (x, q))) |
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
let char = mk noloc (Internal (Types.char Chars.any)) |
let char = mk noloc (Internal (Types.char Chars.any)) |
| 34 |
let string_regexp = Star (Elem char) |
let string_regexp = Star (Elem char) |
| 35 |
|
|
| 46 |
exception Error of string |
exception Error of string |
| 47 |
let error loc s = raise (Location (loc, Error s)) |
let error loc s = raise (Location (loc, Error s)) |
| 48 |
|
|
| 49 |
|
let make_record loc r = |
| 50 |
|
LabelMap.from_list (fun _ _ -> error loc "Duplicated record field") r |
| 51 |
|
|
| 52 |
let parse_char loc s = |
let parse_char loc s = |
| 53 |
(* TODO: Unicode *) |
(* TODO: Unicode *) |
| 54 |
if String.length s <> 1 then |
if String.length s <> 1 then |
| 131 |
] |
] |
| 132 |
| |
| |
| 133 |
[ e = expr; "."; l = [LIDENT | UIDENT] -> |
[ e = expr; "."; l = [LIDENT | UIDENT] -> |
| 134 |
mk loc (Dot (e,Types.LabelPool.mk l)) |
mk loc (Dot (e,LabelPool.mk l)) |
| 135 |
] |
] |
| 136 |
|
|
| 137 |
| |
| |
| 168 |
| "<"; e = expr LEVEL "no_appl" -> e ]; |
| "<"; e = expr LEVEL "no_appl" -> e ]; |
| 169 |
a = expr_attrib_spec; ">"; c = expr -> |
a = expr_attrib_spec; ">"; c = expr -> |
| 170 |
mk loc (Xml (t, mk loc (Pair (a,c)))) |
mk loc (Xml (t, mk loc (Pair (a,c)))) |
| 171 |
| "{"; r = [ expr_record_spec | -> mk loc (RecordLitt []) ]; "}" -> r |
| "{"; r = [ expr_record_spec | -> mk loc (RecordLitt LabelMap.empty) ]; "}" -> r |
| 172 |
| s = STRING2 -> |
| s = STRING2 -> |
| 173 |
tuple loc (char_list loc s @ [cst_nil]) |
tuple loc (char_list loc s @ [cst_nil]) |
| 174 |
| a = LIDENT -> mk loc (Var (ident a)) |
| a = LIDENT -> mk loc (Var (ident a)) |
| 333 |
o = [ "?" -> true | -> false]; |
o = [ "?" -> true | -> false]; |
| 334 |
x = pat -> |
x = pat -> |
| 335 |
let x = if o then mk loc (Optional x) else x in |
let x = if o then mk loc (Optional x) else x in |
| 336 |
(Types.LabelPool.mk l, x) |
(LabelPool.mk l, x) |
| 337 |
] SEP ";" -> |
] SEP ";" -> |
| 338 |
(* TODO: check here uniqueness *) |
make_record loc r |
|
List.sort (fun (l1,_) (l2,_) -> compare l1 l2) r |
|
| 339 |
] ]; |
] ]; |
| 340 |
|
|
| 341 |
char: |
char: |
| 360 |
expr_record_spec: |
expr_record_spec: |
| 361 |
[ [ r = LIST1 |
[ [ r = LIST1 |
| 362 |
[ l = [LIDENT | UIDENT]; "="; x = expr -> |
[ l = [LIDENT | UIDENT]; "="; x = expr -> |
| 363 |
(Types.LabelPool.mk l,x) ] |
(LabelPool.mk l,x) ] |
| 364 |
SEP ";" -> |
SEP ";" -> |
| 365 |
mk loc (RecordLitt r) |
mk loc (RecordLitt (make_record loc r)) |
| 366 |
] ]; |
] ]; |
| 367 |
|
|
| 368 |
expr_attrib_spec: |
expr_attrib_spec: |
| 369 |
[ [ r = expr_record_spec -> r ] |
[ [ r = expr_record_spec -> r ] |
| 370 |
| [ e = expr LEVEL "no_appl" -> e |
| [ e = expr LEVEL "no_appl" -> e |
| 371 |
| -> mk loc (RecordLitt []) |
| -> mk loc (RecordLitt (LabelMap.empty)) |
| 372 |
] |
] |
| 373 |
]; |
]; |
| 374 |
END |
END |