mirror of
https://github.com/luau-lang/luau.git
synced 2024-11-15 14:25:44 +08:00
Update grammar.md (#909)
Fix issues mentioned in https://github.com/Roblox/luau/issues/908
This commit is contained in:
parent
fe7621ee8c
commit
8173491d86
@ -33,19 +33,19 @@ parlist = bindinglist [',' '...'] | '...'
|
|||||||
explist = {exp ','} exp
|
explist = {exp ','} exp
|
||||||
namelist = NAME {',' NAME}
|
namelist = NAME {',' NAME}
|
||||||
|
|
||||||
binding = NAME [':' TypeAnnotation]
|
binding = NAME [':' Type]
|
||||||
bindinglist = binding [',' bindinglist] (* equivalent of Lua 5.1 'namelist', except with optional type annotations *)
|
bindinglist = binding [',' bindinglist] (* equivalent of Lua 5.1 'namelist', except with optional type annotations *)
|
||||||
|
|
||||||
var = NAME | prefixexp '[' exp ']' | prefixexp '.' Name
|
var = NAME | prefixexp '[' exp ']' | prefixexp '.' NAME
|
||||||
varlist = var {',' var}
|
varlist = var {',' var}
|
||||||
prefixexp = var | functioncall | '(' exp ')'
|
prefixexp = var | functioncall | '(' exp ')'
|
||||||
functioncall = prefixexp funcargs | prefixexp ':' NAME funcargs
|
functioncall = prefixexp funcargs | prefixexp ':' NAME funcargs
|
||||||
|
|
||||||
exp = (asexp | unop exp) { binop exp }
|
exp = asexp { binop exp } | unop exp { binop exp }
|
||||||
ifelseexp = 'if' exp 'then' exp {'elseif' exp 'then' exp} 'else' exp
|
ifelseexp = 'if' exp 'then' exp {'elseif' exp 'then' exp} 'else' exp
|
||||||
asexp = simpleexp ['::' Type]
|
asexp = simpleexp ['::' Type]
|
||||||
stringinterp = INTERP_BEGIN exp { INTERP_MID exp } INTERP_END
|
stringinterp = INTERP_BEGIN exp { INTERP_MID exp } INTERP_END
|
||||||
simpleexp = NUMBER | STRING | 'nil' | 'true' | 'false' | '...' | tableconstructor | 'function' body | prefixexp | ifelseexp | stringinterp
|
simpleexp = NUMBER | STRING | 'nil' | 'true' | 'false' | '...' | tableconstructor | 'function' funcbody | prefixexp | ifelseexp | stringinterp
|
||||||
funcargs = '(' [explist] ')' | tableconstructor | STRING
|
funcargs = '(' [explist] ')' | tableconstructor | STRING
|
||||||
|
|
||||||
tableconstructor = '{' [fieldlist] '}'
|
tableconstructor = '{' [fieldlist] '}'
|
||||||
@ -85,5 +85,5 @@ TableProp = NAME ':' Type
|
|||||||
TablePropOrIndexer = TableProp | TableIndexer
|
TablePropOrIndexer = TableProp | TableIndexer
|
||||||
PropList = TablePropOrIndexer {fieldsep TablePropOrIndexer} [fieldsep]
|
PropList = TablePropOrIndexer {fieldsep TablePropOrIndexer} [fieldsep]
|
||||||
TableType = '{' PropList '}'
|
TableType = '{' PropList '}'
|
||||||
FunctionType = ['<' GenericTypeList '>'] '(' [TypeList] ')' '->' ReturnType
|
FunctionType = ['<' GenericTypeParameterList '>'] '(' [TypeList] ')' '->' ReturnType
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user