1 (* Copyright (C) 2004, 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/
29 prerr_endline "<NEW_TEXTUAL_PARSER>";
31 prerr_endline "</NEW_TEXTUAL_PARSER>"
34 (** if set to true each number will have a different insance number and can
35 * thus be interpreted differently than others *)
36 let use_fresh_num_instances = false
38 (** does the lexer return COMMENT tokens? *)
39 let return_comments = false
43 open DisambiguateTypes
45 exception Parse_error of Token.flocation * string
47 let cic_lexer = CicTextualLexer2.cic_lexer ~comments:return_comments ()
49 let fresh_num_instance =
51 if use_fresh_num_instances then
52 (fun () -> incr n; !n)
56 let choice_of_uri uri =
57 let term = CicUtil.term_of_uri uri in
58 (uri, (fun _ _ _ -> term))
60 let grammar = Grammar.gcreate cic_lexer
62 let term = Grammar.Entry.create grammar "term"
63 let term0 = Grammar.Entry.create grammar "term0"
64 let tactic = Grammar.Entry.create grammar "tactic"
65 let tactical = Grammar.Entry.create grammar "tactical"
66 let tactical0 = Grammar.Entry.create grammar "tactical0"
67 let command = Grammar.Entry.create grammar "command"
68 let alias_spec = Grammar.Entry.create grammar "alias_spec"
69 let macro = Grammar.Entry.create grammar "macro"
70 let script = Grammar.Entry.create grammar "script"
71 let statement = Grammar.Entry.create grammar "statement"
72 let statements = Grammar.Entry.create grammar "statements"
74 let return_term loc term = CicAst.AttributedTerm (`Loc loc, term)
77 let (x, y) = CicAst.loc_of_floc floc in
78 failwith (Printf.sprintf "Error at characters %d - %d: %s" x y msg)
80 let name_of_string = function
81 | "_" -> Cic.Anonymous
84 let string_of_name = function
85 | Cic.Anonymous -> "_"
88 let int_opt = function
90 | Some lexeme -> Some (int_of_string lexeme)
94 Pervasives.int_of_string s
96 failwith (sprintf "Lexer failure: string_of_int \"%s\" failed" s)
98 (** the uri of an inductive type (a ".ind" uri) is not meaningful without an
99 * xpointer. Still, it's likely that an user who wrote "cic:/blabla/foo.ind"
100 * actually meant "cic:/blabla/foo.ind#xpointer(1/1)", i.e. the first inductive
101 * type in a block of mutual inductive types.
103 * This function performs the expansion foo.ind -> foo#xpointer..., if needed
105 let ind_expansion uri =
106 let len = String.length uri in
107 if len >= 4 && String.sub uri (len - 4) 4 = ".ind" then
108 uri ^ "#xpointer(1/1)"
112 let mk_binder_ast binder typ vars body =
115 let name = name_of_string var in
116 CicAst.Binder (binder, (name, typ), body))
120 GLOBAL: term term0 statement statements;
125 with Failure _ -> raise (Parse_error (loc, "integer literal expected"))
129 [ s = SYMBOL "_" -> None
130 | t = term -> Some t ]
133 [ SYMBOL <:unicode<Pi>> (* Π *) -> `Pi
134 | SYMBOL <:unicode<exists>> (* ∃ *) -> `Exists
135 | SYMBOL <:unicode<forall>> (* ∀ *) -> `Forall ]
137 binder_high: [ [ SYMBOL <:unicode<lambda>> (* λ *) -> `Lambda ] ];
142 | "CProp" -> `CProp ]
145 [ PAREN "("; i = IDENT; SYMBOL ":"; typ = term; PAREN ")" ->
146 (Cic.Name i, Some typ)
147 | i = IDENT -> (Cic.Name i, None)
151 [ SYMBOL "\\subst"; (* to avoid catching frequent "a [1]" cases *)
154 i = IDENT; SYMBOL <:unicode<Assign>> (* ≔ *); t = term -> (i, t)
160 substituted_name: [ (* a subs.name is an explicit substitution subject *)
161 [ s = IDENT; subst = OPT subst -> CicAst.Ident (s, subst)
162 | s = URI; subst = OPT subst -> CicAst.Uri (ind_expansion s, subst)
165 name: [ (* as substituted_name with no explicit substitution *)
166 [ s = [ IDENT | SYMBOL ] -> s ]
169 [ n = name -> (n, [])
170 | PAREN "("; head = name; vars = LIST1 typed_name; PAREN ")" ->
175 [ PAREN "(" ; names = LIST1 IDENT SEP SYMBOL ",";
176 SYMBOL ":"; ty = term; PAREN ")" -> names,ty
177 | name = IDENT -> [name],CicAst.Implicit
183 args = LIST1 [arg = arg -> arg];
184 index_name = OPT [ IDENT "on"; idx = IDENT -> idx ];
185 ty = OPT [ SYMBOL ":" ; t = term -> t ];
186 SYMBOL <:unicode<def>> (* ≝ *);
188 let rec list_of_binder binder ty final_term = function
191 CicAst.Binder (binder, (Cic.Name name, Some ty),
192 list_of_binder binder ty final_term tl)
194 let rec binder_of_arg_list binder final_term = function
197 list_of_binder binder ty
198 (binder_of_arg_list binder final_term tl) l
200 let t1' = binder_of_arg_list `Lambda t1 args in
204 | Some ty -> Some (binder_of_arg_list `Pi ty args)
206 let rec get_position_of name n = function
212 (get_position_of name (n+1) tl)
214 let rec find_arg name n = function
215 | [] -> (fail loc (sprintf "Argument %s not found" name))
217 let (got,len) = get_position_of name 0 l in
219 | None -> (find_arg name (n+len) tl)
220 | Some where -> n + where)
223 (match index_name with
225 | (Some name) -> find_arg name 0 args)
227 ((Cic.Name name,ty'), t1', index)
230 constructor: [ [ name = IDENT; SYMBOL ":"; typ = term -> (name, typ) ] ];
232 [ vars = LIST1 IDENT SEP SYMBOL ",";
233 typ = OPT [ SYMBOL ":"; t = term -> t ] -> (vars, typ)
234 | PAREN "("; vars = LIST1 IDENT SEP SYMBOL ",";
235 typ = OPT [ SYMBOL ":"; t = term -> t ]; PAREN ")" -> (vars, typ)
238 term0: [ [ t = term; EOI -> return_term loc t ] ];
241 [ "let"; var = typed_name;
242 SYMBOL <:unicode<def>> (* ≝ *);
243 t1 = term; "in"; t2 = term ->
244 return_term loc (CicAst.LetIn (var, t1, t2))
245 | "let"; ind_kind = [ "corec" -> `CoInductive | "rec"-> `Inductive ];
246 defs = let_defs; "in"; body = term ->
247 return_term loc (CicAst.LetRec (ind_kind, defs, body))
251 b = binder_low; (vars, typ) = binder_vars; SYMBOL "."; body = term ->
252 let binder = mk_binder_ast b typ vars body in
253 return_term loc binder
254 | b = binder_high; (vars, typ) = binder_vars; SYMBOL "."; body = term ->
255 let binder = mk_binder_ast b typ vars body in
256 return_term loc binder
257 | t1 = term; SYMBOL <:unicode<to>> (* → *); t2 = term ->
258 return_term loc (CicAst.Binder (`Pi, (Cic.Anonymous, Some t1), t2))
260 | "logic_add" LEFTA [ (* nothing here by default *) ]
261 | "logic_mult" LEFTA [ (* nothing here by default *) ]
262 | "logic_inv" NONA [ (* nothing here by default *) ]
264 [ t1 = term; SYMBOL "="; t2 = term ->
265 return_term loc (CicAst.Appl [CicAst.Symbol ("eq", 0); t1; t2])
267 | "add" LEFTA [ (* nothing here by default *) ]
268 | "mult" LEFTA [ (* nothing here by default *) ]
269 | "power" LEFTA [ (* nothing here by default *) ]
270 | "inv" NONA [ (* nothing here by default *) ]
272 [ t1 = term; t2 = term ->
273 let rec aux = function
274 | CicAst.Appl (hd :: tl) -> aux hd @ tl
277 CicAst.Appl (aux t1 @ [t2])
280 [ sort = sort -> CicAst.Sort sort
281 | n = substituted_name -> return_term loc n
282 | i = NUM -> return_term loc (CicAst.Num (i, (fresh_num_instance ())))
283 | IMPLICIT -> return_term loc CicAst.Implicit
284 | PLACEHOLDER -> return_term loc CicAst.UserInput
287 PAREN "["; substs = LIST0 meta_subst SEP SYMBOL ";" ; PAREN "]" ->
292 int_of_string (String.sub m 1 (String.length m - 1))
293 with Failure "int_of_string" ->
294 fail loc ("Invalid meta variable number: " ^ m)
296 return_term loc (CicAst.Meta (index, substs))
297 | outtyp = OPT [ PAREN "["; typ = term; PAREN "]" -> typ ];
299 indty_ident = OPT ["in" ; id = IDENT -> id ];
303 lhs = pattern; SYMBOL <:unicode<Rightarrow>> (* ⇒ *); rhs = term
305 ((lhs: CicAst.case_pattern), rhs)
309 (CicAst.Case (t, indty_ident, outtyp, patterns))
310 | PAREN "("; t1 = term; SYMBOL ":"; t2 = term; PAREN ")" ->
311 return_term loc (CicAst.Appl [CicAst.Symbol ("cast", 0); t1; t2])
312 | PAREN "("; t = term; PAREN ")" -> return_term loc t
316 [ where = OPT [ "in"; ident = IDENT -> ident ] -> where ]
318 tactic_term: [ [ t = term -> t ] ];
320 [ PAREN "["; idents = LIST0 IDENT SEP SYMBOL ";"; PAREN "]" -> idents ]
323 [ PAREN "["; idents = LIST1 IDENT SEP SYMBOL ";"; PAREN "]" -> idents ]
326 [ [ IDENT "reduce" ] -> `Reduce
327 | [ IDENT "simplify" ] -> `Simpl
328 | [ IDENT "whd" ] -> `Whd
329 | [ IDENT "normalize" ] -> `Normalize ]
332 [ [ IDENT "absurd" ]; t = tactic_term ->
333 TacticAst.Absurd (loc, t)
334 | [ IDENT "apply" ]; t = tactic_term ->
335 TacticAst.Apply (loc, t)
336 | [ IDENT "assumption" ] ->
337 TacticAst.Assumption loc
338 | [ IDENT "auto" ] ; num = OPT [ i = NUM -> int_of_string i ] ->
339 TacticAst.Auto (loc,num)
340 | [ IDENT "change" ];
341 t1 = tactic_term; "with"; t2 = tactic_term;
342 where = tactic_where ->
343 TacticAst.Change (loc, t1, t2, where)
344 (* TODO Change_pattern *)
345 | [ IDENT "contradiction" ] ->
346 TacticAst.Contradiction loc
349 TacticAst.Cut (loc, t)
350 | [ IDENT "decompose" ];
351 principles = ident_list1; where = IDENT ->
352 TacticAst.Decompose (loc, where, principles)
353 | [ IDENT "discriminate" ];
355 TacticAst.Discriminate (loc, hyp)
356 | [ IDENT "elimType" ]; t = tactic_term ->
357 TacticAst.ElimType (loc, t)
360 using = OPT [ "using"; using = tactic_term -> using ] ->
361 TacticAst.Elim (loc, t1, using)
362 | [ IDENT "exact" ]; t = tactic_term ->
363 TacticAst.Exact (loc, t)
364 | [ IDENT "exists" ] ->
367 kind = reduction_kind; t = tactic_term ->
368 TacticAst.Fold (loc, kind, t)
369 | [ IDENT "fourier" ] ->
370 TacticAst.Fourier loc
371 | IDENT "goal"; n = NUM -> TacticAst.Goal (loc, int_of_string n)
372 | [ IDENT "injection" ]; ident = IDENT ->
373 TacticAst.Injection (loc, ident)
374 | [ IDENT "intros" ];
375 num = OPT [ num = int -> num ];
376 idents = OPT ident_list0 ->
377 let idents = match idents with None -> [] | Some idents -> idents in
378 TacticAst.Intros (loc, num, idents)
379 | [ IDENT "intro" ] ->
380 TacticAst.Intros (loc, Some 1, [])
381 | [ IDENT "left" ] -> TacticAst.Left loc
383 where = IDENT ; SYMBOL <:unicode<def>> ; t = tactic_term ->
384 TacticAst.LetIn (loc, t, where)
385 | kind = reduction_kind;
387 "in"; pat = [ IDENT "goal" -> `Goal | IDENT "hyp" -> `Everywhere ] ->
390 terms = LIST0 term SEP SYMBOL "," ->
391 (match (pat, terms) with
392 | None, [] -> TacticAst.Reduce (loc, kind, None)
393 | None, terms -> TacticAst.Reduce (loc, kind, Some (terms, `Goal))
394 | Some pat, [] -> fail loc "Missing term [list]"
395 | Some pat, terms -> TacticAst.Reduce (loc, kind, Some (terms, pat)))
396 | kind = reduction_kind; where = IDENT ; IDENT "at" ; pat = term ->
397 TacticAst.ReduceAt (loc, kind, where, pat)
398 | [ IDENT "reflexivity" ] ->
399 TacticAst.Reflexivity loc
400 | [ IDENT "replace" ];
401 t1 = tactic_term; "with"; t2 = tactic_term ->
402 TacticAst.Replace (loc, t1, t2)
403 | [ IDENT "rewrite" ; IDENT "left" ] ; t = term ->
404 TacticAst.Rewrite (loc,`Left, t, None)
405 | [ IDENT "rewrite" ; IDENT "right" ] ; t = term ->
406 TacticAst.Rewrite (loc,`Right, t, None)
407 (* TODO Replace_pattern *)
408 | [ IDENT "right" ] -> TacticAst.Right loc
409 | [ IDENT "ring" ] -> TacticAst.Ring loc
410 | [ IDENT "split" ] -> TacticAst.Split loc
411 | [ IDENT "symmetry" ] ->
412 TacticAst.Symmetry loc
413 | [ IDENT "transitivity" ];
415 TacticAst.Transitivity (loc, t)
416 | [ IDENT "fwd" ]; name = IDENT ->
417 TacticAst.FwdSimpl (loc, name)
418 | [ IDENT "lapply" ]; t = term ->
419 TacticAst.LApply (loc, t, [])
424 [ tacticals = LIST1 NEXT SEP SYMBOL ";" ->
425 TacticAst.Seq (loc, tacticals)
429 PAREN "["; tacs = LIST0 tactical SEP SYMBOL ";"; PAREN "]" ->
430 (TacticAst.Then (loc, tac, tacs))
433 [ [ IDENT "do" ]; count = int; tac = tactical ->
434 TacticAst.Do (loc, count, tac)
435 | [ IDENT "repeat" ]; tac = tactical ->
436 TacticAst.Repeat (loc, tac)
440 PAREN "["; tacs = LIST0 tactical SEP SYMBOL ";"; PAREN "]" ->
441 TacticAst.Tries (loc, tacs)
442 | IDENT "try"; tac = NEXT ->
443 TacticAst.Try (loc, tac)
444 | IDENT "fail" -> TacticAst.Fail loc
445 | IDENT "id" -> TacticAst.IdTac loc
446 | PAREN "("; tac = tactical; PAREN ")" -> tac
447 | tac = tactic -> TacticAst.Tactic (loc, tac)
451 [ [ IDENT "definition" ] -> `Definition
452 | [ IDENT "fact" ] -> `Fact
453 | [ IDENT "lemma" ] -> `Lemma
454 | [ IDENT "remark" ] -> `Remark
455 | [ IDENT "theorem" ] -> `Theorem
459 fst_name = IDENT; params = LIST0 [ arg=arg -> arg ];
460 SYMBOL ":"; fst_typ = term; SYMBOL <:unicode<def>>; OPT SYMBOL "|";
461 fst_constructors = LIST0 constructor SEP SYMBOL "|";
464 name = IDENT; SYMBOL ":"; typ = term; SYMBOL <:unicode<def>>;
465 OPT SYMBOL "|"; constructors = LIST0 constructor SEP SYMBOL "|" ->
466 (name, true, typ, constructors) ] SEP "with" -> types
470 (fun (names, typ) acc ->
471 (List.map (fun name -> (name, typ)) names) @ acc)
474 let fst_ind_type = (fst_name, true, fst_typ, fst_constructors) in
475 let tl_ind_types = match tl with None -> [] | Some types -> types in
476 let ind_types = fst_ind_type :: tl_ind_types in
481 name = IDENT; params = LIST0 [ arg = arg -> arg ] ;
482 SYMBOL ":"; typ = term; SYMBOL <:unicode<def>>; PAREN "{" ;
484 name = IDENT ; SYMBOL ":" ; ty = term -> (name,ty)
485 ] SEP SYMBOL ";"; PAREN "}" ->
488 (fun (names, typ) acc ->
489 (List.map (fun name -> (name, typ)) names) @ acc)
492 (params,name,typ,fields)
496 [ [ IDENT "quit" ] -> TacticAst.Quit loc
497 (* | [ IDENT "abort" ] -> TacticAst.Abort loc *)
498 | [ IDENT "print" ]; name = QSTRING -> TacticAst.Print (loc, name)
499 (* | [ IDENT "undo" ]; steps = OPT NUM ->
500 TacticAst.Undo (loc, int_opt steps)
501 | [ IDENT "redo" ]; steps = OPT NUM ->
502 TacticAst.Redo (loc, int_opt steps) *)
503 | [ IDENT "check" ]; t = term ->
504 TacticAst.Check (loc, t)
505 | [ IDENT "hint" ] -> TacticAst.Hint loc
506 | [ IDENT "whelp"; "match" ] ; t = term ->
507 TacticAst.WMatch (loc,t)
508 | [ IDENT "whelp"; IDENT "instance" ] ; t = term ->
509 TacticAst.WInstance (loc,t)
510 | [ IDENT "whelp"; IDENT "locate" ] ; id = IDENT ->
511 TacticAst.WLocate (loc,id)
512 | [ IDENT "whelp"; IDENT "elim" ] ; t = term ->
513 TacticAst.WElim (loc, t)
514 | [ IDENT "whelp"; IDENT "hint" ] ; t = term ->
515 TacticAst.WHint (loc,t)
516 | [ IDENT "print" ]; name = QSTRING -> TacticAst.Print (loc, name)
521 [ IDENT "id"; id = QSTRING; SYMBOL "="; uri = QSTRING ->
522 let alpha = "[a-zA-Z]" in
523 let num = "[0-9]+" in
524 let ident_cont = "\\("^alpha^"\\|"^num^"\\|_\\|\\\\\\)" in
525 let ident = "\\("^alpha^ident_cont^"*\\|_"^ident_cont^"+\\)" in
526 let rex = Str.regexp ("^"^ident^"$") in
527 if Str.string_match rex id 0 then
529 ("^\\(cic:/\\|theory:/\\)"^ident^
530 "\\(/"^ident^"+\\)*\\(\\."^ident^"\\)+"^
531 "\\(#xpointer("^ num^"\\(/"^num^"\\)+)\\)?$")
533 if Str.string_match rex uri 0 then
534 TacticAst.Ident_alias (id, uri)
536 raise (Parse_error (loc,sprintf "Not a valid uri: %s" uri))
538 raise (Parse_error (loc,sprintf "Not a valid identifier: %s" id))
539 | IDENT "symbol"; symbol = QSTRING;
540 instance = OPT [ PAREN "("; IDENT "instance"; n = NUM; PAREN ")" -> n ];
541 SYMBOL "="; dsc = QSTRING ->
543 match instance with Some i -> int_of_string i | None -> 0
545 TacticAst.Symbol_alias (symbol, instance, dsc)
547 instance = OPT [ PAREN "("; IDENT "instance"; n = NUM; PAREN ")" -> n ];
548 SYMBOL "="; dsc = QSTRING ->
550 match instance with Some i -> int_of_string i | None -> 0
552 TacticAst.Number_alias (instance, dsc)
557 [ IDENT "set" ]; n = QSTRING; v = QSTRING ->
558 TacticAst.Set (loc, n, v)
559 | [ IDENT "qed" ] -> TacticAst.Qed loc
560 | flavour = theorem_flavour; name = IDENT; SYMBOL ":"; typ = term;
561 body = OPT [ SYMBOL <:unicode<def>> (* ≝ *); body = term -> body ] ->
562 TacticAst.Obj (loc,TacticAst.Theorem (flavour, name, typ, body))
563 | flavour = theorem_flavour; name = IDENT;
564 body = OPT [ SYMBOL <:unicode<def>> (* ≝ *); body = term -> body ] ->
565 TacticAst.Obj (loc,TacticAst.Theorem (flavour, name, CicAst.Implicit, body))
566 | "let"; ind_kind = [ "corec" -> `CoInductive | "rec"-> `Inductive ];
570 | ((Cic.Name name,Some ty),_,_) :: _ -> name,ty
571 | ((Cic.Name name,None),_,_) :: _ -> name,CicAst.Implicit
574 let body = CicAst.Ident (name,None) in
575 TacticAst.Obj (loc,TacticAst.Theorem(`Definition, name, ty,
576 Some (CicAst.LetRec (ind_kind, defs, body))))
578 | [ IDENT "inductive" ]; spec = inductive_spec ->
579 let (params, ind_types) = spec in
580 TacticAst.Obj (loc,TacticAst.Inductive (params, ind_types))
581 | [ IDENT "coinductive" ]; spec = inductive_spec ->
582 let (params, ind_types) = spec in
583 let ind_types = (* set inductive flags to false (coinductive) *)
584 List.map (fun (name, _, term, ctors) -> (name, false, term, ctors))
587 TacticAst.Obj (loc,TacticAst.Inductive (params, ind_types))
588 | [ IDENT "coercion" ] ; name = IDENT ->
589 TacticAst.Coercion (loc, CicAst.Ident (name,Some []))
590 | [ IDENT "coercion" ] ; name = URI ->
591 TacticAst.Coercion (loc, CicAst.Uri (name,Some []))
592 | [ IDENT "alias" ]; spec = alias_spec ->
593 TacticAst.Alias (loc, spec)
594 | [ IDENT "record" ]; (params,name,ty,fields) = record_spec ->
595 TacticAst.Obj (loc,TacticAst.Record (params,name,ty,fields))
599 [ cmd = command; SYMBOL "." -> TacticAst.Command (loc, cmd)
600 | tac = tactical; SYMBOL "." -> TacticAst.Tactical (loc, tac)
601 | mac = macro; SYMBOL "." -> TacticAst.Macro (loc, mac)
606 [ BEGINCOMMENT ; ex = executable ; ENDCOMMENT ->
607 TacticAst.Code (loc, ex)
609 TacticAst.Note (loc, str)
614 [ ex = executable -> TacticAst.Executable (loc,ex)
615 | com = comment -> TacticAst.Comment (loc, com)
619 [ l = LIST0 [ statement ] -> l
624 let exc_located_wrapper f =
628 | Stdpp.Exc_located (floc, Stream.Error msg) ->
629 raise (Parse_error (floc, msg))
630 | Stdpp.Exc_located (floc, exn) ->
631 raise (Parse_error (floc, (Printexc.to_string exn)))
633 let parse_term stream =
634 exc_located_wrapper (fun () -> (Grammar.Entry.parse term0 stream))
635 let parse_statement stream =
636 exc_located_wrapper (fun () -> (Grammar.Entry.parse statement stream))
637 let parse_statements stream =
638 exc_located_wrapper (fun () -> (Grammar.Entry.parse statements stream))
643 (** {2 Interface for gTopLevel} *)
645 module EnvironmentP3 =
651 let aliases_grammar = Grammar.gcreate cic_lexer
652 let aliases = Grammar.Entry.create aliases_grammar "aliases"
657 (fun domain_item (dsc, _) acc ->
659 match domain_item with
661 TacticAstPp.pp_alias (TacticAst.Ident_alias (id, dsc)) ^ "."
662 | Symbol (symb, i) ->
663 TacticAstPp.pp_alias (TacticAst.Symbol_alias (symb, i, dsc))
666 TacticAstPp.pp_alias (TacticAst.Number_alias (i, dsc)) ^ "."
671 String.concat "\n" (List.sort compare aliases)
675 aliases: [ (* build an environment from an aliases list *)
676 [ aliases = LIST0 alias; EOI ->
678 (fun env (domain_item, codomain_item) ->
679 Environment.add domain_item codomain_item env)
680 Environment.empty aliases
683 alias: [ (* return a pair <domain_item, codomain_item> from an alias *)
686 [ IDENT "id"; id = IDENT; SYMBOL "="; uri = URI ->
687 (Id id, choice_of_uri uri)
688 | IDENT "symbol"; symbol = QSTRING;
689 PAREN "("; IDENT "instance"; instance = NUM; PAREN ")";
690 SYMBOL "="; dsc = QSTRING ->
691 (Symbol (symbol, int_of_string instance),
692 DisambiguateChoices.lookup_symbol_by_dsc symbol dsc)
694 PAREN "("; IDENT "instance"; instance = NUM; PAREN ")";
695 SYMBOL "="; dsc = QSTRING ->
696 (Num (int_of_string instance),
697 DisambiguateChoices.lookup_num_by_dsc dsc)
707 (fun () -> Grammar.Entry.parse aliases (Stream.of_string s))
710 (* vim:set encoding=utf8: *)