Skip to content

feat: add type field for WrappedToken #822

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions lib/productions/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export class WrappedToken extends Base {
};
}

get type() {
return this.tokens.value.type;
}

get value() {
return unescape(this.tokens.value.value);
}
Expand Down
5 changes: 5 additions & 0 deletions test/syntax/baseline/extended-attributes.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
"type": "identifier-list",
"value": [
{
"type": "identifier",
"value": "Worker"
},
{
"type": "identifier",
"value": "ServiceWorker"
}
]
Expand Down Expand Up @@ -82,9 +84,11 @@
"type": "identifier-list",
"value": [
{
"type": "identifier",
"value": "null"
},
{
"type": "identifier",
"value": "const"
}
]
Expand All @@ -98,6 +102,7 @@
"type": "decimal-list",
"value": [
{
"type": "decimal",
"value": "3.14"
}
]
Expand Down
4 changes: 4 additions & 0 deletions test/syntax/baseline/reflector-interface.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@
"type": "string-list",
"value": [
{
"type": "string",
"value": "\"anonymous\""
},
{
"type": "string",
"value": "\"use-credentials\""
}
]
Expand Down Expand Up @@ -101,9 +103,11 @@
"type": "integer-list",
"value": [
{
"type": "integer",
"value": "1"
},
{
"type": "integer",
"value": "4"
}
]
Expand Down