From 4031fbd0d39f40d236ea673989f588f2de1656d3 Mon Sep 17 00:00:00 2001 From: Vyacheslav Egorov <vegorov@roblox.com> Date: Tue, 8 Jun 2021 22:22:07 +0300 Subject: [PATCH] Fix syntax to reference new 'funchead' grammar instead of 'funcargs' --- rfcs/syntax-lambda-function-expressions.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/rfcs/syntax-lambda-function-expressions.md b/rfcs/syntax-lambda-function-expressions.md index 7c3077fd..d3344beb 100644 --- a/rfcs/syntax-lambda-function-expressions.md +++ b/rfcs/syntax-lambda-function-expressions.md @@ -36,7 +36,8 @@ prefixexp ::= NAME | `(' expr `)' ``` After: ``` -prefixexp ::= NAME [`->' subexpr] | funcargs `->' subexpr | `(' expr `)' +funchead ::= `(' [parlist] `)' [`:' ReturnType] +prefixexp ::= NAME [`->' subexpr] | funchead `->' subexpr | `(' expr `)' ``` Note that an anonymous function with a single argument is allowed to have a type annotation only when it's inside `()`. @@ -47,7 +48,7 @@ We extend the syntax of *prefixexp* instead of *simpleexp* because we parse expr Parsing of the first option is easy, we check a single token for `->` after the NAME. -### Parsing ``funcargs `->' subexpr`` +### Parsing ``funchead `->' subexpr`` Parsing of the function argument list is in conflict with an expression in `` `(' expr `)'``. To resolve this issue, we are going to perform the switch to potential function arguments after we consume the common `(` token. @@ -86,5 +87,9 @@ local b = filter(map(c, do(a: number) a * 2), do(a: number) a > 0) Syntax of *simpleexp* is extended with a new option: ``` -| `do` funcargs subexpr +| `do` funchead subexpr +``` +where +``` +funchead ::= `(' [parlist] `)' [`:' ReturnType] ```