From 49959160408fc4c9629985bd691f7c76523d849d Mon Sep 17 00:00:00 2001 From: Enrico Tassi Date: Fri, 17 Jun 2005 14:58:02 +0000 Subject: [PATCH] concrete syntax for goal patterns --- .../cic_disambiguation/cicTextualParser2.ml | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) 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 -- 2.39.2