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

Contents of /parser/parser.ml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 529 - (hide annotations)
Tue Jul 10 17:42:07 2007 UTC (5 years, 11 months ago) by abate
File size: 16622 byte(s)
[r2003-06-25 23:11:01 by cvscast] Starting Namespaces -- Alain

Original author: cvscast
Date: 2003-06-25 23:11:03+00:00
1 abate 4 open Location
2     open Ast
3 abate 225 open Ident
4 abate 501 open Printf
5 abate 4
6 abate 161 (*
7 abate 151 let () = Grammar.error_verbose := true
8 abate 161 *)
9 abate 81
10 abate 529 exception Error of string
11     let error (i,j) s = Location.raise_loc i j (Error s)
12 abate 469
13 abate 81 let gram = Grammar.gcreate (Wlexer.lexer Wlexer.token Wlexer.latin1_engine)
14    
15 abate 421 let true_atom = Atoms.mk_ascii "true"
16     let false_atom = Atoms.mk_ascii "false"
17     let true_type = Types.atom (Atoms.atom true_atom)
18     let false_type = Types.atom (Atoms.atom false_atom)
19 abate 81
20 abate 529 let parse_ident = U.mk_latin1
21 abate 374
22 abate 375 let id_dummy = ident (U.mk "$$$")
23 abate 529
24     let split_qname s =
25     try
26     let i = String.index s ':' in
27     let ns = String.sub s 0 i in
28     let s = String.sub s (i + 1) (String.length s - i - 1) in
29     (parse_ident ns, parse_ident s)
30     with Not_found ->
31     (U.mk "", parse_ident s)
32    
33 abate 374 let label s = LabelPool.mk (parse_ident s)
34 abate 375 let ident s = ident (parse_ident s)
35 abate 374
36 abate 38 let prog = Grammar.Entry.create gram "prog"
37 abate 431 let top_phrases = Grammar.Entry.create gram "toplevel phrases"
38 abate 38 let expr = Grammar.Entry.create gram "expression"
39     let pat = Grammar.Entry.create gram "type/pattern expression"
40     let regexp = Grammar.Entry.create gram "type/pattern regexp"
41     let const = Grammar.Entry.create gram "scalar constant"
42    
43 abate 316 let exp pos e = LocatedExpr (loc_of_pos pos,e)
44    
45 abate 38 let rec multi_prod loc = function
46     | [ x ] -> x
47     | x :: l -> mk loc (Prod (x, multi_prod loc l))
48     | [] -> assert false
49    
50 abate 316 let rec tuple = function
51 abate 38 | [ x ] -> x
52 abate 316 | x :: l -> Pair (x, tuple l)
53 abate 38 | [] -> assert false
54 abate 89
55     let tuple_queue =
56 abate 316 List.fold_right (fun x q -> Pair (x, q))
57 abate 89
58 abate 233
59 abate 249 let char = mknoloc (Internal (Types.char Chars.any))
60 abate 66 let string_regexp = Star (Elem char)
61 abate 38
62 abate 529 let cst_nil = Cst (Const_internal (Types.Atom Sequence.nil_atom))
63 abate 38
64 abate 525 let seq_of_string s =
65 abate 326 let s = Encodings.Utf8.mk s in
66     let rec aux i j =
67 abate 525 if Encodings.Utf8.equal_index i j then []
68     else let (c,i) = Encodings.Utf8.next s i in c :: (aux i j)
69 abate 326 in
70 abate 525 aux (Encodings.Utf8.start_index s) (Encodings.Utf8.end_index s)
71 abate 326
72 abate 233 let make_record loc r =
73     LabelMap.from_list (fun _ _ -> error loc "Duplicated record field") r
74    
75 abate 81 let parse_char loc s =
76 abate 525 match seq_of_string s with
77     | [ c ] -> c
78 abate 310 | _ -> error loc "Character litteral must have length 1"
79 abate 81
80 abate 249 let include_stack = ref []
81    
82 abate 448 let protect_exn f g =
83     try let x = f () in g (); x
84     with e -> g (); raise e
85    
86 abate 470 let is_fun_decl =
87     Grammar.Entry.of_parser gram "[is_fun_decl]"
88     (fun strm ->
89     match Stream.npeek 3 strm with
90     | [ ("", "fun"); ("LIDENT", _); ("", "(") ]
91     | [ ("LIDENT", _) ; ("", "(") ; _ ] -> ()
92     | _ -> raise Stream.Failure
93     )
94    
95 abate 501 let dot_RE = Pcre.regexp "\\."
96 abate 470
97 abate 38 EXTEND
98 abate 431 GLOBAL: top_phrases prog expr pat regexp const;
99 abate 4
100 abate 431 top_phrases: [
101 abate 446 [ l = LIST0 phrase; ";;" -> List.flatten l ]
102 abate 431 ];
103    
104 abate 10 prog: [
105 abate 431 [ l = LIST0 [ p = phrase ; OPT ";;" -> p ]; EOI -> List.flatten l ]
106 abate 10 ];
107    
108 abate 529 uident: [ [ x = UIDENT -> parse_ident x ] ];
109    
110 abate 13 phrase: [
111 abate 431 [ (f,p,e) = let_binding ->
112     if f then [ mk loc (FunDecl e) ] else
113     [ mk loc (LetDecl (p,e)) ]
114     | (_,p,e1) = let_binding; "in"; e2 = expr LEVEL "top"->
115 abate 316 [ mk loc (EvalStatement (exp loc (Match (e1,[p,e2])))) ]
116 abate 529 | "type"; x = uident; "="; t = pat -> [ mk loc (TypeDecl (x,t)) ]
117 abate 431 | "type"; x = LIDENT -> error loc "Type identifiers must be capitalized"
118 abate 501 | "schema"; name = UIDENT; "="; uri = STRING2 ->
119 abate 522 protect_op "schema";
120 abate 525 let schema_doc = Schema_xml.pxp_tree_of uri in
121 abate 501 let schema = Schema_parser.parse_schema schema_doc in
122     [ mk loc (SchemaDecl (name, schema))]
123 abate 529 | "namespace";
124     name = [ name = [ UIDENT | LIDENT | keyword ]; "=" ->
125     parse_ident name
126     | -> U.mk "" ];
127     uri = STRING2 ->
128     let ns = Atoms.Ns.mk (parse_ident uri) in
129     Atoms.Ns.register_prefix name ns;
130     [ mk loc (Namespace (name, ns)) ]
131 abate 431 | "debug"; d = debug_directive -> [ mk loc (Debug d) ]
132 abate 446 | DIRECTIVE "#quit" -> [ mk loc (Directive `Quit) ]
133     | DIRECTIVE "#env" -> [ mk loc (Directive `Env) ]
134 abate 431 | "include"; s = STRING2 ->
135 abate 471 let s =
136     if Filename.is_relative s
137     then Filename.concat (Location.current_dir ()) s
138     else s in
139 abate 249 protect_op "File inclusion";
140     (* avoid looping; should issue an error ? *)
141 abate 471 (* it is possible to have looping with x/../x/../x/.. ....
142     Need to canonicalize filename *)
143 abate 249 if List.mem s !include_stack then []
144     else (
145     include_stack := s :: !include_stack;
146     Location.push_source (`File s);
147 abate 448 protect_exn
148     (fun () ->
149     let chan = open_in s in
150 abate 471 protect_exn
151     (fun () ->
152     let input = Stream.of_channel chan in
153     Grammar.Entry.parse prog input)
154     (fun () -> close_in chan))
155 abate 448 (fun () ->
156     Location.pop_source ();
157     include_stack := List.tl !include_stack)
158 abate 249 )
159 abate 66 ] |
160 abate 249 [ e = expr -> [ mk loc (EvalStatement e) ]
161 abate 43 ]
162 abate 13 ];
163    
164 abate 43 debug_directive: [
165     [ LIDENT "filter"; t = pat; p = pat -> `Filter(t,p)
166 abate 75 | LIDENT "accept"; p = pat -> `Accept p
167 abate 43 | LIDENT "compile"; t = pat; p = LIST1 pat -> `Compile (t,p)
168 abate 407 | LIDENT "sample"; t = pat -> `Sample t
169 abate 224 | LIDENT "subtype"; t1 = pat; t2 = pat -> `Subtype (t1,t2)
170 abate 43 ]
171     ];
172    
173 abate 332 keyword: [
174     [ a =
175     [ "map" | "match" | "with" | "try" | "xtransform"
176     | "if" | "then" | "else"
177     | "transform" | "fun" | "in"
178 abate 431 | "let" | "type" | "debug" | "include"
179 abate 529 | "and" | "validate" | "schema" | "namespace"
180 abate 332 ]
181     -> a
182     ]
183     ];
184    
185 abate 4 expr: [
186     "top" RIGHTA
187 abate 421 [ "match"; e = SELF; "with"; b = branches ->
188     exp loc (Match (e,b))
189 abate 64 | "try"; e = SELF; "with"; b = branches ->
190 abate 425 exp loc (Try (e,b))
191 abate 421 | "map"; e = SELF; "with"; b = branches ->
192     exp loc (Map (e,b))
193     | "xtransform"; e = SELF; "with"; b = branches ->
194     exp loc (Xtrans (e,b))
195 abate 237 | "if"; e = SELF; "then"; e1 = SELF; "else"; e2 = SELF ->
196 abate 421 let p1 = mk loc (Internal true_type)
197     and p2 = mk loc (Internal false_type) in
198 abate 316 exp loc (Match (e, [p1,e1; p2,e2]))
199 abate 17 | "transform"; e = SELF; "with"; b = branches ->
200 abate 421 exp loc (Transform (e,b))
201 abate 501 | "validate"; e = SELF; "with"; schema = UIDENT; "#";
202     typ = [ UIDENT | LIDENT | keyword ] ->
203     exp loc (Validate (e, schema, typ))
204 abate 48 | "fun"; (f,a,b) = fun_decl ->
205 abate 316 exp loc (Abstraction { fun_name = f; fun_iface = a; fun_body = b })
206 abate 431 | (_,p,e1) = let_binding; "in"; e2 = expr LEVEL "top"->
207 abate 316 exp loc (Match (e1,[p,e2]))
208 abate 54 | e = expr; ":"; p = pat ->
209 abate 316 exp loc (Forget (e,p))
210 abate 4 ]
211    
212    
213 abate 15 |
214 abate 237 [ e1 = expr; op = ["=" | "<=" | "<<" | ">>" | ">=" ]; e2 = expr ->
215     let op = match op with
216     | "<<" -> "<"
217     | ">>" -> ">"
218     | s -> s in
219 abate 316 exp loc (Op (op,[e1;e2]))
220 abate 237 ]
221    
222     |
223 abate 242 [ e1 = expr; op = ["+" | "-" | "@" ]; e2 = expr ->
224 abate 316 exp loc (Op (op,[e1;e2]))
225 abate 339 | e = expr; "\\"; l = [LIDENT | UIDENT | keyword ] ->
226 abate 374 exp loc (RemoveField (e, label l))
227 abate 51 ]
228 abate 16 |
229 abate 316 [ e1 = expr; op = ["*"]; e2 = expr -> exp loc (Op (op,[e1;e2]))
230 abate 151 | e = expr; op = "/"; p = pat ->
231    
232     let tag = mk loc (Internal (Types.atom (Atoms.any))) in
233     let att = mk loc (Internal Types.Record.any) in
234     let any = mk loc (Internal (Types.any)) in
235 abate 375 let re = Star(Alt(SeqCapture(id_dummy,Elem p), Elem any)) in
236 abate 151 let ct = mk loc (Regexp (re,any)) in
237     let p = mk loc (XmlT (tag, multi_prod loc [att;ct])) in
238 abate 375 let b = (p, Var id_dummy) in
239 abate 421 exp loc (Transform (e,[b]))
240 abate 51 ]
241 abate 26 |
242 abate 339 [ e = expr; "."; l = [LIDENT | UIDENT | keyword ] ->
243 abate 374 exp loc (Dot (e, label l))
244 abate 51 ]
245 abate 26
246 abate 52 |
247 abate 66 [ op = [ LIDENT "flatten"
248     | LIDENT "load_xml"
249 abate 374 | LIDENT "load_file" | LIDENT "load_file_utf8"
250 abate 188 | LIDENT "load_html"
251 abate 374 | LIDENT "print_xml" | LIDENT "print_xml_utf8"
252 abate 124 | LIDENT "print"
253 abate 66 | LIDENT "int_of"
254 abate 133 | LIDENT "string_of"
255 abate 329 | LIDENT "atom_of"
256 abate 421 | LIDENT "raise"
257 abate 66 ];
258 abate 316 e = expr -> exp loc (Op (op,[e]))
259 abate 374 | op = [ LIDENT "dump_to_file" | LIDENT "dump_to_file_utf8" ];
260 abate 316 e1 = expr LEVEL "no_appl"; e2 = expr -> exp loc (Op (op, [e1;e2]))
261     | e1 = SELF; LIDENT "div"; e2 = expr -> exp loc (Op ("/", [e1;e2]))
262     | e1 = SELF; LIDENT "mod"; e2 = expr -> exp loc (Op ("mod", [e1;e2]))
263     | e1 = SELF; e2 = expr -> exp loc (Apply (e1,e2))
264 abate 52 ]
265    
266 abate 4 | "no_appl"
267 abate 316 [ c = const -> exp loc (Cst c)
268     | "("; l = LIST1 expr SEP ","; ")" -> exp loc (tuple l)
269 abate 18 | "["; l = LIST0 seq_elem; e = OPT [ ";"; e = expr -> e ]; "]" ->
270     let e = match e with Some e -> e | None -> cst_nil in
271 abate 321 let l = List.fold_right
272     (fun x q ->
273     match x with
274 abate 522 | `String (loc,i,j,s) -> exp loc (String (i,j,s,q))
275 abate 321 | `Elems l -> tuple_queue l q
276     | `Explode x -> Op ("@",[x;q])
277     ) l e
278     in
279     exp loc l
280 abate 332 | "<"; t = [ "("; e = expr; ")" -> e
281 abate 529 | a = tag -> exp loc (Cst a)
282     ];
283 abate 81 a = expr_attrib_spec; ">"; c = expr ->
284 abate 529 (* let t = Pair (cst_nil, t) in *)
285     exp loc (Xml (t, Pair (a,c)))
286 abate 316 | "{"; r = [ expr_record_spec | -> exp loc (RecordLitt LabelMap.empty) ]; "}" -> r
287 abate 81 | s = STRING2 ->
288 abate 525 let s = U.mk s in
289 abate 522 exp loc (String (U.start_index s, U.end_index s, s, cst_nil))
290 abate 375 | a = LIDENT -> exp loc (Var (ident a))
291 abate 4 ]
292    
293     ];
294 abate 18
295 abate 529 tag: [ [ a = [ LIDENT | UIDENT | keyword ] ->
296     let (ns,l) = split_qname a in Const_atom (ns,l) ] ];
297    
298     tag_type: [
299     [ LIDENT "_" -> mk loc (Internal (Types.atom Atoms.any))
300     | a = [ LIDENT | UIDENT | keyword ] ->
301     let (ns,l) = split_qname a in
302     mk loc (AtomT (ns, Some l))
303     | t = ANY_IN_NS ->
304     mk loc (AtomT (parse_ident t, None))
305     ]
306     ];
307    
308 abate 18 seq_elem: [
309 abate 522 [ x = STRING1 ->
310 abate 525 let s = U.mk x in
311 abate 522 `String (loc, U.start_index s, U.end_index s, s)
312 abate 89 | e = expr LEVEL "no_appl" -> `Elems [e]
313     | "!"; e = expr LEVEL "no_appl" -> `Explode e
314 abate 18 ]
315     ];
316 abate 4
317     let_binding: [
318 abate 470 [ "let"; is_fun_decl; OPT "fun"; (f,a,b) = fun_decl ->
319     let f = match f with Some x -> x | None -> assert false in
320     let p = mk loc (Capture f) in
321     let abst = { fun_name = Some f; fun_iface = a; fun_body = b } in
322 abate 316 let e = exp loc (Abstraction abst) in
323 abate 431 (true,p,e)
324 abate 470 | "let"; p = pat; "="; e = expr -> (false,p,e)
325     | "let"; p = pat; ":"; t = pat; "="; e = expr -> (false,p, Forget (e,t))
326 abate 4 ]
327     ];
328    
329 abate 470 fun_decl_after_lparen: [
330 abate 85 (* need an hack to do this, because both productions would
331     match [ OPT LIDENT; "("; pat ] .... *)
332 abate 470 [ p1 = pat LEVEL "no_arrow";
333     res = [ "->"; p2 = pat;
334     a = [ ";"; a = LIST0 arrow SEP ";" -> a | -> [] ];
335     ")"; b = branches -> `Classic (p2,a,b)
336     | ":"; targ1 = pat;
337     args = LIST0 [ ","; arg = pat; ":"; targ = pat -> (arg,targ) ];
338     ")"; ":"; tres = pat ;
339     "="; body = expr ->
340     `Compact (targ1,args,tres,body)
341     ] ->
342     match res with
343     | `Classic (p2,a,b) -> (p1,p2)::a,b
344     | `Compact (targ1,args,tres,body) ->
345     let args = (p1,targ1) :: args in
346     let targ = multi_prod nopos (List.map snd args) in
347     let arg = multi_prod nopos (List.map fst args) in
348     let b = [arg, body] in
349     let a = [targ,tres] in
350     (a,b) ] ];
351    
352    
353     fun_decl: [
354     [ f = OPT [ x = LIDENT -> ident x]; "("; (a,b) = fun_decl_after_lparen ->
355 abate 85 (f,a,b)
356 abate 470 ]
357 abate 48 ];
358    
359 abate 85 arrow: [
360 abate 9 [ t1 = pat LEVEL "no_arrow"; "->"; t2 = pat -> (t1,t2)]
361 abate 4 ];
362    
363     branches: [
364 abate 81 [ OPT "|"; l = LIST1 branch SEP "|" -> l ]
365 abate 4 ];
366    
367     branch: [
368 abate 6 [ p = pat LEVEL "no_arrow"; "->"; e = expr -> (p,e) ]
369 abate 4 ];
370    
371    
372     regexp: [
373 abate 236 [ x = regexp; "|"; y = regexp ->
374     match (x,y) with
375     | Elem x, Elem y -> Elem (mk loc (Or (x,y)))
376     | _ -> Alt (x,y)
377     ]
378 abate 4 | [ x = regexp; y = regexp -> Seq (x,y) ]
379 abate 375 | [ a = LIDENT; "::"; x = regexp -> SeqCapture (ident a,x) ]
380 abate 4 | [ x = regexp; "*" -> Star x
381     | x = regexp; "*?" -> WeakStar x
382     | x = regexp; "+" -> Seq (x, Star x)
383     | x = regexp; "+?" -> Seq (x, WeakStar x)
384 abate 71 | x = regexp; "?" -> Alt (x, Epsilon)
385 abate 4 | x = regexp; "??" -> Alt (Epsilon, x) ]
386     | [ "("; x = regexp; ")" -> x
387 abate 225 | "("; a = LIDENT; ":="; c = const; ")" ->
388 abate 375 Elem (mk loc (Constant ((ident a,c))))
389 abate 66 | UIDENT "PCDATA" -> string_regexp
390 abate 81 | i = STRING1; "--"; j = STRING1 ->
391 abate 310 let i = Chars.mk_int (parse_char loc i)
392     and j = Chars.mk_int (parse_char loc j) in
393 abate 66 Elem (mk loc (Internal (Types.char (Chars.char_class i j))))
394 abate 81 | s = STRING1 ->
395 abate 18 List.fold_right
396 abate 525 (fun c accu ->
397 abate 310 let c = Chars.mk_int c in
398 abate 18 let c = Chars.atom c in
399 abate 525 Seq (Elem (mknoloc (Internal (Types.char c))), accu))
400     (seq_of_string s)
401 abate 66 Epsilon
402 abate 4 | e = pat LEVEL "simple" -> Elem e
403     ]
404     ];
405    
406     pat: [
407 abate 332 [ x = pat; LIDENT "where";
408 abate 529 b = LIST1 [ a = uident; "="; y = pat -> (a,y)
409 abate 338 | LIDENT -> error loc "Type/pattern identifiers must be capitalized"
410     ] SEP "and"
411 abate 4 -> mk loc (Recurs (x,b)) ]
412     | RIGHTA [ x = pat; "->"; y = pat -> mk loc (Arrow (x,y)) ]
413 abate 6 | "no_arrow" [ x = pat; "|"; y = pat -> mk loc (Or (x,y)) ]
414 abate 121 | "simple" [ x = pat; "&"; y = pat -> mk loc (And (x,y))
415 abate 99 | x = pat; "\\"; y = pat -> mk loc (Diff (x,y)) ]
416 abate 4 |
417 abate 159 [ "{"; r = record_spec; "}" -> mk loc (Record (true,r))
418     | "{|"; r = record_spec; "|}" -> mk loc (Record (false,r))
419 abate 4 | LIDENT "_" -> mk loc (Internal Types.any)
420 abate 375 | a = LIDENT -> mk loc (Capture (ident a))
421 abate 225 | "("; a = LIDENT; ":="; c = const; ")" ->
422 abate 375 mk loc (Constant (ident a,c))
423 abate 501 | schema = UIDENT; "#"; typ = [ UIDENT | LIDENT | keyword ];
424     k = OPT [ "as"; k = [ "element" | "type" | "attribute" ] -> k ] ->
425     let kind =
426     match k with
427     | None -> `Any
428     | Some "element" -> `Element
429     | Some "type" -> `Type
430     | Some "attribute" -> `Attribute
431     | _ -> assert false
432     in
433     mk loc (SchemaVar (kind, schema, typ))
434 abate 529 | a = uident -> mk loc (PatVar a)
435 abate 4 | i = INT ; "--"; j = INT ->
436 abate 222 let i = Intervals.mk i
437     and j = Intervals.mk j in
438 abate 52 mk loc (Internal (Types.interval (Intervals.bounded i j)))
439     | i = INT ->
440 abate 222 let i = Intervals.mk i in
441 abate 52 mk loc (Internal (Types.interval (Intervals.atom i)))
442 abate 81 | "*"; "--"; j = INT ->
443 abate 222 let j = Intervals.mk j in
444 abate 52 mk loc (Internal (Types.interval (Intervals.left j)))
445 abate 81 | i = INT; "--"; "*" ->
446 abate 222 let i = Intervals.mk i in
447 abate 52 mk loc (Internal (Types.interval (Intervals.right i)))
448 abate 19 | i = char ->
449     mk loc (Internal (Types.char (Chars.char_class i i)))
450 abate 13 | i = char ; "--"; j = char ->
451 abate 18 mk loc (Internal (Types.char (Chars.char_class i j)))
452 abate 529 | "`"; c = tag_type -> c
453     | c = const ->
454     (match c with
455     | Const_atom (ns,l) -> mk loc (AtomT (ns,Some l))
456     | Const_internal c ->
457     mk loc (Internal (Types.constant c))
458     )
459 abate 4 | "("; l = LIST1 pat SEP ","; ")" -> multi_prod loc l
460     | "["; r = [ r = regexp -> r | -> Epsilon ];
461     q = [ ";"; q = pat -> q
462 abate 249 | -> mknoloc (Internal (Sequence.nil_type)) ];
463 abate 4 "]" -> mk loc (Regexp (r,q))
464 abate 332 | "<"; t =
465 abate 529 [ x = tag_type -> x
466     | "("; t = pat; ")" -> t ];
467 abate 81 a = attrib_spec; ">"; c = pat ->
468 abate 529 (* let t = mk loc (Prod (mk loc (Internal Sequence.nil_type), t)) in *)
469 abate 110 mk loc (XmlT (t, multi_prod loc [a;c]))
470 abate 81 | s = STRING2 ->
471 abate 525 let s =
472     List.map
473     (fun c ->
474     mknoloc (Internal
475     (Types.char
476     (Chars.atom
477     (Chars.mk_int c)))))
478     (seq_of_string s) in
479     let s = s @ [mknoloc (Internal (Sequence.nil_type))] in
480 abate 63 multi_prod loc s
481 abate 4 ]
482    
483     ];
484    
485     record_spec:
486 abate 339 [ [ r = LIST0 [ l = [LIDENT | UIDENT | keyword ]; "=";
487 abate 81 o = [ "?" -> true | -> false];
488 abate 229 x = pat ->
489     let x = if o then mk loc (Optional x) else x in
490 abate 374 (label l, x)
491 abate 4 ] SEP ";" ->
492 abate 233 make_record loc r
493 abate 4 ] ];
494    
495 abate 13 char:
496     [
497 abate 310 [ c = STRING1 -> Chars.mk_int (parse_char loc c) ]
498 abate 13 ];
499    
500    
501 abate 4 const:
502     [
503 abate 529 [ i = INT -> Const_internal (Types.Integer (Intervals.mk i))
504     | "`"; a = tag -> a
505     | c = char -> Const_internal (Types.Char c) ]
506 abate 4 ];
507    
508    
509     attrib_spec:
510 abate 159 [ [ r = record_spec -> mk loc (Record (true,r))
511 abate 252 | "("; t = pat; ")" -> t
512     | "{"; r = record_spec; "}" -> mk loc (Record (true,r))
513     | "{|"; r = record_spec; "|}" -> mk loc (Record (false,r))
514     ] ];
515 abate 4
516     expr_record_spec:
517     [ [ r = LIST1
518 abate 339 [ l = [LIDENT | UIDENT | keyword ]; "="; x = expr ->
519 abate 374 (label l,x) ]
520 abate 4 SEP ";" ->
521 abate 316 exp loc (RecordLitt (make_record loc r))
522 abate 4 ] ];
523    
524     expr_attrib_spec:
525     [ [ r = expr_record_spec -> r ]
526     | [ e = expr LEVEL "no_appl" -> e
527 abate 316 | -> exp loc (RecordLitt (LabelMap.empty))
528 abate 4 ]
529     ];
530     END
531    
532 abate 10 let pat = Grammar.Entry.parse pat
533 abate 81 and expr = Grammar.Entry.parse expr
534     and prog = Grammar.Entry.parse prog
535 abate 431 and top_phrases = Grammar.Entry.parse top_phrases
536 abate 10
537 abate 495 let sync () =
538     match !Wlexer.lexbuf with
539     | None -> ()
540     | Some lb ->
541     let rec aux () =
542     match !Wlexer.last_tok with
543     | ("",";;") | ("EOI","") -> ()
544     | _ ->
545     Wlexer.last_tok := Wlexer.token Wlexer.latin1_engine lb;
546     aux ()
547     in
548     aux ()

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