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

Contents of /parser/parser.ml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 552 - (hide annotations)
Tue Jul 10 17:43:53 2007 UTC (5 years, 10 months ago) by abate
File size: 16454 byte(s)
[r2003-06-30 21:35:52 by cvscast] Review internal pretting printing of namespaces -- Alain

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

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