From d3127693d4a2125088aa512f593d782843482f2a Mon Sep 17 00:00:00 2001 From: Vincent Laporte Date: Mon, 25 Jun 2018 16:09:11 +0000 Subject: [vernac] use plain strings as attribute names The concrete syntax is still restricted to identifiers. --- vernac/g_vernac.mlg | 14 +++++++------- vernac/ppvernac.ml | 2 +- vernac/vernacentries.ml | 5 ++--- vernac/vernacexpr.ml | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) (limited to 'vernac') diff --git a/vernac/g_vernac.mlg b/vernac/g_vernac.mlg index 23b6898c3..3afe3391b 100644 --- a/vernac/g_vernac.mlg +++ b/vernac/g_vernac.mlg @@ -96,7 +96,7 @@ GRAMMAR EXTEND Gram ] ; attribute: - [ [ k = ident ; v = attribute_value -> (k, v) ] + [ [ k = ident ; v = attribute_value -> (Names.Id.to_string k, v) ] ] ; attribute_value: @@ -106,23 +106,23 @@ GRAMMAR EXTEND Gram ] ; vernac: - [ [ IDENT "Local"; v = vernac_poly -> { let (f, v) = v in ((Names.Id.of_string "local", VernacFlagEmpty) :: f, v) } - | IDENT "Global"; v = vernac_poly -> { let (f, v) = v in ((Names.Id.of_string "global", VernacFlagEmpty) :: f, v) } + [ [ IDENT "Local"; v = vernac_poly -> { let (f, v) = v in (("local", VernacFlagEmpty) :: f, v) } + | IDENT "Global"; v = vernac_poly -> { let (f, v) = v in (("global", VernacFlagEmpty) :: f, v) } | v = vernac_poly -> { v } ] ] ; vernac_poly: - [ [ IDENT "Polymorphic"; v = vernac_aux -> { let (f, v) = v in ((Names.Id.of_string "polymorphic", VernacFlagEmpty) :: f, v) } - | IDENT "Monomorphic"; v = vernac_aux -> { let (f, v) = v in ((Names.Id.of_string "monomorphic", VernacFlagEmpty) :: f, v) } + [ [ IDENT "Polymorphic"; v = vernac_aux -> { let (f, v) = v in (("polymorphic", VernacFlagEmpty) :: f, v) } + | IDENT "Monomorphic"; v = vernac_aux -> { let (f, v) = v in (("monomorphic", VernacFlagEmpty) :: f, v) } | v = vernac_aux -> { v } ] ] ; vernac_aux: (* Better to parse "." here: in case of failure (e.g. in coerce_to_var), *) (* "." is still in the stream and discard_to_dot works correctly *) - [ [ IDENT "Program"; g = gallina; "." -> { ([Names.Id.of_string "program", VernacFlagEmpty], g) } - | IDENT "Program"; g = gallina_ext; "." -> { ([Names.Id.of_string "program", VernacFlagEmpty], g) } + [ [ IDENT "Program"; g = gallina; "." -> { (["program", VernacFlagEmpty], g) } + | IDENT "Program"; g = gallina_ext; "." -> { (["program", VernacFlagEmpty], g) } | g = gallina; "." -> { ([], g) } | g = gallina_ext; "." -> { ([], g) } | c = command; "." -> { ([], c) } diff --git a/vernac/ppvernac.ml b/vernac/ppvernac.ml index 024c145aa..e5547d9b7 100644 --- a/vernac/ppvernac.ml +++ b/vernac/ppvernac.ml @@ -1194,7 +1194,7 @@ open Pputils return (str "}") let rec pr_vernac_flag (k, v) = - let k = keyword (Names.Id.to_string k) in + let k = keyword k in match v with | VernacFlagEmpty -> k | VernacFlagLeaf v -> k ++ str " = " ++ qs v diff --git a/vernac/vernacentries.ml b/vernac/vernacentries.ml index e61687290..080d42607 100644 --- a/vernac/vernacentries.ml +++ b/vernac/vernacentries.ml @@ -2326,7 +2326,6 @@ let attributes_of_flags f atts = in List.fold_left (fun (polymorphism, atts) (k, v) -> - let k = Names.Id.to_string k in match k with | "program" when not atts.program -> assert_empty k v; @@ -2351,8 +2350,8 @@ let attributes_of_flags f atts = user_err Pp.(str "Locality specified twice") | "deprecated" when Option.is_empty atts.deprecated -> begin match v with - | VernacFlagList [ k1, VernacFlagLeaf since ; k2, VernacFlagLeaf note ] - when Names.Id.(equal k1 (of_string "since") && equal k2 (of_string "note")) -> + | VernacFlagList [ "since", VernacFlagLeaf since ; "note", VernacFlagLeaf note ] + | VernacFlagList [ "note", VernacFlagLeaf note ; "since", VernacFlagLeaf since ] -> (polymorphism, { atts with deprecated = Some (since, note) }) | _ -> CErrors.user_err (Pp.str "Ill formed “deprecated” attribute") end diff --git a/vernac/vernacexpr.ml b/vernac/vernacexpr.ml index 2287630c7..e97cac818 100644 --- a/vernac/vernacexpr.ml +++ b/vernac/vernacexpr.ml @@ -459,7 +459,7 @@ type nonrec vernac_expr = (* For extension *) | VernacExtend of extend_name * Genarg.raw_generic_argument list -type vernac_flags = (Names.Id.t * vernac_flag_value) list +type vernac_flags = (string * vernac_flag_value) list and vernac_flag_value = | VernacFlagEmpty | VernacFlagLeaf of string -- cgit v1.2.3