From: Enrico Tassi Date: Fri, 17 Jun 2005 14:58:02 +0000 (+0000) Subject: concrete syntax for goal patterns X-Git-Tag: INDEXING_NO_PROOFS~121 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=49959160408fc4c9629985bd691f7c76523d849d;p=helm.git concrete syntax for goal patterns --- diff --git a/helm/ocaml/cic_disambiguation/cicTextualParser2.ml b/helm/ocaml/cic_disambiguation/cicTextualParser2.ml index b223eb3fd..a1fcc9205 100644 --- a/helm/ocaml/cic_disambiguation/cicTextualParser2.ml +++ b/helm/ocaml/cic_disambiguation/cicTextualParser2.ml @@ -328,6 +328,23 @@ EXTEND | [ IDENT "whd" ] -> `Whd | [ IDENT "normalize" ] -> `Normalize ] ]; + pattern_spec: [ + [ hyp_paths = + OPT [ + paths = LIST1 [ id = IDENT ; SYMBOL ":" ; path = term -> (id,path) ] + SEP SYMBOL ";"; + SYMBOL <:unicode> -> + paths ]; + goal_path = OPT term -> + let hyp_paths = match hyp_paths with None -> [] | Some l -> l in + (hyp_paths, goal_path) ] + ]; + direction: [ + [ IDENT "left" -> `Left + | SYMBOL ">" -> `Left + | IDENT "right" -> `Right + | SYMBOL "<" -> `Right ] + ]; tactic: [ [ [ IDENT "absurd" ]; t = tactic_term -> TacticAst.Absurd (loc, t) @@ -383,28 +400,18 @@ EXTEND where = IDENT ; SYMBOL <:unicode> ; t = tactic_term -> TacticAst.LetIn (loc, t, where) | kind = reduction_kind; - pat = OPT [ - "in"; pat = [ IDENT "goal" -> `Goal | IDENT "hyp" -> `Everywhere ] -> - pat - ]; - terms = LIST0 term SEP SYMBOL "," -> - (match (pat, terms) with - | None, [] -> TacticAst.Reduce (loc, kind, None) - | None, terms -> TacticAst.Reduce (loc, kind, Some (terms, `Goal)) - | Some pat, [] -> fail loc "Missing term [list]" - | Some pat, terms -> TacticAst.Reduce (loc, kind, Some (terms, pat))) - | kind = reduction_kind; where = IDENT ; IDENT "at" ; pat = term -> - TacticAst.ReduceAt (loc, kind, where, pat) + p = OPT [ "in" ; p = pattern_spec -> p ] -> + let p = match p with None -> [], None | Some p -> p in + TacticAst.Reduce (loc, kind, p) | [ IDENT "reflexivity" ] -> TacticAst.Reflexivity loc | [ IDENT "replace" ]; t1 = tactic_term; "with"; t2 = tactic_term -> TacticAst.Replace (loc, t1, t2) - | [ IDENT "rewrite" ; IDENT "left" ] ; t = term -> - TacticAst.Rewrite (loc,`Left, t, None) - | [ IDENT "rewrite" ; IDENT "right" ] ; t = term -> - TacticAst.Rewrite (loc,`Right, t, None) - (* TODO Replace_pattern *) + | IDENT "rewrite" ; d = direction; t = term ; + p = OPT [ "in"; p = pattern_spec -> p ] -> + let p = match p with None -> [], None | Some p -> p in + TacticAst.Rewrite (loc, d, t, p) | [ IDENT "right" ] -> TacticAst.Right loc | [ IDENT "ring" ] -> TacticAst.Ring loc | [ IDENT "split" ] -> TacticAst.Split loc