diff options
author | Alain Frisch <alain@frisch.fr> | 2013-04-10 09:22:54 +0000 |
---|---|---|
committer | Alain Frisch <alain@frisch.fr> | 2013-04-10 09:22:54 +0000 |
commit | 71787e0228da47489fbcf15c92abfc124240bcc4 (patch) | |
tree | 29b3e5f90af1781a638e93682ceea9f06e578b6e | |
parent | ec9dacb3f156256675adbc5f1645b0841ed58fb0 (diff) |
Support dot-separated attributes for extensions and attributes.
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/extension_points@13495 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | experimental/frisch/extension_points.txt | 10 | ||||
-rw-r--r-- | parsing/parser.mly | 6 |
2 files changed, 12 insertions, 4 deletions
diff --git a/experimental/frisch/extension_points.txt b/experimental/frisch/extension_points.txt index 492340f16..db0911343 100644 --- a/experimental/frisch/extension_points.txt +++ b/experimental/frisch/extension_points.txt @@ -4,9 +4,13 @@ This file describes the changes on the extension_points branch. === Attributes Attributes are "decorations" of the syntax tree which are ignored by -the type-checker. An attribute is made of an identifier (an "LIDENT" -or "UIDENT", written id below) and an optional expression (written -expr below). +the type-checker. An attribute is made of an identifier (written id) +and an optional expression (written expr below). + +The identifier can be a lowercase or uppercase identifier (including +OCaml keywords) or a sequence of such atomic identifiers separated with +a dots (whitespaces are allowed around the dots). In the Parsetree, +the identifier is represented as a single string (without spaces). Attributes on expressions, type expressions, module expressions, module type expressions, patterns (TODO: class expressions, class type expressions): diff --git a/parsing/parser.mly b/parsing/parser.mly index 11d636096..b39973542 100644 --- a/parsing/parser.mly +++ b/parsing/parser.mly @@ -1900,7 +1900,7 @@ additive: /* Attributes and extensions */ -attr_id: +single_attr_id: LIDENT { $1 } | UIDENT { $1 } | AND { "and" } @@ -1954,6 +1954,10 @@ attr_id: /* mod/land/lor/lxor/lsl/lsr/asr are not supported for now */ ; +attr_id: + single_attr_id { $1 } + | single_attr_id DOT attr_id { $1 ^ "." ^ $3 } +; attribute: LBRACKETAT attr_id opt_expr RBRACKET { ($2, $3) } ; |