Skip to content

Commit 2009999

Browse files
committed
parse multi-lines condition with its multi-lines parenthesis
1 parent 58bc01c commit 2009999

File tree

6 files changed

+1452
-169
lines changed

6 files changed

+1452
-169
lines changed

lib/parser.js

Lines changed: 271 additions & 169 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/parser.jison

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4706,6 +4706,104 @@ Parenthesis // {{{
47064706
body: $8
47074707
}, @1, @8);
47084708
}
4709+
| '(' NL_0M Expression NL_0M ')'
4710+
{
4711+
$$ = $3;
4712+
}
4713+
| '(' NL_0M Expression ',' Expression1CList NL_0M ')'
4714+
{
4715+
$5.unshift($3);
4716+
4717+
$$ = location({
4718+
kind: NodeKind.SequenceExpression,
4719+
expressions: $5
4720+
}, @3, @5);
4721+
}
4722+
| '(' NL_0M Identifier NL_0M ')'
4723+
{
4724+
$$ = $3;
4725+
}
4726+
| '(' NL_0M Identifier '=' Expression NL_0M ')'
4727+
{
4728+
$$ = location({
4729+
kind: NodeKind.BinaryExpression,
4730+
operator: location({
4731+
kind: BinaryOperatorKind.Assignment,
4732+
assignment: AssignmentOperatorKind.Equality
4733+
}, @4),
4734+
left: $3,
4735+
right: $5
4736+
}, @3, @5);
4737+
}
4738+
| '(' NL_0M Identifier '=' Expression ',' Expression1CList NL_0M ')'
4739+
{
4740+
$7.unshift(location({
4741+
kind: NodeKind.BinaryExpression,
4742+
operator: location({
4743+
kind: BinaryOperatorKind.Assignment,
4744+
assignment: AssignmentOperatorKind.Equality
4745+
}, @4),
4746+
left: $3,
4747+
right: $5
4748+
}, @3, @5));
4749+
4750+
$$ = location({
4751+
kind: NodeKind.SequenceExpression,
4752+
expressions: $7
4753+
}, @3, @7);
4754+
}
4755+
| '(' NL_0M Identifier 'SPACED_?' Expression 'SPACED_:' Expression NL_0M ')'
4756+
{
4757+
$$ = location({
4758+
kind: NodeKind.ConditionalExpression,
4759+
condition: $3,
4760+
whenTrue: $5,
4761+
whenFalse: $7
4762+
}, @3, @7);
4763+
}
4764+
| '(' NL_0M Identifier NL_0M ')' LambdaBody
4765+
{
4766+
$$ = location({
4767+
kind: NodeKind.LambdaExpression,
4768+
modifiers: [],
4769+
parameters: [location({
4770+
kind: NodeKind.Parameter,
4771+
modifiers: [],
4772+
name: $3
4773+
}, @3)],
4774+
body: $6
4775+
}, @1, @6);
4776+
}
4777+
| '(' NL_0M Identifier '=' Expression NL_0M ')' LambdaBody
4778+
{
4779+
$$ = location({
4780+
kind: NodeKind.LambdaExpression,
4781+
modifiers: [],
4782+
parameters: [location({
4783+
kind: NodeKind.Parameter,
4784+
modifiers: [],
4785+
name: $3,
4786+
defaultValue: $5
4787+
}, @3, @5)],
4788+
body: $8
4789+
}, @1, @8);
4790+
}
4791+
| '(' NL_0M Identifier '=' Expression ',' FunctionParameterList NL_0M ')' LambdaBody
4792+
{
4793+
$7.unshift(location({
4794+
kind: NodeKind.Parameter,
4795+
modifiers: [],
4796+
name: $3,
4797+
defaultValue: $5
4798+
}, @3, @5));
4799+
4800+
$$ = location({
4801+
kind: NodeKind.LambdaExpression,
4802+
modifiers: [],
4803+
parameters: $7,
4804+
body: $10
4805+
}, @1, @10);
4806+
}
47094807
;
47104808
// }}}
47114809

@@ -4739,6 +4837,35 @@ Parenthesis_NoAnonymousFunction // {{{
47394837
whenFalse: $6
47404838
}, @2, @6);
47414839
}
4840+
| '(' NL_0M Expression NL_0M ')'
4841+
{
4842+
$$ = $3;
4843+
}
4844+
| '(' NL_0M Identifier '=' Expression NL_0M ')'
4845+
{
4846+
$$ = location({
4847+
kind: NodeKind.BinaryExpression,
4848+
operator: location({
4849+
kind: BinaryOperatorKind.Assignment,
4850+
assignment: AssignmentOperatorKind.Equality
4851+
}, @4),
4852+
left: $3,
4853+
right: $5
4854+
}, @3, @5);
4855+
}
4856+
| '(' NL_0M Identifier NL_0M ')'
4857+
{
4858+
$$ = $3;
4859+
}
4860+
| '(' NL_0M Identifier 'SPACED_?' Expression 'SPACED_:' Expression NL_0M ')'
4861+
{
4862+
$$ = location({
4863+
kind: NodeKind.ConditionalExpression,
4864+
condition: $3,
4865+
whenTrue: $5,
4866+
whenFalse: $7
4867+
}, @3, @7);
4868+
}
47424869
;
47434870
// }}}
47444871

0 commit comments

Comments
 (0)