parseArrowFunction method
Implementation
FunctionNode parseArrowFunction(Expression? exp) {
int? start = token!.startOffset;
// List<Name> params;
// if (token!.type == Token.LPAREN) {
// params = parseParameters();
// } else {
// params = <Name>[];
// }
List<Name> params = <Name>[];
if (exp != null) {
if (exp is SequenceExpression) {
for (var e in exp.expressions) {
if (e is NameExpression) {
params.add(e.name);
} else {
throw fail();
}
}
} else if (exp is NameExpression) {
params.add(exp.name);
} else {
throw fail();
}
}
consume(Token.ARROW);
next();
//Expression body = parseExpression();
//return new FunctionNode(null, params, new BlockStatement([new ReturnStatement(body)]))
BlockStatement body = parseArrowFunctionBody();
return FunctionNode(null, params, body)
..start = start
..end = endOffset
..line = token!.line;
}