X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fcic_notation%2FgrafiteParser.ml;h=cceeaf10dfb4b717f82e59c6e1d3154221607255;hb=1bcad789810fd37d346e690f18557aeedc6fe08c;hp=984635ec60cc44433df2b847ee3f877f1ff9edc6;hpb=cd602bc57c4ceba6188b4cac0dbf5dad8f5df7b6;p=helm.git diff --git a/helm/ocaml/cic_notation/grafiteParser.ml b/helm/ocaml/cic_notation/grafiteParser.ml index 984635ec6..cceeaf10d 100644 --- a/helm/ocaml/cic_notation/grafiteParser.ml +++ b/helm/ocaml/cic_notation/grafiteParser.ml @@ -30,8 +30,10 @@ let grammar = CicNotationParser.level2_ast_grammar let term = CicNotationParser.term let statement = Grammar.Entry.create grammar "statement" -let add_raw_attribute ?context ~text term = - CicNotationPt.AttributedTerm (`Raw (text, context), term) +let add_raw_attribute ~text t = CicNotationPt.AttributedTerm (`Raw text, t) + +let default_precedence = 50 +let default_associativity = Gramext.NonA EXTEND GLOBAL: term statement; @@ -123,8 +125,13 @@ EXTEND GrafiteAst.Cut (loc, ident, t) | IDENT "decide"; IDENT "equality" -> GrafiteAst.DecideEquality loc - | IDENT "decompose"; where = tactic_term -> - GrafiteAst.Decompose (loc, where) + | IDENT "decompose"; types = OPT ident_list0; what = IDENT; + OPT "names"; num = OPT [num = int -> num]; + idents = OPT ident_list0 -> + let idents = match idents with None -> [] | Some idents -> idents in + let types = match types with None -> [] | Some types -> types in + let to_spec id = GrafiteAst.Ident id in + GrafiteAst.Decompose (loc, List.rev_map to_spec types, what, idents) | IDENT "discriminate"; t = tactic_term -> GrafiteAst.Discriminate (loc, t) | IDENT "elim"; what = tactic_term; @@ -361,12 +368,22 @@ EXTEND IDENT "for"; p2 = [ blob = UNPARSED_AST -> - add_raw_attribute ~context:`Ast ~text:blob + add_raw_attribute ~text:(sprintf "@{%s}" blob) (CicNotationParser.parse_level2_ast (Stream.of_string blob)) | blob = UNPARSED_META -> - add_raw_attribute ~context:`Meta ~text:blob + add_raw_attribute ~text:(sprintf "${%s}" blob) (CicNotationParser.parse_level2_meta (Stream.of_string blob)) ] -> + let assoc = + match assoc with + | None -> default_associativity + | Some assoc -> assoc + in + let prec = + match prec with + | None -> default_precedence + | Some prec -> prec + in (add_raw_attribute ~text:s (CicNotationParser.parse_level1_pattern (Stream.of_string s)), assoc, prec, p2)