Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit 00ad71d

Browse files
despairblueJamesHenry
authored andcommitted
Fix: add instanceof to ast-converter (fixes #252) (#251)
1 parent 2989f8b commit 00ad71d

File tree

3 files changed

+150
-0
lines changed

3 files changed

+150
-0
lines changed

Diff for: lib/ast-converter.js

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ TOKEN_TO_TEXT[SyntaxKind.GreaterThanEqualsToken] = ">=";
5959
TOKEN_TO_TEXT[SyntaxKind.EqualsEqualsToken] = "==";
6060
TOKEN_TO_TEXT[SyntaxKind.ExclamationEqualsToken] = "!=";
6161
TOKEN_TO_TEXT[SyntaxKind.EqualsEqualsEqualsToken] = "===";
62+
TOKEN_TO_TEXT[SyntaxKind.InstanceOfKeyword] = "instanceof";
6263
TOKEN_TO_TEXT[SyntaxKind.ExclamationEqualsEqualsToken] = "!==";
6364
TOKEN_TO_TEXT[SyntaxKind.EqualsGreaterThanToken] = "=>";
6465
TOKEN_TO_TEXT[SyntaxKind.PlusToken] = "+";

Diff for: tests/fixtures/basics/instanceof.result.js

+148
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
module.exports = {
2+
"type": "Program",
3+
"range": [
4+
0,
5+
17
6+
],
7+
"loc": {
8+
"start": {
9+
"line": 1,
10+
"column": 0
11+
},
12+
"end": {
13+
"line": 1,
14+
"column": 17
15+
}
16+
},
17+
"body": [
18+
{
19+
"type": "ExpressionStatement",
20+
"range": [
21+
0,
22+
17
23+
],
24+
"loc": {
25+
"start": {
26+
"line": 1,
27+
"column": 0
28+
},
29+
"end": {
30+
"line": 1,
31+
"column": 17
32+
}
33+
},
34+
"expression": {
35+
"type": "BinaryExpression",
36+
"range": [
37+
0,
38+
17
39+
],
40+
"loc": {
41+
"start": {
42+
"line": 1,
43+
"column": 0
44+
},
45+
"end": {
46+
"line": 1,
47+
"column": 17
48+
}
49+
},
50+
"left": {
51+
"type": "Literal",
52+
"range": [
53+
0,
54+
2
55+
],
56+
"loc": {
57+
"start": {
58+
"line": 1,
59+
"column": 0
60+
},
61+
"end": {
62+
"line": 1,
63+
"column": 2
64+
}
65+
},
66+
"value": "",
67+
"raw": "''"
68+
},
69+
"operator": "instanceof",
70+
"right": {
71+
"type": "Identifier",
72+
"range": [
73+
14,
74+
17
75+
],
76+
"loc": {
77+
"start": {
78+
"line": 1,
79+
"column": 14
80+
},
81+
"end": {
82+
"line": 1,
83+
"column": 17
84+
}
85+
},
86+
"name": "Set"
87+
}
88+
}
89+
}
90+
],
91+
"sourceType": "script",
92+
"tokens": [
93+
{
94+
"type": "String",
95+
"value": "''",
96+
"range": [
97+
0,
98+
2
99+
],
100+
"loc": {
101+
"start": {
102+
"line": 1,
103+
"column": 0
104+
},
105+
"end": {
106+
"line": 1,
107+
"column": 2
108+
}
109+
}
110+
},
111+
{
112+
"type": "Keyword",
113+
"value": "instanceof",
114+
"range": [
115+
3,
116+
13
117+
],
118+
"loc": {
119+
"start": {
120+
"line": 1,
121+
"column": 3
122+
},
123+
"end": {
124+
"line": 1,
125+
"column": 13
126+
}
127+
}
128+
},
129+
{
130+
"type": "Identifier",
131+
"value": "Set",
132+
"range": [
133+
14,
134+
17
135+
],
136+
"loc": {
137+
"start": {
138+
"line": 1,
139+
"column": 14
140+
},
141+
"end": {
142+
"line": 1,
143+
"column": 17
144+
}
145+
}
146+
}
147+
]
148+
};

Diff for: tests/fixtures/basics/instanceof.src.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
'' instanceof Set

0 commit comments

Comments
 (0)