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 =
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 protected_binder_vars = CicNotationParser.protected_binder_vars lstatus in
99 (* {{{ parser initialization *)
101 GLOBAL: term statement;
102 constructor: [ [ name = IDENT; SYMBOL ":"; typ = term -> (name, typ) ] ];
103 tactic_term: [ [ t = term LEVEL "90" -> t ] ];
107 | id = IDENT -> Some id ]
110 ident_list1: [ [ LPAREN; idents = LIST1 IDENT; RPAREN -> idents ] ];
112 [ tactic_terms = LIST1 tactic_term SEP SYMBOL "," -> tactic_terms ]
115 [ IDENT "normalize" ; delta = OPT [ IDENT "nodelta" -> () ] ->
116 let delta = match delta with None -> true | _ -> false in
118 (*| IDENT "unfold"; t = OPT tactic_term -> `Unfold t*)
119 | IDENT "whd" ; delta = OPT [ IDENT "nodelta" -> () ] ->
120 let delta = match delta with None -> true | _ -> false in
123 sequent_pattern_spec: [
127 path = OPT [SYMBOL ":" ; path = tactic_term -> path ] ->
128 (id,match path with Some p -> p | None -> N.UserInput) ];
129 goal_path = OPT [ SYMBOL <:unicode<vdash>>; term = tactic_term -> term ] ->
131 match goal_path, hyp_paths with
132 None, [] -> Some N.UserInput
134 | Some goal_path, _ -> Some goal_path
143 [ "match" ; wanted = tactic_term ;
144 sps = OPT [ "in"; sps = sequent_pattern_spec -> sps ] ->
146 | sps = sequent_pattern_spec ->
149 let wanted,hyp_paths,goal_path =
150 match wanted_and_sps with
151 wanted,None -> wanted, [], Some N.UserInput
152 | wanted,Some (hyp_paths,goal_path) -> wanted,hyp_paths,goal_path
154 wanted, hyp_paths, goal_path ] ->
156 None -> None,[],Some N.UserInput
159 inverter_param_list: [
160 [ params = tactic_term ->
161 let deannotate = function
162 | N.AttributedTerm (_,t) | t -> t
163 in match deannotate params with
164 | N.Implicit _ -> [false]
165 | N.UserInput -> [true]
167 List.map (fun x -> match deannotate x with
168 | N.Implicit _ -> false
169 | N.UserInput -> true
170 | _ -> raise (Invalid_argument "malformed target parameter list 1")) l
172 (*CSC: new NCicPp.status is the best I can do here without changing the
174 raise (Invalid_argument ("malformed target parameter list 2\n" ^ NotationPp.pp_term (new NCicPp.status) params)) ]
177 [ SYMBOL ">" -> `LeftToRight
178 | SYMBOL "<" -> `RightToLeft ]
180 int: [ [ num = NUMBER -> int_of_string num ] ];
183 [ OPT [ IDENT "names" ];
184 num = OPT [ num = int -> num ];
185 idents = intros_names ->
190 (* MATITA 1.0 using: [ [ using = OPT [ IDENT "using"; t = tactic_term -> t ] -> using ] ]; *)
192 [ SYMBOL "@"; t = tactic_term -> G.NTactic(loc,[G.NApply (loc, t)])
193 | IDENT "apply"; t = tactic_term -> G.NTactic(loc,[G.NApply (loc, t)])
194 | IDENT "applyS"; t = tactic_term -> G.NTactic(loc,[G.NSmartApply(loc, t)])
198 [ id = IDENT ; SYMBOL ":" ; ty = tactic_term -> id,`Decl ty
199 | id = IDENT ; SYMBOL ":" ; ty = tactic_term ;
200 SYMBOL <:unicode<def>> ; bo = tactic_term ->
202 SYMBOL <:unicode<vdash>>;
203 concl = tactic_term -> (List.rev hyps,concl) ] ->
204 G.NTactic(loc,[G.NAssert (loc, seqs)])
205 (*| IDENT "auto"; params = auto_params ->
206 G.NTactic(loc,[G.NAuto (loc, params)])*)
207 | SYMBOL "/"; num = OPT NUMBER ;
208 just_and_params = auto_params; SYMBOL "/" ->
209 let just,params = just_and_params in
210 let depth = match num with Some n -> n | None -> "1" in
214 [G.NAuto(loc,(None,["depth",depth]@params))])
215 | Some (`Univ univ) ->
217 [G.NAuto(loc,(Some univ,["depth",depth]@params))])
220 [G.NAuto(loc,(Some [],["depth",depth]@params))])
223 G.NAutoInteractive (loc, (None,["depth",depth]@params))))
224 | IDENT "intros" -> G.NMacro (loc, G.NIntroGuess loc)
225 | IDENT "check"; t = term -> G.NMacro(loc,G.NCheck (loc,t))
226 | IDENT "screenshot"; fname = QSTRING ->
227 G.NMacro(loc,G.Screenshot (loc, fname))
228 | IDENT "cases"; what = tactic_term ; where = pattern_spec ->
229 G.NTactic(loc,[G.NCases (loc, what, where)])
230 | IDENT "change"; what = pattern_spec; "with"; with_what = tactic_term ->
231 G.NTactic(loc,[G.NChange (loc, what, with_what)])
232 | SYMBOL "-"; ids = LIST1 IDENT ->
233 G.NTactic(loc,[G.NClear (loc, ids)])
234 | (*SYMBOL "^"*)PLACEHOLDER; num = OPT NUMBER;
235 l = OPT [ SYMBOL "{"; l = LIST1 tactic_term; SYMBOL "}" -> l ] ->
236 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)])
237 | IDENT "cut"; t = tactic_term -> G.NTactic(loc,[G.NCut (loc, t)])
238 (* | IDENT "discriminate"; t = tactic_term -> G.NDiscriminate (loc, t)
239 | IDENT "subst"; t = tactic_term -> G.NSubst (loc, t) *)
240 | IDENT "destruct"; just = OPT [ dom = ident_list1 -> dom ];
241 exclude = OPT [ IDENT "skip"; skip = ident_list1 -> skip ]
242 -> let exclude' = match exclude with None -> [] | Some l -> l in
243 G.NTactic(loc,[G.NDestruct (loc,just,exclude')])
244 | IDENT "elim"; what = tactic_term ; where = pattern_spec ->
245 G.NTactic(loc,[G.NElim (loc, what, where)])
246 | IDENT "generalize"; p=pattern_spec ->
247 G.NTactic(loc,[G.NGeneralize (loc, p)])
248 | IDENT "inversion"; what = tactic_term ; where = pattern_spec ->
249 G.NTactic(loc,[G.NInversion (loc, what, where)])
250 | IDENT "lapply"; t = tactic_term -> G.NTactic(loc,[G.NLApply (loc, t)])
251 | IDENT "letin"; name = IDENT ; SYMBOL <:unicode<def>> ; t = tactic_term;
252 where = pattern_spec ->
253 G.NTactic(loc,[G.NLetIn (loc,where,t,name)])
254 | kind = nreduction_kind; p = pattern_spec ->
255 G.NTactic(loc,[G.NReduce (loc, kind, p)])
256 | dir = direction; what = tactic_term ; where = pattern_spec ->
257 G.NTactic(loc,[G.NRewrite (loc, dir, what, where)])
258 | IDENT "rewrite"; dir = direction; what = tactic_term ; where = pattern_spec ->
259 G.NTactic(loc,[G.NRewrite (loc, dir, what, where)])
260 | IDENT "try"; tac = SELF ->
261 let tac = match tac with G.NTactic(_,[t]) -> t | _ -> assert false in
262 G.NTactic(loc,[ G.NTry (loc,tac)])
263 | IDENT "repeat"; tac = SELF ->
264 let tac = match tac with G.NTactic(_,[t]) -> t | _ -> assert false in
265 G.NTactic(loc,[ G.NRepeat (loc,tac)])
266 | LPAREN; l = LIST1 SELF; RPAREN ->
269 (List.map (function G.NTactic(_,t) -> t | _ -> assert false) l) in
270 G.NTactic(loc,[G.NBlock (loc,l)])
271 | IDENT "assumption" -> G.NTactic(loc,[ G.NAssumption loc])
272 | SYMBOL "#"; ns=IDENT -> G.NTactic(loc,[ G.NIntros (loc,[ns])])
273 | SYMBOL "#"; SYMBOL "_" -> G.NTactic(loc,[ G.NIntro (loc,"_")])
274 | SYMBOL "*" -> G.NTactic(loc,[ G.NCase1 (loc,"_")])
275 | SYMBOL "*"; n=IDENT -> G.NTactic(loc,[ G.NCase1 (loc,n)])
280 | IDENT "fast_paramod"
294 i = auto_fixed_param -> i,""
295 | i = auto_fixed_param ; SYMBOL "="; v = [ v = int ->
296 string_of_int v | v = IDENT -> v ] -> i,v ];
297 just = OPT [ IDENT "by"; by =
298 [ univ = tactic_term_list1 -> `Univ univ
299 | SYMBOL "{"; SYMBOL "}" -> `EmptyUniv
300 | SYMBOL "_" -> `Trace ] -> by ] -> just,params
306 [ 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)
307 | WEPROVED; ty = tactic_term ; t1 = OPT [IDENT "that" ; IDENT "is" ; IDENT "equivalent" ; "to" ; t2 = tactic_term -> t2] ;
308 "done" -> BYC_weproved (ty,None,t1)
310 | "let" ; id1 = IDENT ; SYMBOL ":" ; t1 = tactic_term ;
311 IDENT "such" ; IDENT "that" ; t2=tactic_term ; LPAREN ;
312 id2 = IDENT ; RPAREN -> BYC_letsuchthat (id1,t1,id2,t2)
313 | WEHAVE; t1=tactic_term ; LPAREN ; id1=IDENT ; RPAREN ;"and" ; t2=tactic_term ; LPAREN ; id2=IDENT ; RPAREN ->
314 BYC_wehaveand (id1,t1,id2,t2)
319 rewriting_step_continuation : [
328 [ t1 = SELF; SYMBOL ";"; t2 = SELF ->
331 | G.Seq (_, l) -> l @ [ t2 ]
337 [ tac = SELF; SYMBOL ";";
338 SYMBOL "["; tacs = LIST0 SELF SEP SYMBOL "|"; SYMBOL "]"->
339 (G.Then (loc, tac, tacs))
342 [ IDENT "do"; count = int; tac = SELF ->
343 G.Do (loc, count, tac)
344 | IDENT "repeat"; tac = SELF -> G.Repeat (loc, tac)
348 SYMBOL "["; tacs = LIST0 SELF SEP SYMBOL "|"; SYMBOL "]"->
350 | IDENT "try"; tac = SELF -> G.Try (loc, tac)
352 SYMBOL "["; tacs = LIST0 SELF SEP SYMBOL "|"; SYMBOL "]"->
354 | IDENT "progress"; tac = SELF -> G.Progress (loc, tac)
355 | LPAREN; tac = SELF; RPAREN -> tac
356 | tac = tactic -> tac
360 npunctuation_tactical:
362 [ SYMBOL "[" -> G.NBranch loc
363 | SYMBOL "|" -> G.NShift loc
364 | i = LIST1 int SEP SYMBOL ","; SYMBOL ":" -> G.NPos (loc, i)
365 | SYMBOL "*"; SYMBOL ":" -> G.NWildcard loc
366 | name = IDENT; SYMBOL ":" -> G.NPosbyname (loc, name)
367 | SYMBOL "]" -> G.NMerge loc
368 | SYMBOL ";" -> G.NSemicolon loc
369 | SYMBOL "." -> G.NDot loc
372 nnon_punctuation_tactical:
374 [ IDENT "focus"; goals = LIST1 int -> G.NFocus (loc, goals)
375 | IDENT "unfocus" -> G.NUnfocus loc
376 | IDENT "skip" -> G.NSkip loc
380 [ [ IDENT "definition" ] -> `Definition
381 | [ IDENT "fact" ] -> `Fact
382 | [ IDENT "lemma" ] -> `Lemma
383 | [ IDENT "example" ] -> `Example
384 | [ IDENT "theorem" ] -> `Theorem
385 | [ IDENT "corollary" ] -> `Corollary
390 params = LIST0 protected_binder_vars;
391 SYMBOL ":"; fst_typ = term; SYMBOL <:unicode<def>>; OPT SYMBOL "|";
392 fst_constructors = LIST0 constructor SEP SYMBOL "|";
395 name = IDENT; SYMBOL ":"; typ = term; SYMBOL <:unicode<def>>;
396 OPT SYMBOL "|"; constructors = LIST0 constructor SEP SYMBOL "|" ->
397 (name, true, typ, constructors) ] SEP "with" -> types
401 (fun (names, typ) acc ->
402 (List.map (fun name -> (name, typ)) names) @ acc)
405 let fst_ind_type = (fst_name, true, fst_typ, fst_constructors) in
406 let tl_ind_types = match tl with None -> [] | Some types -> types in
407 let ind_types = fst_ind_type :: tl_ind_types in
413 params = LIST0 protected_binder_vars;
414 SYMBOL ":"; typ = term; SYMBOL <:unicode<def>>; SYMBOL "{" ;
418 SYMBOL ":" -> false,0
419 | SYMBOL ":"; SYMBOL ">" -> true,0
420 | SYMBOL ":"; arity = int ; SYMBOL ">" -> true,arity
423 let b,n = coercion in
425 ] SEP SYMBOL ";"; SYMBOL "}" ->
428 (fun (names, typ) acc ->
429 (List.map (fun name -> (name, typ)) names) @ acc)
432 (params,name,typ,fields)
436 [ IDENT "id"; id = QSTRING; SYMBOL "="; uri = QSTRING ->
437 let alpha = "[a-zA-Z]" in
438 let num = "[0-9]+" in
439 let ident_cont = "\\("^alpha^"\\|"^num^"\\|_\\|\\\\\\)" in
440 let decoration = "\\'" in
441 let ident = "\\("^alpha^ident_cont^"*"^decoration^"*\\|_"^ident_cont^"+"^decoration^"*\\)" in
442 let rex = Str.regexp ("^"^ident^"$") in
443 if Str.string_match rex id 0 then
444 if (try ignore (NReference.reference_of_string uri); true
445 with NReference.IllFormedReference _ -> false)
447 G.Ident_alias (id, uri)
450 (HExtlib.Localized (loc, CicNotationParser.Parse_error (Printf.sprintf "Not a valid uri: %s" uri)))
452 raise (HExtlib.Localized (loc, CicNotationParser.Parse_error (
453 Printf.sprintf "Not a valid identifier: %s" id)))
454 | IDENT "symbol"; symbol = QSTRING;
455 instance = OPT [ LPAREN; IDENT "instance"; n = int; RPAREN -> n ];
456 SYMBOL "="; dsc = QSTRING ->
458 match instance with Some i -> i | None -> 0
460 G.Symbol_alias (symbol, instance, dsc)
462 instance = OPT [ LPAREN; IDENT "instance"; n = int; RPAREN -> n ];
463 SYMBOL "="; dsc = QSTRING ->
465 match instance with Some i -> i | None -> 0
467 G.Number_alias (instance, dsc)
471 [ l = LIST0 [ SYMBOL <:unicode<eta>> (* η *); SYMBOL "." -> () ];
473 N.IdentArg (List.length l, id)
477 [ IDENT "left"; IDENT "associative" -> Gramext.LeftA
478 | IDENT "right"; IDENT "associative" -> Gramext.RightA
479 | IDENT "non"; IDENT "associative" -> Gramext.NonA
483 [ "with"; IDENT "precedence"; n = NUMBER -> int_of_string n ]
486 [ dir = OPT direction; s = QSTRING;
487 assoc = OPT associativity; prec = precedence;
490 [ blob = UNPARSED_AST ->
491 add_raw_attribute ~text:(Printf.sprintf "@{%s}" blob)
492 (CicNotationParser.parse_level2_ast lstatus
493 (Ulexing.from_utf8_string blob))
494 | blob = UNPARSED_META ->
495 add_raw_attribute ~text:(Printf.sprintf "${%s}" blob)
496 (CicNotationParser.parse_level2_meta lstatus
497 (Ulexing.from_utf8_string blob))
501 | None -> default_associativity
502 | Some assoc -> assoc
505 add_raw_attribute ~text:s
506 (CicNotationParser.parse_level1_pattern lstatus prec
507 (Ulexing.from_utf8_string s))
509 (dir, p1, assoc, prec, p2)
513 [ r = NREF -> N.NRefPattern (NReference.reference_of_string r)
514 | IMPLICIT -> N.ImplicitPattern
515 | id = IDENT -> N.VarPattern id
516 | LPAREN; terms = LIST1 SELF; RPAREN ->
520 | terms -> N.ApplPattern terms)
524 [ s = CSYMBOL; args = LIST0 argument; SYMBOL "="; t = level3_term ->
530 IDENT "include" ; path = QSTRING ->
531 loc,path,G.WithPreferences
532 | IDENT "include" ; IDENT "alias"; path = QSTRING ->
533 loc,path,G.OnlyPreferences
534 | IDENT "include'" ; path = QSTRING ->
535 loc,path,G.WithoutPreferences
538 grafite_ncommand: [ [
539 IDENT "qed" -> G.NQed loc
540 | nflavour = ntheorem_flavour; name = IDENT; SYMBOL ":"; typ = term;
541 body = OPT [ SYMBOL <:unicode<def>> (* ≝ *); body = term -> body ] ->
542 G.NObj (loc, N.Theorem (nflavour, name, typ, body,`Regular))
543 | nflavour = ntheorem_flavour; name = IDENT; SYMBOL <:unicode<def>> (* ≝ *);
545 G.NObj (loc, N.Theorem (nflavour, name, N.Implicit `JustOne, Some body,`Regular))
546 | IDENT "axiom"; name = IDENT; SYMBOL ":"; typ = term ->
547 G.NObj (loc, N.Theorem (`Axiom, name, typ, None, `Regular))
548 | IDENT "discriminator" ; indty = tactic_term -> G.NDiscriminator (loc,indty)
549 | IDENT "inverter"; name = IDENT; IDENT "for" ; indty = tactic_term ;
550 paramspec = OPT inverter_param_list ;
551 outsort = OPT [ SYMBOL ":" ; outsort = term -> outsort ] ->
552 G.NInverter (loc,name,indty,paramspec,outsort)
553 | LETCOREC ; defs = let_defs ->
554 nmk_rec_corec `CoInductive defs loc
555 | LETREC ; defs = let_defs ->
556 nmk_rec_corec `Inductive defs loc
557 | IDENT "inductive"; spec = inductive_spec ->
558 let (params, ind_types) = spec in
559 G.NObj (loc, N.Inductive (params, ind_types))
560 | IDENT "coinductive"; spec = inductive_spec ->
561 let (params, ind_types) = spec in
562 let ind_types = (* set inductive flags to false (coinductive) *)
563 List.map (fun (name, _, term, ctors) -> (name, false, term, ctors))
566 G.NObj (loc, N.Inductive (params, ind_types))
567 | IDENT "universe"; IDENT "constraint"; u1 = tactic_term;
568 SYMBOL <:unicode<lt>> ; u2 = tactic_term ->
570 | NotationPt.AttributedTerm (_, NotationPt.Sort (`NType i)) ->
571 NUri.uri_of_string ("cic:/matita/pts/Type"^i^".univ")
572 | _ -> raise (Failure "only a Type[…] sort can be constrained")
576 G.NUnivConstraint (loc,u1,u2)
577 | IDENT "unification"; IDENT "hint"; n = int; t = tactic_term ->
578 G.UnificationHint (loc, t, n)
579 | IDENT "coercion"; name = IDENT; SYMBOL ":"; ty = term;
580 SYMBOL <:unicode<def>>; t = term; "on";
581 id = [ IDENT | PIDENT ]; SYMBOL ":"; source = term;
582 "to"; target = term ->
583 G.NCoercion(loc,name,t,ty,(id,source),target)
584 | IDENT "record" ; (params,name,ty,fields) = record_spec ->
585 G.NObj (loc, N.Record (params,name,ty,fields))
586 | IDENT "copy" ; s = IDENT; IDENT "from"; u = URI; "with";
587 m = LIST0 [ u1 = URI; SYMBOL <:unicode<mapsto>>; u2 = URI -> u1,u2 ] ->
588 G.NCopy (loc,s,NUri.uri_of_string u,
589 List.map (fun a,b -> NUri.uri_of_string a, NUri.uri_of_string b) m)
590 | lc = lexicon_command -> lc
594 IDENT "alias" ; spec = alias_spec ->
596 | IDENT "notation"; (dir, l1, assoc, prec, l2) = notation ->
597 G.Notation (loc, dir, l1, assoc, prec, l2)
598 | IDENT "interpretation"; id = QSTRING;
599 (symbol, args, l3) = interpretation ->
600 G.Interpretation (loc, id, (symbol, args), l3)
603 [ ncmd = grafite_ncommand; SYMBOL "." -> G.NCommand (loc, ncmd)
604 | punct = npunctuation_tactical -> G.NTactic (loc, [punct])
605 | tac = nnon_punctuation_tactical(*; punct = npunctuation_tactical*) ->
606 G.NTactic (loc, [tac])
607 | tac = ntactic (*; punct = npunctuation_tactical*) ->
610 | tac = nnon_punctuation_tactical;
611 punct = npunctuation_tactical ->
612 G.NTactic (loc, [tac; punct])
617 [ BEGINCOMMENT ; ex = executable ; ENDCOMMENT ->
624 [ ex = executable -> G.Executable (loc, ex)
625 | com = comment -> G.Comment (loc, com)
626 | (iloc,fname,mode) = include_command ; SYMBOL "." ->
627 G.Executable (loc,G.NCommand (loc,G.Include (iloc,mode,fname)))
628 | EOI -> raise End_of_file
636 type db = GrafiteAst.statement Grammar.Entry.e ;;
638 class type g_status =
640 inherit CicNotationParser.g_status
644 class virtual status =
646 inherit CicNotationParser.status ~keywords:[]
647 val mutable db = None (* mutable only to initialize it :-( *)
648 method parser_db = match db with None -> assert false | Some x -> x
649 method set_parser_db v = {< db = Some v >}
650 method set_parser_status
651 : 'status. #g_status as 'status -> 'self
652 = fun o -> {< db = Some o#parser_db >}#set_notation_parser_status o
654 let grammar = CicNotationParser.level2_ast_grammar self in
655 db <- Some (mk_parser (Grammar.Entry.create grammar "statement") self)
658 let extend status l1 action =
659 let status = CicNotationParser.extend status l1 action in
660 let grammar = CicNotationParser.level2_ast_grammar status in
662 (mk_parser (Grammar.Entry.create grammar "statement") status)
666 let parse_statement status =
667 parse_statement status#parser_db
669 (* vim:set foldmethod=marker: *)