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
47 let parsable_statement status buf =
48 let grammar = CicNotationParser.level2_ast_grammar status in
49 Grammar.parsable grammar (Obj.magic buf)
51 let parse_statement grafite_parser parsable =
53 (fun () -> (Grammar.Entry.parse_parsable (Obj.magic grafite_parser) parsable))
55 let add_raw_attribute ~text t = N.AttributedTerm (`Raw text, t)
57 let default_associativity = Gramext.NonA
59 let mk_rec_corec ind_kind defs loc =
62 | (params,(N.Ident (name, `Ambiguous), ty),_,_) :: _ ->
63 let ty = match ty with Some ty -> ty | None -> N.Implicit `JustOne in
66 (fun var ty -> N.Binder (`Pi,var,ty)
72 let body = N.Ident (name,`Ambiguous) in
73 (loc, N.Theorem(`Definition, name, ty, Some (N.LetRec (ind_kind, defs, body)), `Regular))
75 let nmk_rec_corec ind_kind defs loc =
76 let loc,t = mk_rec_corec ind_kind defs loc in
80 let nnon_punct_of_punct = function
81 | G.Skip loc -> G.NSkip loc
82 | G.Unfocus loc -> G.NUnfocus loc
83 | G.Focus (loc,l) -> G.NFocus (loc,l)
86 type by_continuation =
88 | BYC_weproved of N.term * string option * N.term option
89 | BYC_letsuchthat of string * N.term * string * N.term
90 | BYC_wehaveand of string * N.term * string * N.term
92 let mk_parser statement lstatus =
93 (* let grammar = CicNotationParser.level2_ast_grammar lstatus in *)
94 let term = CicNotationParser.term lstatus in
95 let let_defs = CicNotationParser.let_defs lstatus in
96 let protected_binder_vars = CicNotationParser.protected_binder_vars lstatus in
97 (* {{{ parser initialization *)
99 GLOBAL: term statement;
100 constructor: [ [ name = IDENT; SYMBOL ":"; typ = term -> (name, typ) ] ];
101 tactic_term: [ [ t = term LEVEL "90" -> t ] ];
105 | id = IDENT -> Some id ]
108 ident_list1: [ [ LPAREN; idents = LIST1 IDENT; RPAREN -> idents ] ];
110 [ tactic_terms = LIST1 tactic_term SEP SYMBOL "," -> tactic_terms ]
113 [ IDENT "normalize" ; delta = OPT [ IDENT "nodelta" -> () ] ->
114 let delta = match delta with None -> true | _ -> false in
116 (*| IDENT "unfold"; t = OPT tactic_term -> `Unfold t*)
117 | IDENT "whd" ; delta = OPT [ IDENT "nodelta" -> () ] ->
118 let delta = match delta with None -> true | _ -> false in
121 sequent_pattern_spec: [
125 path = OPT [SYMBOL ":" ; path = tactic_term -> path ] ->
126 (id,match path with Some p -> p | None -> N.UserInput) ];
127 goal_path = OPT [ SYMBOL <:unicode<vdash>>; term = tactic_term -> term ] ->
129 match goal_path, hyp_paths with
130 None, [] -> Some N.UserInput
132 | Some goal_path, _ -> Some goal_path
141 [ "match" ; wanted = tactic_term ;
142 sps = OPT [ "in"; sps = sequent_pattern_spec -> sps ] ->
144 | sps = sequent_pattern_spec ->
147 let wanted,hyp_paths,goal_path =
148 match wanted_and_sps with
149 wanted,None -> wanted, [], Some N.UserInput
150 | wanted,Some (hyp_paths,goal_path) -> wanted,hyp_paths,goal_path
152 wanted, hyp_paths, goal_path ] ->
154 None -> None,[],Some N.UserInput
157 inverter_param_list: [
158 [ params = tactic_term ->
159 let deannotate = function
160 | N.AttributedTerm (_,t) | t -> t
161 in match deannotate params with
162 | N.Implicit _ -> [false]
163 | N.UserInput -> [true]
165 List.map (fun x -> match deannotate x with
166 | N.Implicit _ -> false
167 | N.UserInput -> true
168 | _ -> raise (Invalid_argument "malformed target parameter list 1")) l
170 (*CSC: new NCicPp.status is the best I can do here without changing the
172 raise (Invalid_argument ("malformed target parameter list 2\n" ^
173 NotationPp.pp_term (new NCicPp.status None ) params)) ]
176 [ SYMBOL ">" -> `LeftToRight
177 | SYMBOL "<" -> `RightToLeft ]
179 int: [ [ num = NUMBER -> int_of_string num ] ];
182 [ OPT [ IDENT "names" ];
183 num = OPT [ num = int -> num ];
184 idents = intros_names ->
189 (* MATITA 1.0 using: [ [ using = OPT [ IDENT "using"; t = tactic_term -> t ] -> using ] ]; *)
191 [ SYMBOL "@"; t = tactic_term -> G.NTactic(loc,[G.NApply (loc, t)])
192 | IDENT "apply"; t = tactic_term -> G.NTactic(loc,[G.NApply (loc, t)])
193 | IDENT "applyS"; t = tactic_term -> G.NTactic(loc,[G.NSmartApply(loc, t)])
197 [ id = IDENT ; SYMBOL ":" ; ty = tactic_term -> id,`Decl ty
198 | id = IDENT ; SYMBOL ":" ; ty = tactic_term ;
199 SYMBOL <:unicode<def>> ; bo = tactic_term ->
201 SYMBOL <:unicode<vdash>>;
202 concl = tactic_term -> (List.rev hyps,concl) ] ->
203 G.NTactic(loc,[G.NAssert (loc, seqs)])
204 (*| IDENT "auto"; params = auto_params ->
205 G.NTactic(loc,[G.NAuto (loc, params)])*)
206 | SYMBOL "/"; num = OPT NUMBER ;
207 just_and_params = auto_params; SYMBOL "/" ->
208 let just,params = just_and_params in
209 let depth = match num with Some n -> n | None -> "1" in
213 [G.NAuto(loc,(None,["depth",depth]@params))])
214 | Some (`Univ univ) ->
216 [G.NAuto(loc,(Some univ,["depth",depth]@params))])
219 [G.NAuto(loc,(Some [],["depth",depth]@params))])
222 G.NAutoInteractive (loc, (None,["depth",depth]@params))))
223 | IDENT "intros" -> G.NMacro (loc, G.NIntroGuess loc)
224 | IDENT "check"; t = tactic_term -> G.NMacro(loc,G.NCheck (loc,t))
225 | IDENT "screenshot"; fname = QSTRING ->
226 G.NMacro(loc,G.Screenshot (loc, fname))
227 | IDENT "cases"; what = tactic_term ; where = pattern_spec ->
228 G.NTactic(loc,[G.NCases (loc, what, where)])
229 | IDENT "change"; what = pattern_spec; "with"; with_what = tactic_term ->
230 G.NTactic(loc,[G.NChange (loc, what, with_what)])
231 | SYMBOL "-"; ids = LIST1 IDENT ->
232 G.NTactic(loc,[G.NClear (loc, ids)])
233 | (*SYMBOL "^"*)PLACEHOLDER; num = OPT NUMBER;
234 l = OPT [ SYMBOL "{"; l = LIST1 tactic_term; SYMBOL "}" -> l ] ->
235 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)])
236 | IDENT "cut"; t = tactic_term -> G.NTactic(loc,[G.NCut (loc, t)])
237 (* | IDENT "discriminate"; t = tactic_term -> G.NDiscriminate (loc, t)
238 | IDENT "subst"; t = tactic_term -> G.NSubst (loc, t) *)
239 | IDENT "destruct"; just = OPT [ dom = ident_list1 -> dom ];
240 exclude = OPT [ IDENT "skip"; skip = ident_list1 -> skip ]
241 -> let exclude' = match exclude with None -> [] | Some l -> l in
242 G.NTactic(loc,[G.NDestruct (loc,just,exclude')])
243 | IDENT "elim"; what = tactic_term ; where = pattern_spec ->
244 G.NTactic(loc,[G.NElim (loc, what, where)])
245 | IDENT "generalize"; p=pattern_spec ->
246 G.NTactic(loc,[G.NGeneralize (loc, p)])
247 | IDENT "inversion"; what = tactic_term ; where = pattern_spec ->
248 G.NTactic(loc,[G.NInversion (loc, what, where)])
249 | IDENT "lapply"; t = tactic_term -> G.NTactic(loc,[G.NLApply (loc, t)])
250 | IDENT "letin"; name = IDENT ; SYMBOL <:unicode<def>> ; t = tactic_term;
251 where = pattern_spec ->
252 G.NTactic(loc,[G.NLetIn (loc,where,t,name)])
253 | kind = nreduction_kind; p = pattern_spec ->
254 G.NTactic(loc,[G.NReduce (loc, kind, p)])
255 | dir = direction; what = tactic_term ; where = pattern_spec ->
256 G.NTactic(loc,[G.NRewrite (loc, dir, what, where)])
257 | IDENT "rewrite"; dir = direction; what = tactic_term ; where = pattern_spec ->
258 G.NTactic(loc,[G.NRewrite (loc, dir, what, where)])
259 | IDENT "try"; tac = SELF ->
260 let tac = match tac with G.NTactic(_,[t]) -> t | _ -> assert false in
261 G.NTactic(loc,[ G.NTry (loc,tac)])
262 | IDENT "repeat"; tac = SELF ->
263 let tac = match tac with G.NTactic(_,[t]) -> t | _ -> assert false in
264 G.NTactic(loc,[ G.NRepeat (loc,tac)])
265 | LPAREN; l = LIST1 SELF; RPAREN ->
268 (List.map (function G.NTactic(_,t) -> t | _ -> assert false) l) in
269 G.NTactic(loc,[G.NBlock (loc,l)])
270 | IDENT "assumption" -> G.NTactic(loc,[ G.NAssumption loc])
271 | SYMBOL "#"; ns=IDENT -> G.NTactic(loc,[ G.NIntros (loc,[ns])])
272 | SYMBOL "#"; SYMBOL "_" -> G.NTactic(loc,[ G.NIntro (loc,"_")])
273 | SYMBOL "*" -> G.NTactic(loc,[ G.NCase1 (loc,"_")])
274 | SYMBOL "*"; n=IDENT -> G.NTactic(loc,[ G.NCase1 (loc,n)])
279 | IDENT "fast_paramod"
293 i = auto_fixed_param -> i,""
294 | i = auto_fixed_param ; SYMBOL "="; v = [ v = int ->
295 string_of_int v | v = IDENT -> v ] -> i,v ];
296 just = OPT [ IDENT "by"; by =
297 [ univ = tactic_term_list1 -> `Univ univ
298 | SYMBOL "{"; SYMBOL "}" -> `EmptyUniv
299 | SYMBOL "_" -> `Trace ] -> by ] -> just,params
305 [ 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)
306 | WEPROVED; ty = tactic_term ; t1 = OPT [IDENT "that" ; IDENT "is" ; IDENT "equivalent" ; "to" ; t2 = tactic_term -> t2] ;
307 "done" -> BYC_weproved (ty,None,t1)
309 | "let" ; id1 = IDENT ; SYMBOL ":" ; t1 = tactic_term ;
310 IDENT "such" ; IDENT "that" ; t2=tactic_term ; LPAREN ;
311 id2 = IDENT ; RPAREN -> BYC_letsuchthat (id1,t1,id2,t2)
312 | WEHAVE; t1=tactic_term ; LPAREN ; id1=IDENT ; RPAREN ;"and" ; t2=tactic_term ; LPAREN ; id2=IDENT ; RPAREN ->
313 BYC_wehaveand (id1,t1,id2,t2)
318 rewriting_step_continuation : [
327 [ t1 = SELF; SYMBOL ";"; t2 = SELF ->
330 | G.Seq (_, l) -> l @ [ t2 ]
336 [ tac = SELF; SYMBOL ";";
337 SYMBOL "["; tacs = LIST0 SELF SEP SYMBOL "|"; SYMBOL "]"->
338 (G.Then (loc, tac, tacs))
341 [ IDENT "do"; count = int; tac = SELF ->
342 G.Do (loc, count, tac)
343 | IDENT "repeat"; tac = SELF -> G.Repeat (loc, tac)
347 SYMBOL "["; tacs = LIST0 SELF SEP SYMBOL "|"; SYMBOL "]"->
349 | IDENT "try"; tac = SELF -> G.Try (loc, tac)
351 SYMBOL "["; tacs = LIST0 SELF SEP SYMBOL "|"; SYMBOL "]"->
353 | IDENT "progress"; tac = SELF -> G.Progress (loc, tac)
354 | LPAREN; tac = SELF; RPAREN -> tac
355 | tac = tactic -> tac
359 npunctuation_tactical:
361 [ SYMBOL "[" -> G.NBranch loc
362 | SYMBOL "|" -> G.NShift loc
363 | i = LIST1 int SEP SYMBOL ","; SYMBOL ":" -> G.NPos (loc, i)
364 | SYMBOL "*"; SYMBOL ":" -> G.NWildcard loc
365 | name = IDENT; SYMBOL ":" -> G.NPosbyname (loc, name)
366 | SYMBOL "]" -> G.NMerge loc
367 | SYMBOL ";" -> G.NSemicolon loc
368 | SYMBOL "." -> G.NDot loc
371 nnon_punctuation_tactical:
373 [ IDENT "focus"; goals = LIST1 int -> G.NFocus (loc, goals)
374 | IDENT "unfocus" -> G.NUnfocus loc
375 | IDENT "skip" -> G.NSkip loc
379 [ [ IDENT "definition" ] -> `Definition
380 | [ IDENT "fact" ] -> `Fact
381 | [ IDENT "lemma" ] -> `Lemma
382 | [ IDENT "example" ] -> `Example
383 | [ IDENT "theorem" ] -> `Theorem
384 | [ IDENT "corollary" ] -> `Corollary
389 params = LIST0 protected_binder_vars;
390 SYMBOL ":"; fst_typ = term; SYMBOL <:unicode<def>>; OPT SYMBOL "|";
391 fst_constructors = LIST0 constructor SEP SYMBOL "|";
394 name = IDENT; SYMBOL ":"; typ = term; SYMBOL <:unicode<def>>;
395 OPT SYMBOL "|"; constructors = LIST0 constructor SEP SYMBOL "|" ->
396 (name, true, typ, constructors) ] SEP "with" -> types
400 (fun (names, typ) acc ->
401 (List.map (fun name -> (name, typ)) names) @ acc)
404 let fst_ind_type = (fst_name, true, fst_typ, fst_constructors) in
405 let tl_ind_types = match tl with None -> [] | Some types -> types in
406 let ind_types = fst_ind_type :: tl_ind_types in
412 params = LIST0 protected_binder_vars;
413 SYMBOL ":"; typ = term; SYMBOL <:unicode<def>>; SYMBOL "{" ;
417 SYMBOL ":" -> false,0
418 | SYMBOL ":"; SYMBOL ">" -> true,0
419 | SYMBOL ":"; arity = int ; SYMBOL ">" -> true,arity
422 let b,n = coercion in
424 ] SEP SYMBOL ";"; SYMBOL "}" ->
427 (fun (names, typ) acc ->
428 (List.map (fun name -> (name, typ)) names) @ acc)
431 (params,name,typ,fields)
434 (* XXX: alias spec must be revised (no more instance nums) *)
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, None, 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 (None,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" ; b = OPT SYMBOL "-" ->
540 let b = match b with None -> true | Some _ -> false in G.NQed (loc,b)
541 | nflavour = ntheorem_flavour; name = IDENT; SYMBOL ":"; typ = term;
542 body = OPT [ SYMBOL <:unicode<def>> (* ≝ *); body = term -> body ] ->
543 G.NObj (loc, N.Theorem (nflavour, name, typ, body,`Regular))
544 | nflavour = ntheorem_flavour; name = IDENT; SYMBOL <:unicode<def>> (* ≝ *);
546 G.NObj (loc, N.Theorem (nflavour, name, N.Implicit `JustOne, Some body,`Regular))
547 | IDENT "axiom"; name = IDENT; SYMBOL ":"; typ = term ->
548 G.NObj (loc, N.Theorem (`Axiom, name, typ, None, `Regular))
549 | IDENT "discriminator" ; indty = tactic_term -> G.NDiscriminator (loc,indty)
550 | IDENT "inverter"; name = IDENT; IDENT "for" ; indty = tactic_term ;
551 paramspec = OPT inverter_param_list ;
552 outsort = OPT [ SYMBOL ":" ; outsort = term -> outsort ] ->
553 G.NInverter (loc,name,indty,paramspec,outsort)
554 | LETCOREC ; defs = let_defs ->
555 nmk_rec_corec `CoInductive defs loc
556 | LETREC ; defs = let_defs ->
557 nmk_rec_corec `Inductive defs loc
558 | IDENT "inductive"; spec = inductive_spec ->
559 let (params, ind_types) = spec in
560 G.NObj (loc, N.Inductive (params, ind_types))
561 | IDENT "coinductive"; spec = inductive_spec ->
562 let (params, ind_types) = spec in
563 let ind_types = (* set inductive flags to false (coinductive) *)
564 List.map (fun (name, _, term, ctors) -> (name, false, term, ctors))
567 G.NObj (loc, N.Inductive (params, ind_types))
568 | IDENT "universe"; IDENT "constraint"; u1 = tactic_term;
569 SYMBOL <:unicode<lt>> ; u2 = tactic_term ->
571 | NotationPt.AttributedTerm (_, NotationPt.Sort (`NType i)) ->
572 NUri.uri_of_string ("cic:/matita/pts/Type"^i^".univ")
573 | _ -> raise (Failure "only a Type[…] sort can be constrained")
577 G.NUnivConstraint (loc,u1,u2)
578 | IDENT "unification"; IDENT "hint"; n = int; t = tactic_term ->
579 G.UnificationHint (loc, t, n)
580 | IDENT "coercion"; name = IDENT; spec = OPT [ SYMBOL ":"; ty = term;
581 SYMBOL <:unicode<def>>; t = term; "on";
582 id = [ IDENT | PIDENT ]; SYMBOL ":"; source = term;
583 "to"; target = term -> t,ty,(id,source),target ] ->
584 G.NCoercion(loc,name,spec)
585 | IDENT "record" ; (params,name,ty,fields) = record_spec ->
586 G.NObj (loc, N.Record (params,name,ty,fields))
587 | IDENT "copy" ; s = IDENT; IDENT "from"; u = URI; "with";
588 m = LIST0 [ u1 = URI; SYMBOL <:unicode<mapsto>>; u2 = URI -> u1,u2 ] ->
589 G.NCopy (loc,s,NUri.uri_of_string u,
590 List.map (fun a,b -> NUri.uri_of_string a, NUri.uri_of_string b) m)
591 | lc = lexicon_command -> lc
595 IDENT "alias" ; spec = alias_spec ->
597 | IDENT "notation"; (dir, l1, assoc, prec, l2) = notation ->
598 G.Notation (loc, dir, l1, assoc, prec, l2)
599 | IDENT "interpretation"; id = QSTRING;
600 (symbol, args, l3) = interpretation ->
601 G.Interpretation (loc, id, (symbol, args), l3)
604 [ ncmd = grafite_ncommand; SYMBOL "." -> G.NCommand (loc, ncmd)
605 | punct = npunctuation_tactical -> G.NTactic (loc, [punct])
606 | tac = nnon_punctuation_tactical(*; punct = npunctuation_tactical*) ->
607 G.NTactic (loc, [tac])
608 | tac = ntactic (*; punct = npunctuation_tactical*) ->
611 | tac = nnon_punctuation_tactical;
612 punct = npunctuation_tactical ->
613 G.NTactic (loc, [tac; punct])
618 [ BEGINCOMMENT ; ex = executable ; ENDCOMMENT ->
625 [ ex = executable -> G.Executable (loc, ex)
626 | com = comment -> G.Comment (loc, com)
627 | (iloc,fname,mode) = include_command ; SYMBOL "." ->
628 G.Executable (loc,G.NCommand (loc,G.Include (iloc,mode,fname)))
629 | EOI -> raise End_of_file
637 type db = GrafiteAst.statement Grammar.Entry.e ;;
639 class type g_status =
641 inherit CicNotationParser.g_status
645 class virtual status uid =
647 inherit CicNotationParser.status uid ~keywords:[]
648 val mutable db = None (* mutable only to initialize it :-( *)
649 method parser_db = match db with None -> assert false | Some x -> x
650 method set_parser_db v = {< db = Some v >}
651 method set_parser_status
652 : 'status. #g_status as 'status -> 'self
653 = fun o -> {< db = Some o#parser_db >}#set_notation_parser_status o
655 let grammar = CicNotationParser.level2_ast_grammar self in
656 db <- Some (mk_parser (Grammar.Entry.create grammar "statement") self)
659 let extend status l1 action =
660 let status = CicNotationParser.extend status l1 action in
661 let grammar = CicNotationParser.level2_ast_grammar status in
663 (mk_parser (Grammar.Entry.create grammar "statement") status)
667 let parse_statement status =
668 status#reset_loctable ();
669 parse_statement status#parser_db
671 (* vim:set foldmethod=marker: *)