parser.ml 16.6 KB
Newer Older
1 2
open Location
open Ast
3
open Ident
4
open Printf
5

6
(*
7
let ()  = Grammar.error_verbose := true
8
*)
9

10 11
exception Error of string
let error (i,j) s = Location.raise_loc i j (Error s)
12

13
let gram    = Grammar.gcreate Ulexer.lex
14

15 16
let true_atom = Atoms.V.mk_ascii "true"
let false_atom = Atoms.V.mk_ascii "false"
17 18
let true_type = Types.atom (Atoms.atom true_atom)
let false_type = Types.atom (Atoms.atom false_atom)
19

20
let parse_ident = U.mk
21

22
let id_dummy = ident (U.mk "$$$")
23

24
let label = parse_ident
25
let ident s = ident (parse_ident s)
26

27
let prog    = Grammar.Entry.create gram "prog"
28
let top_phrases   = Grammar.Entry.create gram "toplevel phrases"
29 30 31 32
let expr    = Grammar.Entry.create gram "expression"
let pat     = Grammar.Entry.create gram "type/pattern expression"
let regexp  = Grammar.Entry.create gram "type/pattern regexp"
		
33 34
let exp pos e = LocatedExpr (loc_of_pos pos,e)

35 36 37 38 39
let rec multi_prod loc = function
  | [ x ] -> x
  | x :: l -> mk loc (Prod (x, multi_prod loc l))
  | [] -> assert false
      
40
let rec tuple = function
41
  | [ x ] -> x
42
  | x :: l -> Pair (x, tuple l)
43
  | [] -> assert false
44 45

let tuple_queue = 
46
  List.fold_right (fun x q -> Pair (x, q))
47 48


49
let char = mknoloc (Internal (Types.char Chars.any))
50
let string_regexp = Star (Elem char)
51
	       
52
let cst_nil =  Atom (U.mk "nil")
53
let pat_nil = mknoloc (Internal (Sequence.nil_type))
54
		 
55
let seq_of_string s =
56 57
  let s = Encodings.Utf8.mk s in
  let rec aux i j =
58 59
    if Encodings.Utf8.equal_index i j then []
    else let (c,i) = Encodings.Utf8.next s i in c :: (aux i j)
60
  in
61
  aux (Encodings.Utf8.start_index s) (Encodings.Utf8.end_index s)
62

63

64
let parse_char loc s =
65 66
  match seq_of_string s with
    | [ c ] -> c
67
    | _ -> error loc "Character litteral must have length 1"
68

69 70
let include_stack = ref []

71 72 73 74
let protect_exn f g =
  try let x = f () in g (); x
  with e -> g (); raise e

75 76 77 78
let is_fun_decl =
   Grammar.Entry.of_parser gram "[is_fun_decl]"
     (fun strm ->
       match Stream.npeek 3 strm with
79 80
	 | [ ("", "fun"); ("IDENT", _); ("", "(") ]
	 | [ ("IDENT", _) ; ("", "(") ; _ ] -> ()
81 82 83
	 | _ -> raise Stream.Failure
     )

84
EXTEND
85
  GLOBAL: top_phrases prog expr pat regexp;
86 87

  top_phrases: [
88
    [ l = LIST0 phrase; ";;" -> List.flatten l  ]
89
  ];
90 91

  prog: [
92
    [ l = LIST0 [ p = phrase ; OPT ";;" -> p ]; EOI -> List.flatten l ]
93 94
  ];

95
  uident: [ [ x = IDENT -> ident x ] ];
96

97
  phrase: [
98 99 100 101
    [ (f,p,e) = let_binding -> 
	if f then [ mk loc (FunDecl e) ] else
	  [ mk loc (LetDecl (p,e)) ]
    | (_,p,e1) = let_binding; "in"; e2 = expr LEVEL "top"->
102
        [ mk loc (EvalStatement (exp loc (Match (e1,[p,e2])))) ]
103
    | "type"; x = uident; "="; t = pat -> [ mk loc (TypeDecl (x,t)) ]
104
    | "schema"; name = IDENT; "="; uri = STRING2 ->
105
	protect_op "schema";
106
        let schema_doc = Schema_xml.pxp_tree_of uri in
107 108
        let schema = Schema_parser.parse_schema schema_doc in
        [ mk loc (SchemaDecl (name, schema))]
109 110 111 112 113
    | (name,ns) = namespace_binding ->
	[ mk loc (Namespace (name, ns)) ]
    | (name,ns) = namespace_binding; "in"; e2 = expr LEVEL "top" ->
	let e = exp loc (NamespaceIn (name, ns, e2)) in
        [ mk loc (EvalStatement (exp loc e)) ]
114
    | "debug"; d = debug_directive -> [ mk loc (Debug d) ]
115 116 117
    | DIRECTIVE "#utf8" -> Ulexer.enc := Ulexing.Utf8; [ ]
    | DIRECTIVE "#latin1" -> Ulexer.enc := Ulexing.Latin1; [ ]
    | DIRECTIVE "#ascii" -> Ulexer.enc := Ulexing.Ascii; [ ]
118 119
    | DIRECTIVE "#quit" -> [ mk loc (Directive `Quit) ]
    | DIRECTIVE "#env" -> [ mk loc (Directive `Env) ]
120
    | DIRECTIVE "#reinit_ns" -> [ mk loc (Directive `Reinit_ns) ]
121
    | "include"; s = STRING2 ->
122 123 124 125
	let s = 
	  if Filename.is_relative s 
	  then Filename.concat (Location.current_dir ()) s
	  else s in
126 127
	protect_op "File inclusion";
	(* avoid looping; should issue an error ? *)
128 129
	(* it is possible to have looping with x/../x/../x/.. ....
	   Need to canonicalize filename *)
130 131 132 133
	if List.mem s !include_stack then [] 
	else (
	  include_stack := s :: !include_stack;
	  Location.push_source (`File s);
134 135
	  let saved_enc = !Ulexer.enc in
	  Ulexer.enc := Ulexing.Latin1;
136 137 138
	  protect_exn
	    (fun () ->
	       let chan = open_in s in
139 140 141 142 143
	       protect_exn
		 (fun () ->
		    let input = Stream.of_channel chan in
		    Grammar.Entry.parse prog input)
		 (fun () -> close_in chan))
144
	    (fun () ->
145
	       Ulexer.enc := saved_enc;
146 147
	       Location.pop_source ();
	       include_stack := List.tl !include_stack)
148
	)
149
    ] | 
150
    [ e = expr -> [ mk loc (EvalStatement e) ]
151 152 153 154
    ]
  ];

  debug_directive: [
155 156 157 158 159
    [ IDENT "filter"; t = pat; p = pat -> `Filter(t,p)
    | IDENT "accept"; p = pat -> `Accept p
    | IDENT "compile"; t = pat; p = LIST1 pat -> `Compile (t,p)
    | IDENT "sample"; t = pat -> `Sample t
    | IDENT "subtype"; t1 = pat; t2 = pat -> `Subtype (t1,t2)
160
    ]
161
  ];
162

163 164 165 166 167
  keyword: [
    [ a = 
	[ "map" | "match" | "with" | "try" | "xtransform"
	| "if" | "then"	| "else"
	| "transform" | "fun" | "in"
168
	| "let" | "type" | "debug" | "include"
169
        | "and" | "validate" | "schema" | "namespace" | "ref"
170 171 172 173 174
	]
	-> a
    ]
  ];

175 176
  expr: [
    "top" RIGHTA
177 178
    [ "match"; e = SELF; "with"; b = branches -> 
	exp loc (Match (e,b))
179
    | "try"; e = SELF; "with"; b = branches -> 
180
	exp loc (Try (e,b))
181 182 183 184
    | "map"; e = SELF; "with"; b = branches -> 
	exp loc (Map (e,b))
    | "xtransform"; e = SELF; "with"; b = branches -> 
	exp loc (Xtrans (e,b))
185
    | "if"; e = SELF; "then"; e1 = SELF; "else"; e2 = SELF ->
186 187
	let p1 = mk loc (Internal true_type)
	and p2 = mk loc (Internal false_type) in
188
	exp loc (Match (e, [p1,e1; p2,e2]))
189
    | "transform"; e = SELF; "with"; b = branches -> 
190
	exp loc (Transform (e,b))
191 192
    | "validate"; e = SELF; "with"; schema = IDENT; "#";
      typ = [ IDENT | keyword ] ->
193
        exp loc (Validate (e, schema, typ))
194
    | "fun"; (f,a,b) = fun_decl ->
195
	exp loc (Abstraction { fun_name = f; fun_iface = a; fun_body = b })
196
    | (_,p,e1) = let_binding; "in"; e2 = expr LEVEL "top"->
197
        exp loc (Match (e1,[p,e2]))
198 199
    | (name,ns) = namespace_binding; "in"; e2 = expr LEVEL "top" ->
	exp loc (NamespaceIn (name, ns, e2))
200
    | e = expr; ":"; p = pat ->
201
	exp loc (Forget (e,p))
202 203 204 205 206 207 208 209
    | e1 = expr; ";"; e2 = expr ->
	exp loc (Match (e1, [pat_nil,e2]))
    | "ref"; p = pat; e = expr ->
	exp loc (Ref (e,p))
    ]
    |
    [ e1 = expr; ":="; e2 = expr ->
	exp loc (Apply (Dot (e1, U.mk "set"), e2))
210
    ]
211 212 213 214 215 216
    | 
    [ e1 = expr; op = ["=" | "<=" | "<<" | ">>" | ">=" ]; e2 = expr -> 
	let op = match op with
	  | "<<" -> "<"
	  | ">>" -> ">"
	  | s -> s in
217
	exp loc (Op (op,[e1;e2]))
218 219
    ]

220
    | 
221
    [ e1 = expr; op = ["+" | "-" | "@" ]; e2 = expr -> 
222
	exp loc (Op (op,[e1;e2]))
223
    | e = expr; "\\"; l = [IDENT | keyword ] -> 
224
	exp loc (RemoveField (e, label l)) 
225 226
    ]
    |
227
    [ e1 = expr; op = ["*"]; e2 = expr -> exp loc (Op (op,[e1;e2]))  
228 229 230 231 232
    | e = expr; op = "/"; p = pat ->

	let tag = mk loc (Internal (Types.atom (Atoms.any))) in
	let att = mk loc (Internal Types.Record.any) in
	let any = mk loc (Internal (Types.any)) in
233
	let re = Star(Alt(SeqCapture(id_dummy,Elem p), Elem any)) in
234 235
	let ct = mk loc (Regexp (re,any)) in
        let p = mk loc (XmlT (tag, multi_prod loc [att;ct])) in
236
	let b = (p,  Var id_dummy) in
237
	exp loc (Transform (e,[b]))
238
    ]
239
    |
240
    [ e = expr;  "."; l = [IDENT | keyword ] -> 
241
	exp loc (Dot (e, label l)) 
242
    ]  
243
 
244
    |
245 246 247 248 249 250 251 252 253 254 255
    [ op = [ IDENT "flatten"
	   | IDENT "load_xml"
	   | IDENT "load_file" | IDENT "load_file_utf8"
           | IDENT "getenv"
	   | IDENT "load_html"
	   | IDENT "print_xml" | IDENT "print_xml_utf8"
	   | IDENT "print"
	   | IDENT "int_of"
	   | IDENT "string_of"
	   | IDENT "atom_of"
	   | IDENT "raise"
256
	   ]; 
257
      e = expr -> exp loc (Op (op,[e]))
258
    | op = [ IDENT "dump_to_file" | IDENT "dump_to_file_utf8" ];
259
      e1 = expr LEVEL "no_appl"; e2 = expr -> exp loc (Op (op, [e1;e2])) 
260 261
    | e1 = SELF; IDENT "div"; e2 = expr -> exp loc (Op ("/", [e1;e2]))
    | e1 = SELF; IDENT "mod"; e2 = expr -> exp loc (Op ("mod", [e1;e2]))
262
    | e1 = SELF; e2 = expr -> exp loc (Apply (e1,e2))
263 264
    ]

265
    | "no_appl" 
266 267
    [ 
      "("; l = LIST1 expr SEP ","; ")" -> exp loc (tuple l)
268
    | "[";  l = LIST0 seq_elem; e = OPT [ ";"; e = expr -> e ]; 
269
      loc_end = ["]" -> loc] ->
270
	let e = match e with Some e -> e | None -> cst_nil in
271 272
        let e = exp loc_end e in
        let (_,loc_end) = loc_end in
273 274 275
	let l = List.fold_right 
		  (fun x q ->
		     match x with
276
		       | `String (loc,i,j,s) -> exp loc (String (i,j,s,q))
277
		       | `Elems ((loc,_),x) -> exp (loc,loc_end) (Pair(x,q))
278 279 280 281
		       | `Explode x -> Op ("@",[x;q])
		  ) l e
	in
	exp loc l
282
    | "<"; t = [ "("; e = expr; ")" -> e
283
	       | a = tag -> exp loc a
284
	       ];
285
	a = expr_attrib_spec; ">"; c = expr ->
286
	  exp loc (Xml (t, Pair (a,c)))
287
    | "{"; r = [ expr_record_spec | -> exp loc (RecordLitt []) ]; "}" -> r
288
    | s = STRING2 ->
289
	let s = U.mk s in
290
	exp loc (String (U.start_index s, U.end_index s, s, cst_nil))
291
    | a = uident -> exp loc (Var a)
292 293
    | "!"; e = expr ->
	exp loc (Apply (Dot (e, U.mk "get"), cst_nil))
294 295 296
    | i = INT -> exp loc (Integer (Intervals.V.mk i))
    | "`"; a = tag -> a
    | c = char -> exp loc (Char c)
297 298 299
    ]

  ];
300

301
  tag: [ [ a = [ IDENT | keyword ] -> exp loc (Atom (parse_ident a)) ] ];
302 303

  tag_type: [
304
    [ IDENT "_" ->  mk loc (Internal (Types.atom Atoms.any))
305
    | a = [ IDENT | keyword ] -> mk loc (Cst (Atom (parse_ident a)))
306
    | t = ANY_IN_NS -> mk loc (NsT (parse_ident t)) 
307 308 309
    ]
  ];

310
  seq_elem: [
311
    [ x = STRING1 -> 
312
	let s = U.mk x in
313
	`String (loc, U.start_index s, U.end_index s, s)
314
    | e = expr LEVEL "no_appl" -> `Elems (loc,e)
315
    | "!"; e = expr LEVEL "no_appl" -> `Explode e
316 317
    ]
  ];
318 319 320
	
  namespace_binding: [
    [ "namespace"; 
321
	name = [ name = [ IDENT | keyword ]; "=" ->
322 323 324
		   parse_ident name
	       | -> U.mk "" ];
	uri = STRING2 ->
325
	  let ns = Ns.mk (parse_ident uri) in
326 327 328 329 330
	  (name,ns)
    ]
  ];

  
331
  let_binding: [
332 333
    [ "let"; is_fun_decl; OPT "fun"; (f,a,b) = fun_decl ->
	let f = match f with Some x -> x | None -> assert false in
334
	let p = mk loc (PatVar f) in
335
	let abst = { fun_name = Some f; fun_iface = a; fun_body = b } in
336
        let e = exp loc (Abstraction abst) in
337
        (true,p,e)
338 339
    | "let"; p = pat; "="; e = expr -> (false,p,e)
    | "let"; p = pat; ":"; t = pat; "="; e = expr -> (false,p, Forget (e,t))
340 341 342
    ] 
  ];

343
 fun_decl_after_lparen: [
344
(* need an hack to do this, because both productions would
345
   match   [ OPT IDENT; "("; pat ] .... *)
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367
   [ p1 = pat LEVEL "no_arrow";
     res = [ "->"; p2 = pat;
	     a = [ ";"; a = LIST0 arrow SEP ";" -> a | -> [] ];
	     ")"; b = branches -> `Classic (p2,a,b)
	   | ":"; targ1 = pat;
	     args = LIST0 [ ","; arg = pat; ":"; targ = pat -> (arg,targ) ]; 
	     ")"; ":"; tres = pat ; 
	     "="; body = expr ->
	       `Compact (targ1,args,tres,body)
	   ] ->
       match res with
	 | `Classic (p2,a,b) -> (p1,p2)::a,b
	 | `Compact (targ1,args,tres,body) ->
	     let args = (p1,targ1) :: args in
	     let targ = multi_prod nopos (List.map snd args) in
	     let arg = multi_prod nopos (List.map fst args) in
	     let b = [arg, body] in
	     let a = [targ,tres] in
	     (a,b) ] ];


 fun_decl: [
368 369 370
   [ f = OPT IDENT; "("; (a,b) = fun_decl_after_lparen ->
       let f = match f with Some x -> Some (ident x) | None -> None in
       (f,a,b)
371
   ]
372 373
 ];

374
 arrow: [
375
    [ t1 = pat LEVEL "no_arrow"; "->"; t2 = pat -> (t1,t2)]
376 377 378
  ];

  branches: [
379
    [ OPT "|"; l = LIST1 branch SEP "|" -> l ]
380 381 382
  ];

  branch: [
383
    [ p = pat LEVEL "no_arrow"; "->"; e = expr -> (p,e) ]
384 385 386 387
  ];

	  
  regexp: [ 
388 389 390 391 392
    [ x = regexp; "|"; y = regexp -> 
	match (x,y) with
	  | Elem x, Elem y -> Elem (mk loc (Or (x,y)))
	  | _ -> Alt (x,y) 
    ]
393
  | [ x = regexp; y = regexp -> Seq (x,y) ]
394
  | [ a = IDENT; "::"; x = regexp -> SeqCapture (ident a,x) ]
395 396 397 398
  | [ x = regexp; "*" -> Star x
    | x = regexp; "*?" -> WeakStar x
    | x = regexp; "+" -> Seq (x, Star x)
    | x = regexp; "+?" -> Seq (x, WeakStar x)
399
    | x = regexp; "?" ->  Alt (x, Epsilon)
400 401
    | x = regexp; "??" -> Alt (Epsilon, x) ]
  | [ "("; x = regexp; ")" -> x
402 403
    | "("; a = uident; ":="; c = expr; ")" -> 
	Elem (mk loc (Constant ((a,c))))
404
    | IDENT "PCDATA" -> string_regexp
405
    | i = STRING1; "--"; j = STRING1 ->
406 407
	let i = Chars.V.mk_int (parse_char loc i)
	and j = Chars.V.mk_int (parse_char loc j) in
408
        Elem (mk loc (Internal (Types.char (Chars.char_class i j))))
409
    |  s = STRING1 ->
410
	List.fold_right
411
	  (fun c accu -> 
412
	     let c = Chars.V.mk_int c in
413
	     let c = Chars.atom c in
414 415
	     Seq (Elem (mknoloc (Internal (Types.char c))), accu))
	  (seq_of_string s)
416 417
	  Epsilon ]
    | [ e = pat LEVEL "simple" -> Elem e
418 419 420 421
    ]
  ];

  pat: [ 
422 423
      [ x = pat; IDENT "where"; 
        b = LIST1 [ a = uident; "="; y = pat -> (a,y) ] SEP "and"
424 425
            -> mk loc (Recurs (x,b)) ]
    | RIGHTA [ x = pat; "->"; y = pat -> mk loc (Arrow (x,y)) ]
426
    | "no_arrow" [ x = pat; "|"; y = pat -> mk loc (Or (x,y)) ] 
427
    | "simple" [ x = pat; "&"; y = pat -> mk loc (And (x,y)) 
428
	       | x = pat; "\\"; y = pat -> mk loc (Diff (x,y)) ]
429
    | 
430 431
      [ "{"; r = record_spec; "}" -> mk loc (Record (true,r))
      | "{|"; r = record_spec; "|}" -> mk loc (Record (false,r))
432 433 434 435 436
      | "ref"; p = pat ->
	  let get_fun = mk loc (Arrow (pat_nil, p)) 
	  and set_fun = mk loc (Arrow (p, pat_nil)) in
	  let fields = [ label "get", get_fun; label "set", set_fun ] in
	  mk loc (Record (false, fields))
437
      | IDENT "_" -> mk loc (Internal Types.any)
438
      | "("; a = IDENT; ":="; c = expr; ")" -> 
439
	  mk loc (Constant (ident a,c))
440
      | schema = IDENT; "#"; typ = [ IDENT | keyword ];
441 442 443 444 445 446 447 448 449 450
        k = OPT [ "as"; k = [ "element" | "type" | "attribute" ] -> k ] ->
          let kind =
            match k with
            | None -> `Any
            | Some "element" -> `Element
            | Some "type" -> `Type
            | Some "attribute" -> `Attribute
            | _ -> assert false
          in
          mk loc (SchemaVar (kind, schema, typ))
451 452
      | a = uident -> 
	  mk loc (PatVar a)
453
      | i = INT ; "--"; j = INT -> 
454 455
          let i =  Intervals.V.mk i 
	  and j =  Intervals.V.mk j in
456 457
          mk loc (Internal (Types.interval (Intervals.bounded i j)))
      | i = INT -> 
458
          let i =  Intervals.V.mk i  in
459
          mk loc (Internal (Types.interval (Intervals.atom i)))
460
      | "*"; "--"; j = INT ->
461
	  let j =  Intervals.V.mk j in
462
          mk loc (Internal (Types.interval (Intervals.left j)))
463
      | i = INT; "--"; "*" ->
464
	  let i = Intervals.V.mk i in
465
          mk loc (Internal (Types.interval (Intervals.right i)))
466 467
      | i = char ->
          mk loc (Internal (Types.char (Chars.char_class i i)))
468
      | i = char ; "--"; j = char ->
469
          mk loc (Internal (Types.char (Chars.char_class i j)))
470
      | "`"; c = tag_type -> c
471 472 473
      | "("; l = LIST1 pat SEP ","; ")" -> multi_prod loc l
      | "["; r = [ r = regexp -> r | -> Epsilon ];
             q = [ ";"; q = pat -> q 
474
                 | -> pat_nil ]; 
475
             "]" -> mk loc (Regexp (r,q))
476
      | "<"; t =
477 478
            [ x = tag_type -> x
            | "("; t = pat; ")" -> t ];
479
	a = attrib_spec; ">"; c = pat ->
480
          mk loc (XmlT (t, multi_prod loc [a;c]))
481
      | s = STRING2 ->
482 483 484 485 486 487
	  let s = 
	    List.map 
	      (fun c -> 
		 mknoloc (Internal
			     (Types.char
				(Chars.atom
488
				   (Chars.V.mk_int c))))) 
489 490
	      (seq_of_string s) in
	  let s = s @ [mknoloc (Internal (Sequence.nil_type))] in
491
	  multi_prod loc s
492 493 494 495 496
      ]
    
  ];

  record_spec:
497
    [ [ r = LIST0 [ l = [IDENT | keyword ]; "=";
498
                  o = [ "?" -> true | -> false]; 
499 500
                  x = pat -> 
		    let x = if o then mk loc (Optional x) else x in
501
		    (label l, x)
502
                ] SEP ";" ->
503
	  r
504 505
      ] ];
  
506 507
  char:
    [ 
508
      [ c = STRING1 -> Chars.V.mk_int (parse_char loc c) ]
509 510 511
    ];
     

512
  attrib_spec:
513
    [ [ r = LIST0 [ l = [IDENT | keyword ]; "=";
514 515 516 517 518 519
                  o = [ "?" -> true | -> false]; 
                  x = pat; OPT ";" -> 
		    let x = if o then mk loc (Optional x) else x in
		    (label l, x)
                ] ->
	  mk loc (Record (true,r)) 
520 521 522 523
      | "("; t = pat; ")" -> t 
      | "{"; r = record_spec; "}" -> mk loc (Record (true,r))
      | "{|"; r = record_spec; "|}" -> mk loc (Record (false,r))
      ] ];
524 525 526

  expr_record_spec:
    [ [ r = LIST1
527
	      [ l = [IDENT | keyword ]; "="; x = expr LEVEL "no_appl" -> 
528
		  (label l,x) ] 
529
	       SEP ";"  ->
530
	  exp loc (RecordLitt r)
531
      ] ];
532

533
  expr_attrib_spec:
534
    [ [ r = LIST1
535
	      [ l = [IDENT | keyword ]; "="; x = expr LEVEL "no_appl"; OPT ";" -> 
536 537 538
		  (label l,x) ] ->
	  exp loc (RecordLitt r)
      ]
539
    | [ e = expr LEVEL "no_appl" -> e 
540
      | -> exp loc (RecordLitt []) 
541 542 543 544
      ] 
    ];
END

545
let pat = Grammar.Entry.parse pat
546 547
and expr = Grammar.Entry.parse expr
and prog = Grammar.Entry.parse prog
548 549
and top_phrases = Grammar.Entry.parse top_phrases

550
let sync () = 
551
  match !Ulexer.lexbuf with
552 553 554
    | None -> ()
    | Some lb ->
	let rec aux () =
555
	  match !Ulexer.last_tok with
556 557
	    | ("",";;") | ("EOI","") -> ()
	    | _ -> 
558
		Ulexer.last_tok := fst (Ulexer.token lb); 
559 560 561
		aux ()
	in
	aux ()