xmlui 0.7.0 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -972,16 +972,30 @@ class Parser {
972
972
  * : "function" identifier "(" [parameterList] ")" blockStatement
973
973
  * ;
974
974
  */
975
- parseFunctionDeclaration() {
975
+ parseFunctionDeclaration(allowNoName = false) {
976
976
  var _a;
977
977
  const startToken = this._lexer.get();
978
978
  // --- Get the function name
979
+ let functionName;
979
980
  const funcId = this._lexer.peek();
980
- if (funcId.type !== Token_1.TokenType.Identifier) {
981
- this.reportError("W003", funcId);
982
- return null;
981
+ if (allowNoName) {
982
+ if (funcId.type !== Token_1.TokenType.LParent) {
983
+ if (funcId.type !== Token_1.TokenType.Identifier) {
984
+ this.reportError("W003", funcId);
985
+ return null;
986
+ }
987
+ functionName = funcId.text;
988
+ this._lexer.get();
989
+ }
990
+ }
991
+ else {
992
+ if (funcId.type !== Token_1.TokenType.Identifier) {
993
+ this.reportError("W003", funcId);
994
+ return null;
995
+ }
996
+ functionName = funcId.text;
997
+ this._lexer.get();
983
998
  }
984
- this._lexer.get();
985
999
  // --- Get the parameter list;
986
1000
  const nextToken = this._lexer.peek();
987
1001
  if (nextToken.type !== Token_1.TokenType.LParent) {
@@ -1091,7 +1105,7 @@ class Parser {
1091
1105
  return null;
1092
1106
  // --- Done.
1093
1107
  return this.createStatementNode("FuncD", {
1094
- name: funcId.text,
1108
+ name: functionName,
1095
1109
  args,
1096
1110
  statement: body,
1097
1111
  }, startToken, body.endToken);
@@ -1275,6 +1289,16 @@ class Parser {
1275
1289
  }, startToken, spreadOperand.endToken)
1276
1290
  : null;
1277
1291
  }
1292
+ if (startToken.type === Token_1.TokenType.Function) {
1293
+ const funcDecl = this.parseFunctionDeclaration(true);
1294
+ return funcDecl
1295
+ ? this.createExpressionNode("ArrowE", {
1296
+ name: funcDecl.name,
1297
+ args: funcDecl.args,
1298
+ statement: funcDecl.statement,
1299
+ }, startToken, funcDecl.endToken)
1300
+ : null;
1301
+ }
1278
1302
  const otherExpr = this.parseNullCoalescingExpr();
1279
1303
  if (!otherExpr) {
1280
1304
  return null;
@@ -103,7 +103,7 @@ exports.tokenTraits = {
103
103
  [Token_1.TokenType.Case]: { keywordLike: true },
104
104
  [Token_1.TokenType.Default]: { keywordLike: true },
105
105
  [Token_1.TokenType.Delete]: { expressionStart: true, canBeUnary: true, keywordLike: true },
106
- [Token_1.TokenType.Function]: { keywordLike: true },
106
+ [Token_1.TokenType.Function]: { keywordLike: true, expressionStart: true },
107
107
  [Token_1.TokenType.Export]: { keywordLike: true },
108
108
  [Token_1.TokenType.Import]: { keywordLike: true },
109
109
  [Token_1.TokenType.As]: { keywordLike: true },