Skip to content

Commit 9e8b5a0

Browse files
authored
feat: support bigints (#503)
1 parent e8b86cf commit 9e8b5a0

File tree

6 files changed

+178
-1
lines changed

6 files changed

+178
-1
lines changed

lib/productions/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export function primitive_type(tokeniser) {
102102
const { source } = tokeniser;
103103
const num_type = integer_type(tokeniser) || decimal_type(tokeniser);
104104
if (num_type) return num_type;
105-
const base = tokeniser.consume("boolean", "byte", "octet", "undefined");
105+
const base = tokeniser.consume("bigint", "boolean", "byte", "octet", "undefined");
106106
if (base) {
107107
return new Type({ source, tokens: { base } });
108108
}

lib/tokeniser.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ const nonRegexTerminals = [
7171
"NaN",
7272
"ObservableArray",
7373
"Promise",
74+
"bigint",
7475
"boolean",
7576
"byte",
7677
"double",
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Syntax error at line 2 in bigint-keyword.webidl, since `dictionary Dictionary`:
2+
long long bigint;
3+
^ Dictionary member lacks a name
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dictionary Dictionary {
2+
long long bigint;
3+
};

test/syntax/baseline/bigint.json

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
[
2+
{
3+
"type": "interface",
4+
"name": "Interface",
5+
"inheritance": null,
6+
"members": [
7+
{
8+
"type": "attribute",
9+
"name": "bigint",
10+
"idlType": {
11+
"type": "attribute-type",
12+
"extAttrs": [],
13+
"generic": "",
14+
"nullable": false,
15+
"union": false,
16+
"idlType": "bigint"
17+
},
18+
"extAttrs": [],
19+
"special": "",
20+
"readonly": false
21+
},
22+
{
23+
"type": "operation",
24+
"name": "getBig",
25+
"idlType": {
26+
"type": "return-type",
27+
"extAttrs": [],
28+
"generic": "",
29+
"nullable": false,
30+
"union": false,
31+
"idlType": "bigint"
32+
},
33+
"arguments": [],
34+
"extAttrs": [],
35+
"special": ""
36+
},
37+
{
38+
"type": "operation",
39+
"name": "setBig",
40+
"idlType": {
41+
"type": "return-type",
42+
"extAttrs": [],
43+
"generic": "",
44+
"nullable": false,
45+
"union": false,
46+
"idlType": "void"
47+
},
48+
"arguments": [
49+
{
50+
"type": "argument",
51+
"name": "big",
52+
"extAttrs": [],
53+
"idlType": {
54+
"type": "argument-type",
55+
"extAttrs": [],
56+
"generic": "",
57+
"nullable": false,
58+
"union": false,
59+
"idlType": "bigint"
60+
},
61+
"default": null,
62+
"optional": false,
63+
"variadic": false
64+
}
65+
],
66+
"extAttrs": [],
67+
"special": ""
68+
}
69+
],
70+
"extAttrs": [
71+
{
72+
"type": "extended-attribute",
73+
"name": "Exposed",
74+
"rhs": {
75+
"type": "identifier",
76+
"value": "Window"
77+
},
78+
"arguments": []
79+
}
80+
],
81+
"partial": false
82+
},
83+
{
84+
"type": "dictionary",
85+
"name": "Dictionary",
86+
"inheritance": null,
87+
"members": [
88+
{
89+
"type": "field",
90+
"name": "big",
91+
"extAttrs": [],
92+
"idlType": {
93+
"type": "dictionary-type",
94+
"extAttrs": [],
95+
"generic": "",
96+
"nullable": false,
97+
"union": false,
98+
"idlType": "bigint"
99+
},
100+
"default": null,
101+
"required": false
102+
},
103+
{
104+
"type": "field",
105+
"name": "another",
106+
"extAttrs": [],
107+
"idlType": {
108+
"type": "dictionary-type",
109+
"extAttrs": [],
110+
"generic": "",
111+
"nullable": false,
112+
"union": false,
113+
"idlType": "bigint"
114+
},
115+
"default": null,
116+
"required": true
117+
}
118+
],
119+
"extAttrs": [],
120+
"partial": false
121+
},
122+
{
123+
"type": "typedef",
124+
"name": "allowed",
125+
"idlType": {
126+
"type": "typedef-type",
127+
"extAttrs": [],
128+
"generic": "",
129+
"nullable": false,
130+
"union": true,
131+
"idlType": [
132+
{
133+
"type": null,
134+
"extAttrs": [],
135+
"generic": "",
136+
"nullable": false,
137+
"union": false,
138+
"idlType": "bigint"
139+
},
140+
{
141+
"type": null,
142+
"extAttrs": [],
143+
"generic": "",
144+
"nullable": false,
145+
"union": false,
146+
"idlType": "short"
147+
}
148+
]
149+
},
150+
"extAttrs": []
151+
},
152+
{
153+
"type": "eof",
154+
"value": "",
155+
"trivia": "\n"
156+
}
157+
]

test/syntax/idl/bigint.webidl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[Exposed=Window]
2+
interface Interface {
3+
attribute bigint _bigint;
4+
bigint getBig();
5+
void setBig(bigint big);
6+
};
7+
8+
dictionary Dictionary {
9+
bigint big;
10+
required bigint another;
11+
};
12+
13+
typedef (bigint or short) allowed;

0 commit comments

Comments
 (0)