Skip to content
This repository was archived by the owner on Apr 10, 2023. It is now read-only.

Commit 476c141

Browse files
committed
feat(parenthesis): ✨Beter supports parenthesis
1 parent 570039d commit 476c141

File tree

2 files changed

+208
-118
lines changed

2 files changed

+208
-118
lines changed

__tests__/index.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,3 +248,60 @@ test('member expression', (t) => {
248248
],
249249
});
250250
});
251+
252+
test('parenthesis test', (t) => {
253+
254+
t.deepEqual(parser(tokenizer('1 * (2 + (3 - 3) + 2) - 1')), {
255+
type: astTypes.PROGRAM,
256+
body: [
257+
{
258+
type: astTypes.EXPRESSION_STATEMENT,
259+
expression: {
260+
type: astTypes.BINARY_EXPRESSION,
261+
operator: '-',
262+
left: {
263+
type: astTypes.BINARY_EXPRESSION,
264+
operator: '*',
265+
left: {
266+
type: astTypes.LITERAL,
267+
value: 1,
268+
},
269+
right: {
270+
type: astTypes.BINARY_EXPRESSION,
271+
operator: '+',
272+
left: {
273+
type: astTypes.BINARY_EXPRESSION,
274+
operator: '+',
275+
left: {
276+
type: astTypes.LITERAL,
277+
value: 2,
278+
},
279+
right: {
280+
type: astTypes.BINARY_EXPRESSION,
281+
operator: '-',
282+
left: {
283+
type: astTypes.LITERAL,
284+
value: 3,
285+
},
286+
right: {
287+
type: astTypes.LITERAL,
288+
value: 3,
289+
},
290+
},
291+
},
292+
right: {
293+
type: astTypes.LITERAL,
294+
value: 2,
295+
}
296+
},
297+
},
298+
right: {
299+
type: astTypes.LITERAL,
300+
value: 1,
301+
},
302+
},
303+
},
304+
],
305+
});
306+
307+
});

0 commit comments

Comments
 (0)