Add type pack argument grammar

Including variadic/generic type packs
This commit is contained in:
JohnnyMorganz 2022-01-17 16:24:46 +00:00
parent e0b9aadb06
commit 39f85e2c9c

View file

@ -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 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). is available in the [syntax section](syntax).
> Note: this grammar is currently missing type pack syntax for generic arguments
```ebnf ```ebnf
chunk = block chunk = block
block = {stat [';']} [laststat [';']] block = {stat [';']} [laststat [';']]
@ -63,7 +61,7 @@ SimpleType =
STRING | STRING |
'true' | 'true' |
'false' | 'false' |
NAME ['.' NAME] [ '<' TypeList '>' ] | NAME ['.' NAME] [ '<' [TypeParams] '>' ] |
'typeof' '(' exp ')' | 'typeof' '(' exp ')' |
TableType | TableType |
FunctionType FunctionType
@ -76,7 +74,9 @@ Type =
GenericTypePack = NAME '...' ['=' '(' TypeList ')'] GenericTypePack = NAME '...' ['=' '(' TypeList ')']
GenericTypeList = NAME ['=' Type] [',' GenericTypeList] | GenericTypePack {',' GenericTypePack} GenericTypeList = NAME ['=' Type] [',' GenericTypeList] | GenericTypePack {',' GenericTypePack}
TypeList = Type [',' TypeList] | '...' Type TypeList = Type [',' TypeList] | '...' Type
ReturnType = Type | '(' TypeList ')' TypeParams = (Type | TypePack | '...' Type | NAME '...') [',' TypeParams]
TypePack = '(' [TypeList] ')'
ReturnType = Type | TypePack
TableIndexer = '[' Type ']' ':' Type TableIndexer = '[' Type ']' ':' Type
TableProp = NAME ':' Type TableProp = NAME ':' Type
TablePropOrIndexer = TableProp | TableIndexer TablePropOrIndexer = TableProp | TableIndexer