mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
TypeAnnotation
-> Type
This commit is contained in:
parent
b1e83ba138
commit
88b726fa7d
1 changed files with 16 additions and 16 deletions
|
@ -22,7 +22,7 @@ stat ::= varlist `=' explist |
|
||||||
function funcname funcbody |
|
function funcname funcbody |
|
||||||
local function NAME funcbody |
|
local function NAME funcbody |
|
||||||
local bindinglist [`=' explist] |
|
local bindinglist [`=' explist] |
|
||||||
[export] type NAME [`<' GenericTypeList `>'] `=' TypeAnnotation
|
[export] type NAME [`<' GenericTypeList `>'] `=' Type
|
||||||
|
|
||||||
laststat ::= return [explist] | break | continue
|
laststat ::= return [explist] | break | continue
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ exp ::= (asexp | 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
|
||||||
prefixexp ::= NAME | '(' exp ')'
|
prefixexp ::= NAME | '(' exp ')'
|
||||||
primaryexp ::= prefixexp { `.' NAME | `[' exp `]' | `:' NAME funcargs | funcargs }
|
primaryexp ::= prefixexp { `.' NAME | `[' exp `]' | `:' NAME funcargs | funcargs }
|
||||||
asexp ::= simpleexp [`::' TypeAnnotation]
|
asexp ::= simpleexp [`::' Type]
|
||||||
simpleexp ::= NUMBER | STRING | nil | true | false | `...' | tableconstructor | function body | primaryexp | ifelseexp
|
simpleexp ::= NUMBER | STRING | nil | true | false | `...' | tableconstructor | function body | primaryexp | ifelseexp
|
||||||
funcargs ::= `(' [explist] `)' | tableconstructor | STRING
|
funcargs ::= `(' [explist] `)' | tableconstructor | STRING
|
||||||
|
|
||||||
|
@ -53,25 +53,25 @@ compoundop :: `+=' | `-=' | `*=' | `/=' | `%=' | `^=' | `..='
|
||||||
binop ::= `+' | `-' | `*' | `/' | `^' | `%' | `..' | `<' | `<=' | `>' | `>=' | `==' | `~=' | and | or
|
binop ::= `+' | `-' | `*' | `/' | `^' | `%' | `..' | `<' | `<=' | `>' | `>=' | `==' | `~=' | and | or
|
||||||
unop ::= `-' | not | `#'
|
unop ::= `-' | not | `#'
|
||||||
|
|
||||||
SimpleTypeAnnotation ::=
|
SimpleType ::=
|
||||||
nil |
|
nil |
|
||||||
NAME[`.' NAME] [ `<' TypeAnnotation [`,' ...] `>' ] |
|
NAME[`.' NAME] [ `<' Type {`,' Type} `>' ] |
|
||||||
`typeof' `(' exp `)' |
|
`typeof' `(' exp `)' |
|
||||||
`{' [PropList] `}' |
|
TableType |
|
||||||
FunctionTypeAnnotation
|
FunctionType
|
||||||
|
|
||||||
TypeAnnotation ::=
|
Type ::=
|
||||||
SimpleTypeAnnotation [`?`] |
|
SimpleType [`?`] |
|
||||||
SimpleTypeAnnotation [`|` TypeAnnotation] |
|
SimpleType [`|` Type] |
|
||||||
SimpleTypeAnnotation [`&` TypeAnnotation]
|
SimpleType [`&` Type]
|
||||||
|
|
||||||
GenericTypeList ::= NAME [`...'] {`,' NAME}
|
GenericTypeList ::= NAME [`...'] {`,' NAME}
|
||||||
TypeList ::= TypeAnnotation [`,' TypeList] | ...TypeAnnotation
|
TypeList ::= Type [`,' TypeList] | ...Type
|
||||||
ReturnType ::= TypeAnnotation | `(' TypeList `)'
|
ReturnType ::= Type | `(' TypeList `)'
|
||||||
TableIndexer ::= `[' TypeAnnotation `]' `:' TypeAnnotation
|
TableIndexer ::= `[' Type `]' `:' Type
|
||||||
TableProp ::= NAME `:' TypeAnnotation
|
TableProp ::= NAME `:' Type
|
||||||
TablePropOrIndexer ::= TableProp | TableIndexer
|
TablePropOrIndexer ::= TableProp | TableIndexer
|
||||||
PropList ::= TablePropOrIndexer {fieldsep TablePropOrIndexer} [fieldsep]
|
PropList ::= TablePropOrIndexer {fieldsep TablePropOrIndexer} [fieldsep]
|
||||||
TableTypeAnnotation ::= `{' PropList `}'
|
TableType ::= `{' PropList `}'
|
||||||
FunctionTypeAnnotation ::= [`<' GenericTypeList `>'] `(' [TypeList] `)' `->` ReturnType
|
FunctionType ::= [`<' GenericTypeList `>'] `(' [TypeList] `)' `->` ReturnType
|
||||||
```
|
```
|
||||||
|
|
Loading…
Add table
Reference in a new issue