1 (* Copyright (C) 2005, HELM Team.
3 * This file is part of HELM, an Hypertextual, Electronic
4 * Library of Mathematics, developed at the Computer Science
5 * Department, University of Bologna, Italy.
7 * HELM is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * HELM is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HELM; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 * For details, see the HELM World-Wide-Web page,
23 * http://helm.cs.unibo.it/
31 let exc_located_wrapper f =
35 | Ploc.Exc (_, End_of_file) -> raise End_of_file
36 | Ploc.Exc (floc, Stream.Error msg) ->
37 raise (HExtlib.Localized (floc,CicNotationParser.Parse_error msg))
38 | Ploc.Exc (floc, HExtlib.Localized(_,exn)) ->
39 raise (HExtlib.Localized
40 (floc,CicNotationParser.Parse_error (Printexc.to_string exn)))
41 | Ploc.Exc (floc, exn) ->
42 raise (HExtlib.Localized
43 (floc,CicNotationParser.Parse_error (Printexc.to_string exn)))
45 type parsable = Grammar.parsable * Ulexing.lexbuf
47 let parsable_statement status buf =
48 let grammar = CicNotationParser.level2_ast_grammar status in
49 Grammar.parsable grammar (Obj.magic buf), buf
51 let parse_statement grafite_parser parsable =
53 (fun () -> (Grammar.Entry.parse_parsable grafite_parser (fst parsable)))
55 let strm_of_parsable (_,buf) = buf
57 let add_raw_attribute ~text t = N.AttributedTerm (`Raw text, t)
59 let default_associativity = Gramext.NonA
61 let mk_rec_corec src ind_kind defs loc =
62 let attrs = src, `Definition, `Regular in
63 (loc, N.LetRec (ind_kind, defs, attrs))
65 let nmk_rec_corec src ind_kind defs loc index =
66 let loc,t = mk_rec_corec src ind_kind defs loc in
70 let nnon_punct_of_punct = function
71 | G.Skip loc -> G.NSkip loc
72 | G.Unfocus loc -> G.NUnfocus loc
73 | G.Focus (loc,l) -> G.NFocus (loc,l)
76 type by_continuation =
78 | BYC_weproved of N.term * string option * N.term option
79 | BYC_letsuchthat of string * N.term * string * N.term
80 | BYC_wehaveand of string * N.term * string * N.term
82 let mk_parser statement lstatus =
83 (* let grammar = CicNotationParser.level2_ast_grammar lstatus in *)
84 let term = CicNotationParser.term lstatus in
85 let let_defs = CicNotationParser.let_defs lstatus in
86 let let_codefs = CicNotationParser.let_codefs lstatus in
87 let protected_binder_vars = CicNotationParser.protected_binder_vars lstatus in
88 (* {{{ parser initialization *)
90 GLOBAL: term statement;
91 constructor: [ [ name = IDENT; SYMBOL ":"; typ = term -> (name, typ) ] ];
92 tactic_term: [ [ t = term LEVEL "90" -> t ] ];
93 ident_list1: [ [ LPAREN; idents = LIST1 IDENT; RPAREN -> idents ] ];
95 [ IDENT "normalize" ; delta = OPT [ IDENT "nodelta" -> () ] ->
96 let delta = match delta with None -> true | _ -> false in
98 | IDENT "whd" ; delta = OPT [ IDENT "nodelta" -> () ] ->
99 let delta = match delta with None -> true | _ -> false in
102 sequent_pattern_spec: [
106 path = OPT [SYMBOL ":" ; path = tactic_term -> path ] ->
107 (id,match path with Some p -> p | None -> N.UserInput) ];
108 goal_path = OPT [ SYMBOL <:unicode<vdash>>; term = tactic_term -> term ] ->
110 match goal_path, hyp_paths with
111 None, [] -> Some N.UserInput
113 | Some goal_path, _ -> Some goal_path
122 [ "match" ; wanted = tactic_term ;
123 sps = OPT [ "in"; sps = sequent_pattern_spec -> sps ] ->
125 | sps = sequent_pattern_spec ->
129 let wanted,hyp_paths,goal_path =
130 match wanted_and_sps with
131 wanted,None -> wanted, [], Some N.UserInput
132 | wanted,Some (hyp_paths,goal_path) -> wanted,hyp_paths,goal_path
134 wanted, hyp_paths, goal_path ] ->
136 None -> None,[],Some N.UserInput
139 inverter_param_list: [
140 [ params = tactic_term ->
141 let deannotate = function
142 | N.AttributedTerm (_,t) | t -> t
143 in match deannotate params with
144 | N.Implicit _ -> [false]
145 | N.UserInput -> [true]
147 List.map (fun x -> match deannotate x with
148 | N.Implicit _ -> false
149 | N.UserInput -> true
150 | _ -> raise (Invalid_argument "malformed target parameter list 1")) l
152 (*CSC: new NCicPp.status is the best I can do here without changing the
154 raise (Invalid_argument ("malformed target parameter list 2\n" ^ NotationPp.pp_term (new NCicPp.status) params)) ]
157 [ SYMBOL ">" -> `LeftToRight
158 | SYMBOL "<" -> `RightToLeft ]
160 int: [ [ num = NUMBER -> int_of_string num ] ];
162 [ SYMBOL "@"; t = tactic_term -> G.NTactic(loc,[G.NApply (loc, t)])
163 | IDENT "applyS"; t = tactic_term -> G.NTactic(loc,[G.NSmartApply(loc, t)])
167 [ id = IDENT ; SYMBOL ":" ; ty = tactic_term -> id,`Decl ty
168 | id = IDENT ; SYMBOL ":" ; ty = tactic_term ;
169 SYMBOL <:unicode<def>> ; bo = tactic_term ->
171 SYMBOL <:unicode<vdash>>;
172 concl = tactic_term -> (List.rev hyps,concl) ] ->
173 G.NTactic(loc,[G.NAssert (loc, seqs)])
174 | SYMBOL "/"; num = OPT NUMBER ;
175 just_and_params = auto_params; SYMBOL "/" ->
176 let just,params = just_and_params in
177 let depth = match num with Some n -> n | None -> "1" in
181 [G.NAuto(loc,(None,["depth",depth]@params))])
182 | Some (`Univ univ) ->
184 [G.NAuto(loc,(Some univ,["depth",depth]@params))])
187 G.NAutoInteractive (loc, (None,["depth",depth]@params))))
188 | SYMBOL "#"; SYMBOL "#" -> G.NMacro (loc, G.NIntroGuess loc)
189 | IDENT "check"; t = tactic_term -> G.NMacro(loc,G.NCheck (loc,t))
190 | IDENT "screenshot"; fname = QSTRING ->
191 G.NMacro(loc,G.Screenshot (loc, fname))
192 | IDENT "cases"; what = tactic_term ; where = pattern_spec ->
193 G.NTactic(loc,[G.NCases (loc, what, where)])
194 | IDENT "change"; "with"; with_what = tactic_term; what = pattern_spec ->
195 G.NTactic(loc,[G.NChange (loc, what, with_what)])
196 | SYMBOL "-"; id = IDENT ->
197 G.NTactic(loc,[G.NClear (loc, [id])])
198 | PLACEHOLDER; num = OPT NUMBER;
199 l = OPT [ SYMBOL "{"; l = LIST1 tactic_term; SYMBOL "}" -> l ] ->
200 G.NTactic(loc,[G.NConstructor (loc, (match num with None -> None | Some x -> Some (int_of_string x)),match l with None -> [] | Some l -> l)])
201 | IDENT "cut"; t = tactic_term -> G.NTactic(loc,[G.NCut (loc, t)])
202 | IDENT "destruct"; just = OPT [ dom = ident_list1 -> dom ];
203 exclude = OPT [ IDENT "skip"; skip = ident_list1 -> skip ]
204 -> let exclude' = match exclude with None -> [] | Some l -> l in
205 G.NTactic(loc,[G.NDestruct (loc,just,exclude')])
206 | IDENT "elim"; what = tactic_term ; where = pattern_spec ->
207 G.NTactic(loc,[G.NElim (loc, what, where)])
208 | IDENT "generalize"; p=pattern_spec ->
209 G.NTactic(loc,[G.NGeneralize (loc, p)])
210 | IDENT "inversion"; what = tactic_term ; where = pattern_spec ->
211 G.NTactic(loc,[G.NInversion (loc, what, where)])
212 | IDENT "lapply"; t = tactic_term -> G.NTactic(loc,[G.NLApply (loc, t)])
213 | IDENT "letin"; name = IDENT ; SYMBOL <:unicode<def>> ; t = tactic_term;
214 where = pattern_spec ->
215 G.NTactic(loc,[G.NLetIn (loc,where,t,name)])
216 | kind = nreduction_kind; p = pattern_spec ->
217 G.NTactic(loc,[G.NReduce (loc, kind, p)])
218 | dir = direction; what = tactic_term ; where = pattern_spec ->
219 G.NTactic(loc,[G.NRewrite (loc, dir, what, where)])
220 | IDENT "try"; tac = SELF ->
221 let tac = match tac with G.NTactic(_,[t]) -> t | _ -> assert false in
222 G.NTactic(loc,[ G.NTry (loc,tac)])
223 | IDENT "repeat"; tac = SELF ->
224 let tac = match tac with G.NTactic(_,[t]) -> t | _ -> assert false in
225 G.NTactic(loc,[ G.NRepeat (loc,tac)])
226 | LPAREN; l = LIST1 SELF; RPAREN ->
229 (List.map (function G.NTactic(_,t) -> t | _ -> assert false) l) in
230 G.NTactic(loc,[G.NBlock (loc,l)])
231 | IDENT "assumption" -> G.NTactic(loc,[ G.NAssumption loc])
232 | SYMBOL "#"; ns=IDENT -> G.NTactic(loc,[ G.NIntros (loc,[ns])])
233 | SYMBOL "#"; SYMBOL "_" -> G.NTactic(loc,[ G.NIntro (loc,"_")])
234 | SYMBOL "*" -> G.NTactic(loc,[ G.NCase1 (loc,"_")])
235 | SYMBOL "*"; "as"; n=IDENT -> G.NTactic(loc,[ G.NCase1 (loc,n)])
240 | IDENT "fast_paramod"
245 (* | IDENT "timeout" *)
251 i = auto_fixed_param -> i,""
252 | i = auto_fixed_param ; SYMBOL "="; v = [ v = int ->
253 string_of_int v | v = IDENT -> v ] -> i,v ];
254 just = OPT [ IDENT "by"; by =
255 [ univ = LIST0 tactic_term SEP SYMBOL "," -> `Univ univ
256 | SYMBOL "_" -> `Trace ] -> by ] -> just,params
262 [ WEPROVED; ty = tactic_term ; LPAREN ; id = IDENT ; RPAREN ; t1 = OPT [IDENT "that" ; IDENT "is" ; IDENT "equivalent" ; "to" ; t2 = tactic_term -> t2] -> BYC_weproved (ty,Some id,t1)
263 | WEPROVED; ty = tactic_term ; t1 = OPT [IDENT "that" ; IDENT "is" ; IDENT "equivalent" ; "to" ; t2 = tactic_term -> t2] ;
264 "done" -> BYC_weproved (ty,None,t1)
266 | "let" ; id1 = IDENT ; SYMBOL ":" ; t1 = tactic_term ;
267 IDENT "such" ; IDENT "that" ; t2=tactic_term ; LPAREN ;
268 id2 = IDENT ; RPAREN -> BYC_letsuchthat (id1,t1,id2,t2)
269 | WEHAVE; t1=tactic_term ; LPAREN ; id1=IDENT ; RPAREN ;"and" ; t2=tactic_term ; LPAREN ; id2=IDENT ; RPAREN ->
270 BYC_wehaveand (id1,t1,id2,t2)
275 rewriting_step_continuation : [
284 [ t1 = SELF; SYMBOL ";"; t2 = SELF ->
287 | G.Seq (_, l) -> l @ [ t2 ]
293 [ tac = SELF; SYMBOL ";";
294 SYMBOL "["; tacs = LIST0 SELF SEP SYMBOL "|"; SYMBOL "]"->
295 (G.Then (loc, tac, tacs))
298 [ IDENT "do"; count = int; tac = SELF ->
299 G.Do (loc, count, tac)
300 | IDENT "repeat"; tac = SELF -> G.Repeat (loc, tac)
304 SYMBOL "["; tacs = LIST0 SELF SEP SYMBOL "|"; SYMBOL "]"->
306 | IDENT "try"; tac = SELF -> G.Try (loc, tac)
308 SYMBOL "["; tacs = LIST0 SELF SEP SYMBOL "|"; SYMBOL "]"->
310 | IDENT "progress"; tac = SELF -> G.Progress (loc, tac)
311 | LPAREN; tac = SELF; RPAREN -> tac
312 | tac = tactic -> tac
316 npunctuation_tactical:
318 [ SYMBOL "[" -> G.NBranch loc
319 | SYMBOL "|" -> G.NShift loc
320 | i = LIST1 int SEP SYMBOL ","; SYMBOL ":" -> G.NPos (loc, i)
321 | SYMBOL "*"; SYMBOL ":" -> G.NWildcard loc
322 | name = IDENT; SYMBOL ":" -> G.NPosbyname (loc, name)
323 | SYMBOL "]" -> G.NMerge loc
324 | SYMBOL ";" -> G.NSemicolon loc
325 | SYMBOL "." -> G.NDot loc
328 nnon_punctuation_tactical:
330 [ IDENT "focus"; goals = LIST1 int -> G.NFocus (loc, goals)
331 | IDENT "unfocus" -> G.NUnfocus loc
332 | IDENT "skip" -> G.NSkip loc
336 [ [ IDENT "definition" ] -> `Definition
337 | [ IDENT "fact" ] -> `Fact
338 | [ IDENT "lemma" ] -> `Lemma
339 | [ IDENT "example" ] -> `Example
340 | [ IDENT "theorem" ] -> `Theorem
341 | [ IDENT "corollary" ] -> `Corollary
346 params = LIST0 protected_binder_vars;
347 SYMBOL ":"; fst_typ = term; SYMBOL <:unicode<def>>; OPT SYMBOL "|";
348 fst_constructors = LIST0 constructor SEP SYMBOL "|";
351 name = IDENT; SYMBOL ":"; typ = term; SYMBOL <:unicode<def>>;
352 OPT SYMBOL "|"; constructors = LIST0 constructor SEP SYMBOL "|" ->
353 (name, true, typ, constructors) ] SEP "with" -> types
357 (fun (names, typ) acc ->
358 (List.map (fun name -> (name, typ)) names) @ acc)
361 let fst_ind_type = (fst_name, true, fst_typ, fst_constructors) in
362 let tl_ind_types = match tl with None -> [] | Some types -> types in
363 let ind_types = fst_ind_type :: tl_ind_types in
369 params = LIST0 protected_binder_vars;
370 SYMBOL ":"; typ = term; SYMBOL <:unicode<def>>; SYMBOL "{" ;
374 SYMBOL ":" -> false,0
375 | SYMBOL ":"; SYMBOL ">" -> true,0
376 | SYMBOL ":"; arity = int ; SYMBOL ">" -> true,arity
379 let b,n = coercion in
381 ] SEP SYMBOL ";"; SYMBOL "}" ->
384 (fun (names, typ) acc ->
385 (List.map (fun name -> (name, typ)) names) @ acc)
388 (params,name,typ,fields)
392 [ IDENT "id"; id = QSTRING; SYMBOL "="; uri = QSTRING ->
393 let alpha = "[a-zA-Z]" in
394 let num = "[0-9]+" in
395 let ident_cont = "\\("^alpha^"\\|"^num^"\\|_\\|\\\\\\)" in
396 let decoration = "\\'" in
397 let ident = "\\("^alpha^ident_cont^"*"^decoration^"*\\|_"^ident_cont^"+"^decoration^"*\\)" in
398 let rex = Str.regexp ("^"^ident^"$") in
399 if Str.string_match rex id 0 then
400 if (try ignore (NReference.reference_of_string uri); true
401 with NReference.IllFormedReference _ -> false)
403 G.Ident_alias (id, uri)
406 (HExtlib.Localized (loc, CicNotationParser.Parse_error (Printf.sprintf "Not a valid uri: %s" uri)))
408 raise (HExtlib.Localized (loc, CicNotationParser.Parse_error (
409 Printf.sprintf "Not a valid identifier: %s" id)))
410 | IDENT "symbol"; symbol = QSTRING;
411 instance = OPT [ LPAREN; IDENT "instance"; n = int; RPAREN -> n ];
412 SYMBOL "="; dsc = QSTRING ->
414 match instance with Some i -> i | None -> 0
416 G.Symbol_alias (symbol, instance, dsc)
418 instance = OPT [ LPAREN; IDENT "instance"; n = int; RPAREN -> n ];
419 SYMBOL "="; dsc = QSTRING ->
421 match instance with Some i -> i | None -> 0
423 G.Number_alias (instance, dsc)
427 [ l = LIST0 [ SYMBOL <:unicode<eta>> (* η *); SYMBOL "." -> () ];
429 N.IdentArg (List.length l, id)
433 [ IDENT "left"; IDENT "associative" -> Gramext.LeftA
434 | IDENT "right"; IDENT "associative" -> Gramext.RightA
435 | IDENT "non"; IDENT "associative" -> Gramext.NonA
439 [ "with"; IDENT "precedence"; n = NUMBER -> int_of_string n ]
442 [ dir = OPT direction; s = QSTRING;
443 assoc = OPT associativity; prec = precedence;
446 [ blob = UNPARSED_AST ->
447 add_raw_attribute ~text:(Printf.sprintf "@{%s}" blob)
448 (CicNotationParser.parse_level2_ast lstatus
449 (Ulexing.from_utf8_string blob))
450 | blob = UNPARSED_META ->
451 add_raw_attribute ~text:(Printf.sprintf "${%s}" blob)
452 (CicNotationParser.parse_level2_meta lstatus
453 (Ulexing.from_utf8_string blob))
457 | None -> default_associativity
458 | Some assoc -> assoc
461 add_raw_attribute ~text:s
462 (CicNotationParser.parse_level1_pattern lstatus prec
463 (Ulexing.from_utf8_string s))
465 (dir, p1, assoc, prec, p2)
469 [ r = NREF -> N.NRefPattern (NReference.reference_of_string r)
470 | IMPLICIT -> N.ImplicitPattern
471 | id = IDENT -> N.VarPattern id
472 | LPAREN; terms = LIST1 SELF; RPAREN ->
476 | terms -> N.ApplPattern terms)
480 [ s = CSYMBOL; args = LIST0 argument; SYMBOL "="; t = level3_term ->
486 IDENT "include" ; path = QSTRING ->
487 loc,path,G.WithPreferences
488 | IDENT "include" ; IDENT "alias"; path = QSTRING ->
489 loc,path,G.OnlyPreferences
490 | IDENT "include'" ; path = QSTRING ->
491 loc,path,G.WithoutPreferences
494 index: [[ b = OPT SYMBOL "-" -> match b with None -> true | _ -> false ]];
497 src = OPT IDENT "implied" ->
498 match src with None -> `Provided | _ -> `Implied
501 grafite_ncommand: [ [
502 IDENT "qed" ; i = index -> G.NQed (loc,i)
503 | IDENT "defined" ; i = index -> G.NQed (loc,i) (* FG: presentational qed for definitions *)
504 | src = source; nflavour = ntheorem_flavour; name = IDENT; SYMBOL ":"; typ = term;
505 body = OPT [ SYMBOL <:unicode<def>> (* ≝ *); body = term -> body ] ->
506 let attrs = src, nflavour, `Regular in
507 G.NObj (loc, N.Theorem (name, typ, body, attrs),true)
508 | src = source; nflavour = ntheorem_flavour; name = IDENT; SYMBOL <:unicode<def>> (* ≝ *);
510 let attrs = src, nflavour, `Regular in
512 N.Theorem(name, N.Implicit `JustOne, Some body, attrs),
514 | src = source; IDENT "axiom"; i = index; name = IDENT; SYMBOL ":"; typ = term ->
515 let attrs = src, `Axiom, `Regular in
516 G.NObj (loc, N.Theorem (name, typ, None, attrs),i)
517 | IDENT "discriminator" ; indty = tactic_term -> G.NDiscriminator (loc,indty)
518 | IDENT "inverter"; name = IDENT; IDENT "for" ; indty = tactic_term ;
519 paramspec = OPT inverter_param_list ;
520 outsort = OPT [ SYMBOL ":" ; outsort = term -> outsort ] ->
521 G.NInverter (loc,name,indty,paramspec,outsort)
522 | src = source; LETCOREC ; defs = let_codefs ->
523 nmk_rec_corec src `CoInductive defs loc true
524 | src = source; LETREC ; defs = let_defs ->
525 nmk_rec_corec src `Inductive defs loc true
526 (* FG: no source since no i_attr in N.Inductive *)
527 | IDENT "inductive"; spec = inductive_spec ->
528 let (params, ind_types) = spec in
529 G.NObj (loc, N.Inductive (params, ind_types),true)
530 (* FG: no source since no i_attr in N.Inductive *)
531 | IDENT "coinductive"; spec = inductive_spec ->
532 let (params, ind_types) = spec in
533 let ind_types = (* set inductive flags to false (coinductive) *)
534 List.map (fun (name, _, term, ctors) -> (name, false, term, ctors))
537 G.NObj (loc, N.Inductive (params, ind_types),true)
538 | IDENT "universe"; IDENT "constraint"; u1 = tactic_term;
539 SYMBOL <:unicode<lt>> ; u2 = tactic_term ->
541 | NotationPt.AttributedTerm (_, NotationPt.Sort (`NType i)) ->
542 NUri.uri_of_string ("cic:/matita/pts/Type"^i^".univ")
543 | _ -> raise (Failure "only a Type[…] sort can be constrained")
547 G.NUnivConstraint (loc,u1,u2)
548 | IDENT "unification"; IDENT "hint"; n = int; t = tactic_term ->
549 G.UnificationHint (loc, t, n)
550 | IDENT "coercion"; name = IDENT;
551 compose = OPT [ IDENT "nocomposites" -> () ];
552 spec = OPT [ SYMBOL ":"; ty = term;
553 SYMBOL <:unicode<def>>; t = term; "on";
554 id = [ IDENT | PIDENT ]; SYMBOL ":"; source = term;
555 "to"; target = term -> t,ty,(id,source),target ] ->
556 let compose = compose = None in
557 G.NCoercion(loc,name,compose,spec)
558 (* FG: no source since no i_attr in N.Record *)
559 | IDENT "record" ; (params,name,ty,fields) = record_spec ->
560 G.NObj (loc, N.Record (params,name,ty,fields),true)
561 | IDENT "copy" ; s = IDENT; IDENT "from"; u = URI; "with";
562 m = LIST0 [ u1 = URI; SYMBOL <:unicode<mapsto>>; u2 = URI -> u1,u2 ] ->
563 G.NCopy (loc,s,NUri.uri_of_string u,
564 List.map (fun a,b -> NUri.uri_of_string a, NUri.uri_of_string b) m)
565 | lc = lexicon_command -> lc
569 IDENT "alias" ; spec = alias_spec ->
571 | IDENT "notation"; (dir, l1, assoc, prec, l2) = notation ->
572 G.Notation (loc, dir, l1, assoc, prec, l2)
573 | IDENT "interpretation"; id = QSTRING;
574 (symbol, args, l3) = interpretation ->
575 G.Interpretation (loc, id, (symbol, args), l3)
578 [ ncmd = grafite_ncommand; SYMBOL "." -> G.NCommand (loc, ncmd)
579 | punct = npunctuation_tactical -> G.NTactic (loc, [punct])
580 | tac = nnon_punctuation_tactical(*; punct = npunctuation_tactical*) ->
581 G.NTactic (loc, [tac])
582 | tac = ntactic (*; punct = npunctuation_tactical*) ->
585 | tac = nnon_punctuation_tactical;
586 punct = npunctuation_tactical ->
587 G.NTactic (loc, [tac; punct])
592 [ BEGINCOMMENT ; ex = executable ; ENDCOMMENT ->
599 [ ex = executable -> G.Executable (loc, ex)
600 | com = comment -> G.Comment (loc, com)
601 | (iloc,fname,mode) = include_command ; SYMBOL "." ->
602 G.Executable (loc,G.NCommand (loc,G.Include (iloc,mode,fname)))
603 | EOI -> raise End_of_file
611 type db = GrafiteAst.statement Grammar.Entry.e ;;
613 class type g_status =
615 inherit CicNotationParser.g_status
619 class virtual status =
621 inherit CicNotationParser.status ~keywords:[]
622 val mutable db = None (* mutable only to initialize it :-( *)
623 method parser_db = match db with None -> assert false | Some x -> x
624 method set_parser_db v = {< db = Some v >}
625 method set_parser_status
626 : 'status. #g_status as 'status -> 'self
627 = fun o -> {< db = Some o#parser_db >}#set_notation_parser_status o
629 let grammar = CicNotationParser.level2_ast_grammar self in
630 db <- Some (mk_parser (Grammar.Entry.create grammar "statement") self)
633 let extend status l1 action =
634 let status = CicNotationParser.extend status l1 action in
635 let grammar = CicNotationParser.level2_ast_grammar status in
637 (mk_parser (Grammar.Entry.create grammar "statement") status)
641 let parse_statement status =
642 parse_statement status#parser_db
644 (* vim:set foldmethod=marker: *)