X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=components%2Fcontent_pres%2FcicNotationParser.ml;h=461e2fc9f755e9b0f868188ac4b535accd4b996d;hb=refs%2Ftags%2F0.4.95;hp=7aa4efe170cc3a52a32e9bfd2383ec06b7a5bbfc;hpb=e485fe6131cd39401a093d0c10aac7e25aa0532d;p=helm.git diff --git a/components/content_pres/cicNotationParser.ml b/components/content_pres/cicNotationParser.ml index 7aa4efe17..461e2fc9f 100644 --- a/components/content_pres/cicNotationParser.ml +++ b/components/content_pres/cicNotationParser.ml @@ -46,6 +46,7 @@ let level1_pattern = let level2_ast = Grammar.Entry.create level2_ast_grammar "level2_ast" let term = Grammar.Entry.create level2_ast_grammar "term" let let_defs = Grammar.Entry.create level2_ast_grammar "let_defs" +let protected_binder_vars = Grammar.Entry.create level2_ast_grammar "protected_binder_vars" let level2_meta = Grammar.Entry.create level2_meta_grammar "level2_meta" let int_of_string s = @@ -223,7 +224,7 @@ let level_of precedence associativity = in string_of_int precedence ^ assoc_string -type rule_id = Token.t Gramext.g_symbol list +type rule_id = Grammar.token Gramext.g_symbol list (* mapping: rule_id -> owned keywords. (rule_id, string list) Hashtbl.t *) let owned_keywords = Hashtbl.create 23 @@ -420,7 +421,7 @@ END (* {{{ Grammar for ast patterns, notation level 2 *) EXTEND - GLOBAL: level2_ast term let_defs; + GLOBAL: level2_ast term let_defs protected_binder_vars; level2_ast: [ [ p = term -> p ] ]; sort: [ [ "Prop" -> `Prop @@ -451,12 +452,17 @@ EXTEND id, Some typ | arg = single_arg -> arg, None | SYMBOL "_" -> Ast.Ident ("_", None), None + | LPAREN; SYMBOL "_"; SYMBOL ":"; typ = term; RPAREN -> + Ast.Ident ("_", None), Some typ ] ]; match_pattern: [ - [ id = IDENT -> id, None, [] + [ id = IDENT -> Ast.Pattern (id, None, []) | LPAREN; id = IDENT; vars = LIST1 possibly_typed_name; RPAREN -> - id, None, vars + Ast.Pattern (id, None, vars) + | id = IDENT; vars = LIST1 possibly_typed_name -> + Ast.Pattern (id, None, vars) + | SYMBOL "_" -> Ast.Wildcard ] ]; binder: [ @@ -502,12 +508,6 @@ EXTEND index_name = OPT [ "on"; id = single_arg -> id ]; ty = OPT [ SYMBOL ":" ; p = term -> p ]; SYMBOL <:unicode> (* ≝ *); body = term -> - let body = fold_binder `Lambda args body in - let ty = - match ty with - | None -> None - | Some ty -> Some (fold_binder `Pi args ty) - in let rec position_of name p = function | [] -> None, p | n :: _ when n = name -> Some p, p @@ -527,7 +527,13 @@ EXTEND | None -> 0 | Some index_name -> find_arg index_name 0 args in - (name, ty), body, index + let args = + List.concat + (List.map + (function (names,ty) -> List.map (function x -> x,ty) names + ) args) + in + args, (name, ty), body, index ] SEP "and" -> defs ] @@ -537,12 +543,15 @@ EXTEND l = LIST1 single_arg SEP SYMBOL "," -> l | SYMBOL "_" -> [Ast.Ident ("_", None)] ]; typ = OPT [ SYMBOL ":"; t = term -> t ] -> (vars, typ) - | LPAREN; - vars = [ - l = LIST1 single_arg SEP SYMBOL "," -> l - | SYMBOL "_" -> [Ast.Ident ("_", None)] ]; - typ = OPT [ SYMBOL ":"; t = term -> t ]; - RPAREN -> (vars, typ) + ] + ]; + protected_binder_vars: [ + [ LPAREN; vars = binder_vars; RPAREN -> vars + ] + ]; + maybe_protected_binder_vars: [ + [ vars = binder_vars -> vars + | vars = protected_binder_vars -> vars ] ]; term: LEVEL "10N" [ (* let in *) @@ -556,10 +565,10 @@ EXTEND ]; term: LEVEL "20R" (* binder *) [ - [ b = binder; (vars, typ) = binder_vars; SYMBOL "."; body = term -> + [ b = binder; (vars, typ) = maybe_protected_binder_vars; SYMBOL "."; body = term -> return_term loc (fold_cluster b vars typ body) | SYMBOL <:unicode> (* ∃ *); - (vars, typ) = binder_vars; SYMBOL "."; body = term -> + (vars, typ) = maybe_protected_binder_vars; SYMBOL "."; body = term -> return_term loc (fold_exists vars typ body) ] ];