Commit 2f1dc36e authored by POTTIER Francois's avatar POTTIER Francois

Check that payload of [@name] is a valid identifier.

parent 074b7318
......@@ -111,11 +111,25 @@ type opacity =
let opacity (attrs : attributes) : opacity =
if present "opaque" attrs then Opaque else NonOpaque
(* [name attrs] tests for the presence of a [@name] attribute, carrying
a payload of type [string]. *)
(* [name attrs] tests for the presence of a [@name] attribute, carrying a
payload of type [string]. We check that the payload is a valid (lowercase
or uppercase) identifier, because we intend to use it as the basis of a
method name. *)
let identifier : string Arg.conv =
fun e ->
match Arg.string e with
| Error msg ->
Error msg
| Ok s ->
match classify s with
| LIDENT | UIDENT ->
Ok s
| OTHER ->
Error "identifier"
let name (attrs : attributes) : string option =
Arg.get_attr ~deriver:plugin Arg.string (select "name" attrs)
Arg.get_attr ~deriver:plugin identifier (select "name" attrs)
(* [constructor attrs] tests for the presence of a [@constructor] attribute,
carrying a payload that is an arbitrary OCaml expression. *)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment