diff --git a/README.md b/README.md index 7f488b06..322e3b40 100644 --- a/README.md +++ b/README.md @@ -720,6 +720,7 @@ Extended attributes look like this: * `type`: Always `"extended-attribute"`. * `rhs`: If there is a right-hand side, this will capture its `type` and `value`. The type can be one of the following: + * `"identifier"` * `"identifier-list"` * `"string"` @@ -729,6 +730,8 @@ Extended attributes look like this: * `"integer"` * `"integer-list"` * `"*"` + + Each child of a list has its own `type` of `value`, e.g. `type: "identifier"` for `"identifier-list"`. * `parent`: The container of this type as an Object. ### Default and Const Values diff --git a/lib/productions/token.js b/lib/productions/token.js index 6b59d6b1..189bb9e4 100644 --- a/lib/productions/token.js +++ b/lib/productions/token.js @@ -18,6 +18,10 @@ export class WrappedToken extends Base { }; } + get type() { + return this.tokens.value.type; + } + get value() { return unescape(this.tokens.value.value); } diff --git a/test/syntax/baseline/extended-attributes.json b/test/syntax/baseline/extended-attributes.json index b7a74f7f..0bd64d4f 100644 --- a/test/syntax/baseline/extended-attributes.json +++ b/test/syntax/baseline/extended-attributes.json @@ -12,9 +12,11 @@ "type": "identifier-list", "value": [ { + "type": "identifier", "value": "Worker" }, { + "type": "identifier", "value": "ServiceWorker" } ] @@ -82,9 +84,11 @@ "type": "identifier-list", "value": [ { + "type": "identifier", "value": "null" }, { + "type": "identifier", "value": "const" } ] @@ -98,6 +102,7 @@ "type": "decimal-list", "value": [ { + "type": "decimal", "value": "3.14" } ] diff --git a/test/syntax/baseline/reflector-interface.json b/test/syntax/baseline/reflector-interface.json index 7f7544d9..f748039f 100644 --- a/test/syntax/baseline/reflector-interface.json +++ b/test/syntax/baseline/reflector-interface.json @@ -63,9 +63,11 @@ "type": "string-list", "value": [ { + "type": "string", "value": "\"anonymous\"" }, { + "type": "string", "value": "\"use-credentials\"" } ] @@ -101,9 +103,11 @@ "type": "integer-list", "value": [ { + "type": "integer", "value": "1" }, { + "type": "integer", "value": "4" } ]