doc/ref/spec.md: simplify attributes
Simplify the specifcation of attributes. The only requirement
of attribute bodies is now that parentheses, brackets, and
curly braces are matched.
This approach is adopted from Swift attributes. It is compatible
with a wide range of attribute formats of other languages,
allowing for easier interoperability.
Parsing in the cue API remains the same.
This allows for more tolerance of faulty inputs
as well, allowing for bugs in external specs, such
as mentioned in Issue #181 to not affect the basic
operation of CUE itself. This is especially useful
as the external specs are often not used at all.
Change-Id: I1f0dc63fe4ebf468d4b041481a1d15f999232dab
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/4223
Reviewed-by: Jonathan Amsterdam <jba@google.com>
diff --git a/doc/ref/spec.md b/doc/ref/spec.md
index db7916a..a7bf68b 100644
--- a/doc/ref/spec.md
+++ b/doc/ref/spec.md
@@ -1118,13 +1118,12 @@
Label = LabelName [ "?" ] | "[" AliasExpr "]".
LabelName = identifier | simple_string_lit .
-attribute = "@" identifier "(" attr_elems ")" .
-attr_elems = attr_elem { "," attr_elem }
-attr_elem = attr_string | attr_label | attr_nest .
-attr_label = identifier "=" attr_string .
-attr_nest = identifier "(" attr_elems ")" .
-attr_string = { attr_char } | string_lit .
-attr_char = /* an arbitrary Unicode code point except newline, ',', '"', `'`, '#', '=', '(', and ')' */ .
+attribute = "@" identifier "(" attr_tokens ")" .
+attr_tokens = { attr_token |
+ "(" attr_tokens ")" |
+ "[" attr_tokens "]" |
+ "{" attr_tokens "}" } .
+attr_token = /* any token except '(', ')', '[', ']', '{', or '}' */
```
<!--