From 39f85e2c9c8c58faed0e83800d498cb161a60f29 Mon Sep 17 00:00:00 2001 From: JohnnyMorganz Date: Mon, 17 Jan 2022 16:24:46 +0000 Subject: [PATCH] Add type pack argument grammar Including variadic/generic type packs --- docs/_pages/grammar.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/_pages/grammar.md b/docs/_pages/grammar.md index 8a6d7f1a..c2799141 100644 --- a/docs/_pages/grammar.md +++ b/docs/_pages/grammar.md @@ -7,8 +7,6 @@ classes: wide This is the complete syntax grammar for Luau in EBNF. More information about the terminal nodes String and Number is available in the [syntax section](syntax). -> Note: this grammar is currently missing type pack syntax for generic arguments - ```ebnf chunk = block block = {stat [';']} [laststat [';']] @@ -63,7 +61,7 @@ SimpleType = STRING | 'true' | 'false' | - NAME ['.' NAME] [ '<' TypeList '>' ] | + NAME ['.' NAME] [ '<' [TypeParams] '>' ] | 'typeof' '(' exp ')' | TableType | FunctionType @@ -76,7 +74,9 @@ Type = GenericTypePack = NAME '...' ['=' '(' TypeList ')'] GenericTypeList = NAME ['=' Type] [',' GenericTypeList] | GenericTypePack {',' GenericTypePack} TypeList = Type [',' TypeList] | '...' Type -ReturnType = Type | '(' TypeList ')' +TypeParams = (Type | TypePack | '...' Type | NAME '...') [',' TypeParams] +TypePack = '(' [TypeList] ')' +ReturnType = Type | TypePack TableIndexer = '[' Type ']' ':' Type TableProp = NAME ':' Type TablePropOrIndexer = TableProp | TableIndexer