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 let parse_statement grafite_parser lexbuf =
47 (fun () -> (Grammar.Entry.parse (Obj.magic grafite_parser) (Obj.magic lexbuf)))
49 let add_raw_attribute ~text t = N.AttributedTerm (`Raw text, t)
51 let default_associativity = Gramext.NonA
53 let mk_rec_corec ind_kind defs loc =
56 | (params,(N.Ident (name, None), ty),_,_) :: _ ->
57 let ty = match ty with Some ty -> ty | None -> N.Implicit `JustOne in
60 (fun var ty -> N.Binder (`Pi,var,ty)
66 let body = N.Ident (name,None) in
67 (loc, N.Theorem(`Definition, name, ty, Some (N.LetRec (ind_kind, defs, body)), `Regular))
69 let nmk_rec_corec ind_kind defs loc =
70 let loc,t = mk_rec_corec ind_kind defs loc in
74 let nnon_punct_of_punct = function
75 | G.Skip loc -> G.NSkip loc
76 | G.Unfocus loc -> G.NUnfocus loc
77 | G.Focus (loc,l) -> G.NFocus (loc,l)
80 type by_continuation =
82 | BYC_weproved of N.term * string option * N.term option
83 | BYC_letsuchthat of string * N.term * string * N.term
84 | BYC_wehaveand of string * N.term * string * N.term
86 let mk_parser statement lstatus =
87 (* let grammar = CicNotationParser.level2_ast_grammar lstatus in *)
88 let term = CicNotationParser.term lstatus in
89 let let_defs = CicNotationParser.let_defs lstatus in
90 let protected_binder_vars = CicNotationParser.protected_binder_vars lstatus in
91 (* {{{ parser initialization *)
93 GLOBAL: term statement;
94 constructor: [ [ name = IDENT; SYMBOL ":"; typ = term -> (name, typ) ] ];
95 tactic_term: [ [ t = term LEVEL "90" -> t ] ];
99 | id = IDENT -> Some id ]
102 ident_list1: [ [ LPAREN; idents = LIST1 IDENT; RPAREN -> idents ] ];
104 [ tactic_terms = LIST1 tactic_term SEP SYMBOL "," -> tactic_terms ]
107 [ IDENT "normalize" ; delta = OPT [ IDENT "nodelta" -> () ] ->
108 let delta = match delta with None -> true | _ -> false in
110 (*| IDENT "unfold"; t = OPT tactic_term -> `Unfold t*)
111 | IDENT "whd" ; delta = OPT [ IDENT "nodelta" -> () ] ->
112 let delta = match delta with None -> true | _ -> false in
115 sequent_pattern_spec: [
119 path = OPT [SYMBOL ":" ; path = tactic_term -> path ] ->
120 (id,match path with Some p -> p | None -> N.UserInput) ];
121 goal_path = OPT [ SYMBOL <:unicode<vdash>>; term = tactic_term -> term ] ->
123 match goal_path, hyp_paths with
124 None, [] -> Some N.UserInput
126 | Some goal_path, _ -> Some goal_path
135 [ "match" ; wanted = tactic_term ;
136 sps = OPT [ "in"; sps = sequent_pattern_spec -> sps ] ->
138 | 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
163 | _ -> raise (Invalid_argument ("malformed target parameter list 2\n" ^ NotationPp.pp_term params)) ]
166 [ SYMBOL ">" -> `LeftToRight
167 | SYMBOL "<" -> `RightToLeft ]
169 int: [ [ num = NUMBER -> int_of_string num ] ];
172 [ OPT [ IDENT "names" ];
173 num = OPT [ num = int -> num ];
174 idents = intros_names ->
179 (* MATITA 1.0 using: [ [ using = OPT [ IDENT "using"; t = tactic_term -> t ] -> using ] ]; *)
181 [ SYMBOL "@"; t = tactic_term -> G.NTactic(loc,[G.NApply (loc, t)])
182 | IDENT "apply"; t = tactic_term -> G.NTactic(loc,[G.NApply (loc, t)])
183 | IDENT "applyS"; t = tactic_term -> G.NTactic(loc,[G.NSmartApply(loc, t)])
187 [ id = IDENT ; SYMBOL ":" ; ty = tactic_term -> id,`Decl ty
188 | id = IDENT ; SYMBOL ":" ; ty = tactic_term ;
189 SYMBOL <:unicode<def>> ; bo = tactic_term ->
191 SYMBOL <:unicode<vdash>>;
192 concl = tactic_term -> (List.rev hyps,concl) ] ->
193 G.NTactic(loc,[G.NAssert (loc, seqs)])
194 (*| IDENT "auto"; params = auto_params ->
195 G.NTactic(loc,[G.NAuto (loc, params)])*)
196 | SYMBOL "/"; num = OPT NUMBER ;
197 just_and_params = auto_params; SYMBOL "/" ->
198 let just,params = just_and_params in
199 let depth = match num with Some n -> n | None -> "1" in
203 [G.NAuto(loc,(None,["depth",depth]@params))])
204 | Some (`Univ univ) ->
206 [G.NAuto(loc,(Some univ,["depth",depth]@params))])
209 [G.NAuto(loc,(Some [],["depth",depth]@params))])
212 G.NAutoInteractive (loc, (None,["depth",depth]@params))))
213 | IDENT "intros" -> G.NMacro (loc, G.NIntroGuess loc)
214 | IDENT "check"; t = term -> G.NMacro(loc,G.NCheck (loc,t))
215 | IDENT "screenshot"; fname = QSTRING ->
216 G.NMacro(loc,G.Screenshot (loc, fname))
217 | IDENT "cases"; what = tactic_term ; where = pattern_spec ->
218 G.NTactic(loc,[G.NCases (loc, what, where)])
219 | IDENT "change"; what = pattern_spec; "with"; with_what = tactic_term ->
220 G.NTactic(loc,[G.NChange (loc, what, with_what)])
221 | SYMBOL "-"; ids = LIST1 IDENT ->
222 G.NTactic(loc,[G.NClear (loc, ids)])
223 | (*SYMBOL "^"*)PLACEHOLDER; num = OPT NUMBER;
224 l = OPT [ SYMBOL "{"; l = LIST1 tactic_term; SYMBOL "}" -> l ] ->
225 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)])
226 | IDENT "cut"; t = tactic_term -> G.NTactic(loc,[G.NCut (loc, t)])
227 (* | IDENT "discriminate"; t = tactic_term -> G.NDiscriminate (loc, t)
228 | IDENT "subst"; t = tactic_term -> G.NSubst (loc, t) *)
229 | IDENT "destruct"; just = OPT [ dom = ident_list1 -> dom ];
230 exclude = OPT [ IDENT "skip"; skip = ident_list1 -> skip ]
231 -> let exclude' = match exclude with None -> [] | Some l -> l in
232 G.NTactic(loc,[G.NDestruct (loc,just,exclude')])
233 | IDENT "elim"; what = tactic_term ; where = pattern_spec ->
234 G.NTactic(loc,[G.NElim (loc, what, where)])
235 | IDENT "generalize"; p=pattern_spec ->
236 G.NTactic(loc,[G.NGeneralize (loc, p)])
237 | IDENT "inversion"; what = tactic_term ; where = pattern_spec ->
238 G.NTactic(loc,[G.NInversion (loc, what, where)])
239 | IDENT "lapply"; t = tactic_term -> G.NTactic(loc,[G.NLApply (loc, t)])
240 | IDENT "letin"; name = IDENT ; SYMBOL <:unicode<def>> ; t = tactic_term;
241 where = pattern_spec ->
242 G.NTactic(loc,[G.NLetIn (loc,where,t,name)])
243 | kind = nreduction_kind; p = pattern_spec ->
244 G.NTactic(loc,[G.NReduce (loc, kind, p)])
245 | dir = direction; what = tactic_term ; where = pattern_spec ->
246 G.NTactic(loc,[G.NRewrite (loc, dir, what, where)])
247 | IDENT "rewrite"; dir = direction; what = tactic_term ; where = pattern_spec ->
248 G.NTactic(loc,[G.NRewrite (loc, dir, what, where)])
249 | IDENT "try"; tac = SELF ->
250 let tac = match tac with G.NTactic(_,[t]) -> t | _ -> assert false in
251 G.NTactic(loc,[ G.NTry (loc,tac)])
252 | IDENT "repeat"; tac = SELF ->
253 let tac = match tac with G.NTactic(_,[t]) -> t | _ -> assert false in
254 G.NTactic(loc,[ G.NRepeat (loc,tac)])
255 | LPAREN; l = LIST1 SELF; RPAREN ->
258 (List.map (function G.NTactic(_,t) -> t | _ -> assert false) l) in
259 G.NTactic(loc,[G.NBlock (loc,l)])
260 | IDENT "assumption" -> G.NTactic(loc,[ G.NAssumption loc])
261 | SYMBOL "#"; ns=IDENT -> G.NTactic(loc,[ G.NIntros (loc,[ns])])
262 | SYMBOL "#"; SYMBOL "_" -> G.NTactic(loc,[ G.NIntro (loc,"_")])
263 | SYMBOL "*" -> G.NTactic(loc,[ G.NCase1 (loc,"_")])
264 | SYMBOL "*"; n=IDENT -> G.NTactic(loc,[ G.NCase1 (loc,n)])
269 | IDENT "fast_paramod"
283 i = auto_fixed_param -> i,""
284 | i = auto_fixed_param ; SYMBOL "="; v = [ v = int ->
285 string_of_int v | v = IDENT -> v ] -> i,v ];
286 just = OPT [ IDENT "by"; by =
287 [ univ = tactic_term_list1 -> `Univ univ
288 | SYMBOL "{"; SYMBOL "}" -> `EmptyUniv
289 | SYMBOL "_" -> `Trace ] -> by ] -> just,params
295 [ 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)
296 | WEPROVED; ty = tactic_term ; t1 = OPT [IDENT "that" ; IDENT "is" ; IDENT "equivalent" ; "to" ; t2 = tactic_term -> t2] ;
297 "done" -> BYC_weproved (ty,None,t1)
299 | "let" ; id1 = IDENT ; SYMBOL ":" ; t1 = tactic_term ;
300 IDENT "such" ; IDENT "that" ; t2=tactic_term ; LPAREN ;
301 id2 = IDENT ; RPAREN -> BYC_letsuchthat (id1,t1,id2,t2)
302 | WEHAVE; t1=tactic_term ; LPAREN ; id1=IDENT ; RPAREN ;"and" ; t2=tactic_term ; LPAREN ; id2=IDENT ; RPAREN ->
303 BYC_wehaveand (id1,t1,id2,t2)
308 rewriting_step_continuation : [
317 [ t1 = SELF; SYMBOL ";"; t2 = SELF ->
320 | G.Seq (_, l) -> l @ [ t2 ]
326 [ tac = SELF; SYMBOL ";";
327 SYMBOL "["; tacs = LIST0 SELF SEP SYMBOL "|"; SYMBOL "]"->
328 (G.Then (loc, tac, tacs))
331 [ IDENT "do"; count = int; tac = SELF ->
332 G.Do (loc, count, tac)
333 | IDENT "repeat"; tac = SELF -> G.Repeat (loc, tac)
337 SYMBOL "["; tacs = LIST0 SELF SEP SYMBOL "|"; SYMBOL "]"->
339 | IDENT "try"; tac = SELF -> G.Try (loc, tac)
341 SYMBOL "["; tacs = LIST0 SELF SEP SYMBOL "|"; SYMBOL "]"->
343 | IDENT "progress"; tac = SELF -> G.Progress (loc, tac)
344 | LPAREN; tac = SELF; RPAREN -> tac
345 | tac = tactic -> tac
349 npunctuation_tactical:
351 [ SYMBOL "[" -> G.NBranch loc
352 | SYMBOL "|" -> G.NShift loc
353 | i = LIST1 int SEP SYMBOL ","; SYMBOL ":" -> G.NPos (loc, i)
354 | SYMBOL "*"; SYMBOL ":" -> G.NWildcard loc
355 | name = IDENT; SYMBOL ":" -> G.NPosbyname (loc, name)
356 | SYMBOL "]" -> G.NMerge loc
357 | SYMBOL ";" -> G.NSemicolon loc
358 | SYMBOL "." -> G.NDot loc
361 nnon_punctuation_tactical:
363 [ IDENT "focus"; goals = LIST1 int -> G.NFocus (loc, goals)
364 | IDENT "unfocus" -> G.NUnfocus loc
365 | IDENT "skip" -> G.NSkip loc
369 [ [ IDENT "definition" ] -> `Definition
370 | [ IDENT "fact" ] -> `Fact
371 | [ IDENT "lemma" ] -> `Lemma
372 | [ IDENT "example" ] -> `Example
373 | [ IDENT "theorem" ] -> `Theorem
374 | [ IDENT "corollary" ] -> `Corollary
379 params = LIST0 protected_binder_vars;
380 SYMBOL ":"; fst_typ = term; SYMBOL <:unicode<def>>; OPT SYMBOL "|";
381 fst_constructors = LIST0 constructor SEP SYMBOL "|";
384 name = IDENT; SYMBOL ":"; typ = term; SYMBOL <:unicode<def>>;
385 OPT SYMBOL "|"; constructors = LIST0 constructor SEP SYMBOL "|" ->
386 (name, true, typ, constructors) ] SEP "with" -> types
390 (fun (names, typ) acc ->
391 (List.map (fun name -> (name, typ)) names) @ acc)
394 let fst_ind_type = (fst_name, true, fst_typ, fst_constructors) in
395 let tl_ind_types = match tl with None -> [] | Some types -> types in
396 let ind_types = fst_ind_type :: tl_ind_types in
402 params = LIST0 protected_binder_vars;
403 SYMBOL ":"; typ = term; SYMBOL <:unicode<def>>; SYMBOL "{" ;
407 SYMBOL ":" -> false,0
408 | SYMBOL ":"; SYMBOL ">" -> true,0
409 | SYMBOL ":"; arity = int ; SYMBOL ">" -> true,arity
412 let b,n = coercion in
414 ] SEP SYMBOL ";"; SYMBOL "}" ->
417 (fun (names, typ) acc ->
418 (List.map (fun name -> (name, typ)) names) @ acc)
421 (params,name,typ,fields)
425 [ IDENT "id"; id = QSTRING; SYMBOL "="; uri = QSTRING ->
426 let alpha = "[a-zA-Z]" in
427 let num = "[0-9]+" in
428 let ident_cont = "\\("^alpha^"\\|"^num^"\\|_\\|\\\\\\)" in
429 let decoration = "\\'" in
430 let ident = "\\("^alpha^ident_cont^"*"^decoration^"*\\|_"^ident_cont^"+"^decoration^"*\\)" in
431 let rex = Str.regexp ("^"^ident^"$") in
432 if Str.string_match rex id 0 then
433 if (try ignore (NReference.reference_of_string uri); true
434 with NReference.IllFormedReference _ -> false)
436 G.Ident_alias (id, uri)
439 (HExtlib.Localized (loc, CicNotationParser.Parse_error (Printf.sprintf "Not a valid uri: %s" uri)))
441 raise (HExtlib.Localized (loc, CicNotationParser.Parse_error (
442 Printf.sprintf "Not a valid identifier: %s" id)))
443 | IDENT "symbol"; symbol = QSTRING;
444 instance = OPT [ LPAREN; IDENT "instance"; n = int; RPAREN -> n ];
445 SYMBOL "="; dsc = QSTRING ->
447 match instance with Some i -> i | None -> 0
449 G.Symbol_alias (symbol, instance, dsc)
451 instance = OPT [ LPAREN; IDENT "instance"; n = int; RPAREN -> n ];
452 SYMBOL "="; dsc = QSTRING ->
454 match instance with Some i -> i | None -> 0
456 G.Number_alias (instance, dsc)
460 [ l = LIST0 [ SYMBOL <:unicode<eta>> (* η *); SYMBOL "." -> () ];
462 N.IdentArg (List.length l, id)
466 [ IDENT "left"; IDENT "associative" -> Gramext.LeftA
467 | IDENT "right"; IDENT "associative" -> Gramext.RightA
468 | IDENT "non"; IDENT "associative" -> Gramext.NonA
472 [ "with"; IDENT "precedence"; n = NUMBER -> int_of_string n ]
475 [ dir = OPT direction; s = QSTRING;
476 assoc = OPT associativity; prec = precedence;
479 [ blob = UNPARSED_AST ->
480 add_raw_attribute ~text:(Printf.sprintf "@{%s}" blob)
481 (CicNotationParser.parse_level2_ast lstatus
482 (Ulexing.from_utf8_string blob))
483 | blob = UNPARSED_META ->
484 add_raw_attribute ~text:(Printf.sprintf "${%s}" blob)
485 (CicNotationParser.parse_level2_meta lstatus
486 (Ulexing.from_utf8_string blob))
490 | None -> default_associativity
491 | Some assoc -> assoc
494 add_raw_attribute ~text:s
495 (CicNotationParser.parse_level1_pattern lstatus prec
496 (Ulexing.from_utf8_string s))
498 (dir, p1, assoc, prec, p2)
502 [ r = NREF -> N.NRefPattern (NReference.reference_of_string r)
503 | IMPLICIT -> N.ImplicitPattern
504 | id = IDENT -> N.VarPattern id
505 | LPAREN; terms = LIST1 SELF; RPAREN ->
509 | terms -> N.ApplPattern terms)
513 [ s = CSYMBOL; args = LIST0 argument; SYMBOL "="; t = level3_term ->
519 IDENT "include" ; path = QSTRING ->
520 loc,path,G.WithPreferences
521 | IDENT "include" ; IDENT "alias"; path = QSTRING ->
522 loc,path,G.OnlyPreferences
523 | IDENT "include'" ; path = QSTRING ->
524 loc,path,G.WithoutPreferences
527 grafite_ncommand: [ [
528 IDENT "qed" -> G.NQed loc
529 | nflavour = ntheorem_flavour; name = IDENT; SYMBOL ":"; typ = term;
530 body = OPT [ SYMBOL <:unicode<def>> (* ≝ *); body = term -> body ] ->
531 G.NObj (loc, N.Theorem (nflavour, name, typ, body,`Regular))
532 | nflavour = ntheorem_flavour; name = IDENT; SYMBOL <:unicode<def>> (* ≝ *);
534 G.NObj (loc, N.Theorem (nflavour, name, N.Implicit `JustOne, Some body,`Regular))
535 | IDENT "axiom"; name = IDENT; SYMBOL ":"; typ = term ->
536 G.NObj (loc, N.Theorem (`Axiom, name, typ, None, `Regular))
537 | IDENT "discriminator" ; indty = tactic_term -> G.NDiscriminator (loc,indty)
538 | IDENT "inverter"; name = IDENT; IDENT "for" ; indty = tactic_term ;
539 paramspec = OPT inverter_param_list ;
540 outsort = OPT [ SYMBOL ":" ; outsort = term -> outsort ] ->
541 G.NInverter (loc,name,indty,paramspec,outsort)
542 | LETCOREC ; defs = let_defs ->
543 nmk_rec_corec `CoInductive defs loc
544 | LETREC ; defs = let_defs ->
545 nmk_rec_corec `Inductive defs loc
546 | IDENT "inductive"; spec = inductive_spec ->
547 let (params, ind_types) = spec in
548 G.NObj (loc, N.Inductive (params, ind_types))
549 | IDENT "coinductive"; spec = inductive_spec ->
550 let (params, ind_types) = spec in
551 let ind_types = (* set inductive flags to false (coinductive) *)
552 List.map (fun (name, _, term, ctors) -> (name, false, term, ctors))
555 G.NObj (loc, N.Inductive (params, ind_types))
556 | IDENT "universe"; IDENT "constraint"; u1 = tactic_term;
557 SYMBOL <:unicode<lt>> ; u2 = tactic_term ->
559 | NotationPt.AttributedTerm (_, NotationPt.Sort (`NType i)) ->
560 NUri.uri_of_string ("cic:/matita/pts/Type"^i^".univ")
561 | _ -> raise (Failure "only a Type[…] sort can be constrained")
565 G.NUnivConstraint (loc,u1,u2)
566 | IDENT "unification"; IDENT "hint"; n = int; t = tactic_term ->
567 G.UnificationHint (loc, t, n)
568 | IDENT "coercion"; name = IDENT; SYMBOL ":"; ty = term;
569 SYMBOL <:unicode<def>>; t = term; "on";
570 id = [ IDENT | PIDENT ]; SYMBOL ":"; source = term;
571 "to"; target = term ->
572 G.NCoercion(loc,name,t,ty,(id,source),target)
573 | IDENT "record" ; (params,name,ty,fields) = record_spec ->
574 G.NObj (loc, N.Record (params,name,ty,fields))
575 | IDENT "copy" ; s = IDENT; IDENT "from"; u = URI; "with";
576 m = LIST0 [ u1 = URI; SYMBOL <:unicode<mapsto>>; u2 = URI -> u1,u2 ] ->
577 G.NCopy (loc,s,NUri.uri_of_string u,
578 List.map (fun a,b -> NUri.uri_of_string a, NUri.uri_of_string b) m)
579 | lc = lexicon_command -> lc
583 IDENT "alias" ; spec = alias_spec ->
585 | IDENT "notation"; (dir, l1, assoc, prec, l2) = notation ->
586 G.Notation (loc, dir, l1, assoc, prec, l2)
587 | IDENT "interpretation"; id = QSTRING;
588 (symbol, args, l3) = interpretation ->
589 G.Interpretation (loc, id, (symbol, args), l3)
592 [ ncmd = grafite_ncommand; SYMBOL "." -> G.NCommand (loc, ncmd)
593 | punct = npunctuation_tactical -> G.NTactic (loc, [punct])
594 | tac = nnon_punctuation_tactical(*; punct = npunctuation_tactical*) ->
595 G.NTactic (loc, [tac])
596 | tac = ntactic (*; punct = npunctuation_tactical*) ->
599 | tac = nnon_punctuation_tactical;
600 punct = npunctuation_tactical ->
601 G.NTactic (loc, [tac; punct])
606 [ BEGINCOMMENT ; ex = executable ; ENDCOMMENT ->
613 [ ex = executable -> G.Executable (loc, ex)
614 | com = comment -> G.Comment (loc, com)
615 | (iloc,fname,mode) = include_command ; SYMBOL "." ->
616 G.Executable (loc,G.NCommand (loc,G.Include (iloc,mode,fname)))
617 | EOI -> raise End_of_file
625 type db = GrafiteAst.statement Grammar.Entry.e ;;
627 class type g_status =
629 inherit CicNotationParser.g_status
635 inherit CicNotationParser.status ~keywords:[]
636 val mutable db = None
637 method parser_db = match db with None -> assert false | Some x -> x
638 method set_parser_db v = {< db = Some v >}
639 method set_parser_status
640 : 'status. #g_status as 'status -> 'self
641 = fun o -> {< db = Some o#parser_db >}#set_notation_parser_status o
643 let grammar = CicNotationParser.level2_ast_grammar self in
644 db <- Some (mk_parser (Grammar.Entry.create grammar "statement") self)
647 let extend status l1 action =
648 let status = CicNotationParser.extend status l1 action in
649 let grammar = CicNotationParser.level2_ast_grammar status in
651 (mk_parser (Grammar.Entry.create grammar "statement") status)
655 let parse_statement status =
656 parse_statement status#parser_db
658 (* vim:set foldmethod=marker: *)