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 | Stdpp.Exc_located (_, End_of_file) -> raise End_of_file
36 | Stdpp.Exc_located (floc, Stream.Error msg) ->
37 raise (HExtlib.Localized (floc,CicNotationParser.Parse_error msg))
38 | Stdpp.Exc_located (floc, HExtlib.Localized(_,exn)) ->
39 raise (HExtlib.Localized
40 (floc,CicNotationParser.Parse_error (Printexc.to_string exn)))
41 | Stdpp.Exc_located (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 (Obj.magic 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 ind_kind defs loc =
64 | (params,(N.Ident (name, None), ty),_,_) :: _ ->
65 let ty = match ty with Some ty -> ty | None -> N.Implicit `JustOne in
68 (fun var ty -> N.Binder (`Pi,var,ty)
74 let body = N.Ident (name,None) in
75 (loc, N.Theorem(`Definition, name, ty, Some (N.LetRec (ind_kind, defs, body)), `Regular))
77 let nmk_rec_corec ind_kind defs loc index =
78 let loc,t = mk_rec_corec ind_kind defs loc in
82 let nnon_punct_of_punct = function
83 | G.Skip loc -> G.NSkip loc
84 | G.Unfocus loc -> G.NUnfocus loc
85 | G.Focus (loc,l) -> G.NFocus (loc,l)
88 type by_continuation =
90 | BYC_weproved of N.term * string option * N.term option
91 | BYC_letsuchthat of string * N.term * string * N.term
92 | BYC_wehaveand of string * N.term * string * N.term
94 let mk_parser statement lstatus =
95 (* let grammar = CicNotationParser.level2_ast_grammar lstatus in *)
96 let term = CicNotationParser.term lstatus in
97 let let_defs = CicNotationParser.let_defs lstatus in
98 let let_codefs = CicNotationParser.let_codefs lstatus in
99 let protected_binder_vars = CicNotationParser.protected_binder_vars lstatus in
100 (* {{{ parser initialization *)
102 GLOBAL: term statement;
103 constructor: [ [ name = IDENT; SYMBOL ":"; typ = term -> (name, typ) ] ];
104 tactic_term: [ [ t = term LEVEL "90" -> t ] ];
105 ident_list1: [ [ LPAREN; idents = LIST1 IDENT; RPAREN -> idents ] ];
107 [ IDENT "normalize" ; delta = OPT [ IDENT "nodelta" -> () ] ->
108 let delta = match delta with None -> true | _ -> false in
110 | IDENT "whd" ; delta = OPT [ IDENT "nodelta" -> () ] ->
111 let delta = match delta with None -> true | _ -> false in
114 sequent_pattern_spec: [
118 path = OPT [SYMBOL ":" ; path = tactic_term -> path ] ->
119 (id,match path with Some p -> p | None -> N.UserInput) ];
120 goal_path = OPT [ SYMBOL <:unicode<vdash>>; term = tactic_term -> term ] ->
122 match goal_path, hyp_paths with
123 None, [] -> Some N.UserInput
125 | Some goal_path, _ -> Some goal_path
134 [ "match" ; wanted = tactic_term ;
135 sps = OPT [ "in"; sps = sequent_pattern_spec -> sps ] ->
137 | sps = sequent_pattern_spec ->
141 let wanted,hyp_paths,goal_path =
142 match wanted_and_sps with
143 wanted,None -> wanted, [], Some N.UserInput
144 | wanted,Some (hyp_paths,goal_path) -> wanted,hyp_paths,goal_path
146 wanted, hyp_paths, goal_path ] ->
148 None -> None,[],Some N.UserInput
151 inverter_param_list: [
152 [ params = tactic_term ->
153 let deannotate = function
154 | N.AttributedTerm (_,t) | t -> t
155 in match deannotate params with
156 | N.Implicit _ -> [false]
157 | N.UserInput -> [true]
159 List.map (fun x -> match deannotate x with
160 | N.Implicit _ -> false
161 | N.UserInput -> true
162 | _ -> raise (Invalid_argument "malformed target parameter list 1")) l
164 (*CSC: new NCicPp.status is the best I can do here without changing the
166 raise (Invalid_argument ("malformed target parameter list 2\n" ^ NotationPp.pp_term (new NCicPp.status) params)) ]
169 [ SYMBOL ">" -> `LeftToRight
170 | SYMBOL "<" -> `RightToLeft ]
172 int: [ [ num = NUMBER -> int_of_string num ] ];
174 [ SYMBOL "@"; t = tactic_term -> G.NTactic(loc,[G.NApply (loc, t)])
175 | IDENT "applyS"; t = tactic_term -> G.NTactic(loc,[G.NSmartApply(loc, t)])
179 [ id = IDENT ; SYMBOL ":" ; ty = tactic_term -> id,`Decl ty
180 | id = IDENT ; SYMBOL ":" ; ty = tactic_term ;
181 SYMBOL <:unicode<def>> ; bo = tactic_term ->
183 SYMBOL <:unicode<vdash>>;
184 concl = tactic_term -> (List.rev hyps,concl) ] ->
185 G.NTactic(loc,[G.NAssert (loc, seqs)])
186 | SYMBOL "/"; num = OPT NUMBER ;
187 just_and_params = auto_params; SYMBOL "/" ->
188 let just,params = just_and_params in
189 let depth = match num with Some n -> n | None -> "1" in
193 [G.NAuto(loc,(None,["depth",depth]@params))])
194 | Some (`Univ univ) ->
196 [G.NAuto(loc,(Some univ,["depth",depth]@params))])
199 G.NAutoInteractive (loc, (None,["depth",depth]@params))))
200 | SYMBOL "#"; SYMBOL "#" -> G.NMacro (loc, G.NIntroGuess loc)
201 | IDENT "check"; t = tactic_term -> G.NMacro(loc,G.NCheck (loc,t))
202 | IDENT "screenshot"; fname = QSTRING ->
203 G.NMacro(loc,G.Screenshot (loc, fname))
204 | IDENT "cases"; what = tactic_term ; where = pattern_spec ->
205 G.NTactic(loc,[G.NCases (loc, what, where)])
206 | IDENT "change"; "with"; with_what = tactic_term; what = pattern_spec ->
207 G.NTactic(loc,[G.NChange (loc, what, with_what)])
208 | SYMBOL "-"; id = IDENT ->
209 G.NTactic(loc,[G.NClear (loc, [id])])
210 | PLACEHOLDER; num = OPT NUMBER;
211 l = OPT [ SYMBOL "{"; l = LIST1 tactic_term; SYMBOL "}" -> l ] ->
212 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)])
213 | IDENT "cut"; t = tactic_term -> G.NTactic(loc,[G.NCut (loc, t)])
214 | IDENT "destruct"; just = OPT [ dom = ident_list1 -> dom ];
215 exclude = OPT [ IDENT "skip"; skip = ident_list1 -> skip ]
216 -> let exclude' = match exclude with None -> [] | Some l -> l in
217 G.NTactic(loc,[G.NDestruct (loc,just,exclude')])
218 | IDENT "elim"; what = tactic_term ; where = pattern_spec ->
219 G.NTactic(loc,[G.NElim (loc, what, where)])
220 | IDENT "generalize"; p=pattern_spec ->
221 G.NTactic(loc,[G.NGeneralize (loc, p)])
222 | IDENT "inversion"; what = tactic_term ; where = pattern_spec ->
223 G.NTactic(loc,[G.NInversion (loc, what, where)])
224 | IDENT "lapply"; t = tactic_term -> G.NTactic(loc,[G.NLApply (loc, t)])
225 | IDENT "letin"; name = IDENT ; SYMBOL <:unicode<def>> ; t = tactic_term;
226 where = pattern_spec ->
227 G.NTactic(loc,[G.NLetIn (loc,where,t,name)])
228 | kind = nreduction_kind; p = pattern_spec ->
229 G.NTactic(loc,[G.NReduce (loc, kind, p)])
230 | dir = direction; what = tactic_term ; where = pattern_spec ->
231 G.NTactic(loc,[G.NRewrite (loc, dir, what, where)])
232 | IDENT "try"; tac = SELF ->
233 let tac = match tac with G.NTactic(_,[t]) -> t | _ -> assert false in
234 G.NTactic(loc,[ G.NTry (loc,tac)])
235 | IDENT "repeat"; tac = SELF ->
236 let tac = match tac with G.NTactic(_,[t]) -> t | _ -> assert false in
237 G.NTactic(loc,[ G.NRepeat (loc,tac)])
238 | LPAREN; l = LIST1 SELF; RPAREN ->
241 (List.map (function G.NTactic(_,t) -> t | _ -> assert false) l) in
242 G.NTactic(loc,[G.NBlock (loc,l)])
243 | IDENT "assumption" -> G.NTactic(loc,[ G.NAssumption loc])
244 | SYMBOL "#"; ns=IDENT -> G.NTactic(loc,[ G.NIntros (loc,[ns])])
245 | SYMBOL "#"; SYMBOL "_" -> G.NTactic(loc,[ G.NIntro (loc,"_")])
246 | SYMBOL "*" -> G.NTactic(loc,[ G.NCase1 (loc,"_")])
247 | SYMBOL "*"; "as"; n=IDENT -> G.NTactic(loc,[ G.NCase1 (loc,n)])
252 | IDENT "fast_paramod"
261 i = auto_fixed_param -> i,""
262 | i = auto_fixed_param ; SYMBOL "="; v = [ v = int ->
263 string_of_int v | v = IDENT -> v ] -> i,v ];
264 just = OPT [ IDENT "by"; by =
265 [ univ = LIST0 tactic_term SEP SYMBOL "," -> `Univ univ
266 | SYMBOL "_" -> `Trace ] -> by ] -> just,params
272 [ 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)
273 | WEPROVED; ty = tactic_term ; t1 = OPT [IDENT "that" ; IDENT "is" ; IDENT "equivalent" ; "to" ; t2 = tactic_term -> t2] ;
274 "done" -> BYC_weproved (ty,None,t1)
276 | "let" ; id1 = IDENT ; SYMBOL ":" ; t1 = tactic_term ;
277 IDENT "such" ; IDENT "that" ; t2=tactic_term ; LPAREN ;
278 id2 = IDENT ; RPAREN -> BYC_letsuchthat (id1,t1,id2,t2)
279 | WEHAVE; t1=tactic_term ; LPAREN ; id1=IDENT ; RPAREN ;"and" ; t2=tactic_term ; LPAREN ; id2=IDENT ; RPAREN ->
280 BYC_wehaveand (id1,t1,id2,t2)
285 rewriting_step_continuation : [
294 [ t1 = SELF; SYMBOL ";"; t2 = SELF ->
297 | G.Seq (_, l) -> l @ [ t2 ]
303 [ tac = SELF; SYMBOL ";";
304 SYMBOL "["; tacs = LIST0 SELF SEP SYMBOL "|"; SYMBOL "]"->
305 (G.Then (loc, tac, tacs))
308 [ IDENT "do"; count = int; tac = SELF ->
309 G.Do (loc, count, tac)
310 | IDENT "repeat"; tac = SELF -> G.Repeat (loc, tac)
314 SYMBOL "["; tacs = LIST0 SELF SEP SYMBOL "|"; SYMBOL "]"->
316 | IDENT "try"; tac = SELF -> G.Try (loc, tac)
318 SYMBOL "["; tacs = LIST0 SELF SEP SYMBOL "|"; SYMBOL "]"->
320 | IDENT "progress"; tac = SELF -> G.Progress (loc, tac)
321 | LPAREN; tac = SELF; RPAREN -> tac
322 | tac = tactic -> tac
326 npunctuation_tactical:
328 [ SYMBOL "[" -> G.NBranch loc
329 | SYMBOL "|" -> G.NShift loc
330 | i = LIST1 int SEP SYMBOL ","; SYMBOL ":" -> G.NPos (loc, i)
331 | SYMBOL "*"; SYMBOL ":" -> G.NWildcard loc
332 | name = IDENT; SYMBOL ":" -> G.NPosbyname (loc, name)
333 | SYMBOL "]" -> G.NMerge loc
334 | SYMBOL ";" -> G.NSemicolon loc
335 | SYMBOL "." -> G.NDot loc
338 nnon_punctuation_tactical:
340 [ IDENT "focus"; goals = LIST1 int -> G.NFocus (loc, goals)
341 | IDENT "unfocus" -> G.NUnfocus loc
342 | IDENT "skip" -> G.NSkip loc
346 [ [ IDENT "definition" ] -> `Definition
347 | [ IDENT "fact" ] -> `Fact
348 | [ IDENT "lemma" ] -> `Lemma
349 | [ IDENT "example" ] -> `Example
350 | [ IDENT "theorem" ] -> `Theorem
351 | [ IDENT "corollary" ] -> `Corollary
356 params = LIST0 protected_binder_vars;
357 SYMBOL ":"; fst_typ = term; SYMBOL <:unicode<def>>; OPT SYMBOL "|";
358 fst_constructors = LIST0 constructor SEP SYMBOL "|";
361 name = IDENT; SYMBOL ":"; typ = term; SYMBOL <:unicode<def>>;
362 OPT SYMBOL "|"; constructors = LIST0 constructor SEP SYMBOL "|" ->
363 (name, true, typ, constructors) ] SEP "with" -> types
367 (fun (names, typ) acc ->
368 (List.map (fun name -> (name, typ)) names) @ acc)
371 let fst_ind_type = (fst_name, true, fst_typ, fst_constructors) in
372 let tl_ind_types = match tl with None -> [] | Some types -> types in
373 let ind_types = fst_ind_type :: tl_ind_types in
379 params = LIST0 protected_binder_vars;
380 SYMBOL ":"; typ = term; SYMBOL <:unicode<def>>; SYMBOL "{" ;
384 SYMBOL ":" -> false,0
385 | SYMBOL ":"; SYMBOL ">" -> true,0
386 | SYMBOL ":"; arity = int ; SYMBOL ">" -> true,arity
389 let b,n = coercion in
391 ] SEP SYMBOL ";"; SYMBOL "}" ->
394 (fun (names, typ) acc ->
395 (List.map (fun name -> (name, typ)) names) @ acc)
398 (params,name,typ,fields)
402 [ IDENT "id"; id = QSTRING; SYMBOL "="; uri = QSTRING ->
403 let alpha = "[a-zA-Z]" in
404 let num = "[0-9]+" in
405 let ident_cont = "\\("^alpha^"\\|"^num^"\\|_\\|\\\\\\)" in
406 let decoration = "\\'" in
407 let ident = "\\("^alpha^ident_cont^"*"^decoration^"*\\|_"^ident_cont^"+"^decoration^"*\\)" in
408 let rex = Str.regexp ("^"^ident^"$") in
409 if Str.string_match rex id 0 then
410 if (try ignore (NReference.reference_of_string uri); true
411 with NReference.IllFormedReference _ -> false)
413 G.Ident_alias (id, uri)
416 (HExtlib.Localized (loc, CicNotationParser.Parse_error (Printf.sprintf "Not a valid uri: %s" uri)))
418 raise (HExtlib.Localized (loc, CicNotationParser.Parse_error (
419 Printf.sprintf "Not a valid identifier: %s" id)))
420 | IDENT "symbol"; symbol = QSTRING;
421 instance = OPT [ LPAREN; IDENT "instance"; n = int; RPAREN -> n ];
422 SYMBOL "="; dsc = QSTRING ->
424 match instance with Some i -> i | None -> 0
426 G.Symbol_alias (symbol, instance, dsc)
428 instance = OPT [ LPAREN; IDENT "instance"; n = int; RPAREN -> n ];
429 SYMBOL "="; dsc = QSTRING ->
431 match instance with Some i -> i | None -> 0
433 G.Number_alias (instance, dsc)
437 [ l = LIST0 [ SYMBOL <:unicode<eta>> (* η *); SYMBOL "." -> () ];
439 N.IdentArg (List.length l, id)
443 [ IDENT "left"; IDENT "associative" -> Gramext.LeftA
444 | IDENT "right"; IDENT "associative" -> Gramext.RightA
445 | IDENT "non"; IDENT "associative" -> Gramext.NonA
449 [ "with"; IDENT "precedence"; n = NUMBER -> int_of_string n ]
452 [ dir = OPT direction; s = QSTRING;
453 assoc = OPT associativity; prec = precedence;
456 [ blob = UNPARSED_AST ->
457 add_raw_attribute ~text:(Printf.sprintf "@{%s}" blob)
458 (CicNotationParser.parse_level2_ast lstatus
459 (Ulexing.from_utf8_string blob))
460 | blob = UNPARSED_META ->
461 add_raw_attribute ~text:(Printf.sprintf "${%s}" blob)
462 (CicNotationParser.parse_level2_meta lstatus
463 (Ulexing.from_utf8_string blob))
467 | None -> default_associativity
468 | Some assoc -> assoc
471 add_raw_attribute ~text:s
472 (CicNotationParser.parse_level1_pattern lstatus prec
473 (Ulexing.from_utf8_string s))
475 (dir, p1, assoc, prec, p2)
479 [ r = NREF -> N.NRefPattern (NReference.reference_of_string r)
480 | IMPLICIT -> N.ImplicitPattern
481 | id = IDENT -> N.VarPattern id
482 | LPAREN; terms = LIST1 SELF; RPAREN ->
486 | terms -> N.ApplPattern terms)
490 [ s = CSYMBOL; args = LIST0 argument; SYMBOL "="; t = level3_term ->
496 IDENT "include" ; path = QSTRING ->
497 loc,path,G.WithPreferences
498 | IDENT "include" ; IDENT "alias"; path = QSTRING ->
499 loc,path,G.OnlyPreferences
500 | IDENT "include'" ; path = QSTRING ->
501 loc,path,G.WithoutPreferences
504 index: [[ b = OPT SYMBOL "-" -> match b with None -> true | _ -> false ]];
506 grafite_ncommand: [ [
507 IDENT "qed" ; i = index -> G.NQed (loc,i)
508 | nflavour = ntheorem_flavour; name = IDENT; SYMBOL ":"; typ = term;
509 body = OPT [ SYMBOL <:unicode<def>> (* ≝ *); body = term -> body ] ->
510 G.NObj (loc, N.Theorem (nflavour, name, typ, body,`Regular),true)
511 | nflavour = ntheorem_flavour; name = IDENT; SYMBOL <:unicode<def>> (* ≝ *);
514 N.Theorem(nflavour, name, N.Implicit `JustOne, Some body,`Regular),
516 | IDENT "axiom"; i = index; name = IDENT; SYMBOL ":"; typ = term ->
517 G.NObj (loc, N.Theorem (`Axiom, name, typ, None, `Regular),i)
518 | IDENT "discriminator" ; indty = tactic_term -> G.NDiscriminator (loc,indty)
519 | IDENT "inverter"; name = IDENT; IDENT "for" ; indty = tactic_term ;
520 paramspec = OPT inverter_param_list ;
521 outsort = OPT [ SYMBOL ":" ; outsort = term -> outsort ] ->
522 G.NInverter (loc,name,indty,paramspec,outsort)
523 | LETCOREC ; defs = let_codefs ->
524 nmk_rec_corec `CoInductive defs loc true
525 | LETREC ; defs = let_defs ->
526 nmk_rec_corec `Inductive defs loc true
527 | IDENT "inductive"; spec = inductive_spec ->
528 let (params, ind_types) = spec in
529 G.NObj (loc, N.Inductive (params, ind_types),true)
530 | IDENT "coinductive"; spec = inductive_spec ->
531 let (params, ind_types) = spec in
532 let ind_types = (* set inductive flags to false (coinductive) *)
533 List.map (fun (name, _, term, ctors) -> (name, false, term, ctors))
536 G.NObj (loc, N.Inductive (params, ind_types),true)
537 | IDENT "universe"; IDENT "constraint"; u1 = tactic_term;
538 SYMBOL <:unicode<lt>> ; u2 = tactic_term ->
540 | NotationPt.AttributedTerm (_, NotationPt.Sort (`NType i)) ->
541 NUri.uri_of_string ("cic:/matita/pts/Type"^i^".univ")
542 | _ -> raise (Failure "only a Type[…] sort can be constrained")
546 G.NUnivConstraint (loc,u1,u2)
547 | IDENT "unification"; IDENT "hint"; n = int; t = tactic_term ->
548 G.UnificationHint (loc, t, n)
549 | IDENT "coercion"; name = IDENT;
550 compose = OPT [ IDENT "nocomposites" -> () ];
551 spec = OPT [ SYMBOL ":"; ty = term;
552 SYMBOL <:unicode<def>>; t = term; "on";
553 id = [ IDENT | PIDENT ]; SYMBOL ":"; source = term;
554 "to"; target = term -> t,ty,(id,source),target ] ->
555 let compose = compose = None in
556 G.NCoercion(loc,name,compose,spec)
557 | IDENT "record" ; (params,name,ty,fields) = record_spec ->
558 G.NObj (loc, N.Record (params,name,ty,fields),true)
559 | IDENT "copy" ; s = IDENT; IDENT "from"; u = URI; "with";
560 m = LIST0 [ u1 = URI; SYMBOL <:unicode<mapsto>>; u2 = URI -> u1,u2 ] ->
561 G.NCopy (loc,s,NUri.uri_of_string u,
562 List.map (fun a,b -> NUri.uri_of_string a, NUri.uri_of_string b) m)
563 | lc = lexicon_command -> lc
567 IDENT "alias" ; spec = alias_spec ->
569 | IDENT "notation"; (dir, l1, assoc, prec, l2) = notation ->
570 G.Notation (loc, dir, l1, assoc, prec, l2)
571 | IDENT "interpretation"; id = QSTRING;
572 (symbol, args, l3) = interpretation ->
573 G.Interpretation (loc, id, (symbol, args), l3)
576 [ ncmd = grafite_ncommand; SYMBOL "." -> G.NCommand (loc, ncmd)
577 | punct = npunctuation_tactical -> G.NTactic (loc, [punct])
578 | tac = nnon_punctuation_tactical(*; punct = npunctuation_tactical*) ->
579 G.NTactic (loc, [tac])
580 | tac = ntactic (*; punct = npunctuation_tactical*) ->
583 | tac = nnon_punctuation_tactical;
584 punct = npunctuation_tactical ->
585 G.NTactic (loc, [tac; punct])
590 [ BEGINCOMMENT ; ex = executable ; ENDCOMMENT ->
597 [ ex = executable -> G.Executable (loc, ex)
598 | com = comment -> G.Comment (loc, com)
599 | (iloc,fname,mode) = include_command ; SYMBOL "." ->
600 G.Executable (loc,G.NCommand (loc,G.Include (iloc,mode,fname)))
601 | EOI -> raise End_of_file
609 type db = GrafiteAst.statement Grammar.Entry.e ;;
611 class type g_status =
613 inherit CicNotationParser.g_status
617 class virtual status =
619 inherit CicNotationParser.status ~keywords:[]
620 val mutable db = None (* mutable only to initialize it :-( *)
621 method parser_db = match db with None -> assert false | Some x -> x
622 method set_parser_db v = {< db = Some v >}
623 method set_parser_status
624 : 'status. #g_status as 'status -> 'self
625 = fun o -> {< db = Some o#parser_db >}#set_notation_parser_status o
627 let grammar = CicNotationParser.level2_ast_grammar self in
628 db <- Some (mk_parser (Grammar.Entry.create grammar "statement") self)
631 let extend status l1 action =
632 let status = CicNotationParser.extend status l1 action in
633 let grammar = CicNotationParser.level2_ast_grammar status in
635 (mk_parser (Grammar.Entry.create grammar "statement") status)
639 let parse_statement status =
640 parse_statement status#parser_db
642 (* vim:set foldmethod=marker: *)