mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
List out all definition comments from Parser.cpp
This commit is contained in:
parent
d2bf2870e8
commit
7c100ca949
1 changed files with 60 additions and 0 deletions
60
docs/_pages/grammar.md
Normal file
60
docs/_pages/grammar.md
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
---
|
||||||
|
permalink: /grammar
|
||||||
|
title: Grammar
|
||||||
|
toc: true
|
||||||
|
---
|
||||||
|
|
||||||
|
```
|
||||||
|
chunk ::= {stat [`;']} [laststat [`;']]
|
||||||
|
block ::= chunk
|
||||||
|
stat ::= varlist `=' explist |
|
||||||
|
functioncall |
|
||||||
|
do block end |
|
||||||
|
while exp do block end |
|
||||||
|
repeat block until exp |
|
||||||
|
if exp then block {elseif exp then block} [else block] end |
|
||||||
|
for binding `=' exp `,' exp [`,' exp] do block end |
|
||||||
|
for namelist in explist do block end |
|
||||||
|
function funcname funcbody |
|
||||||
|
local function Name funcbody |
|
||||||
|
local namelist [`=' explist]
|
||||||
|
|
||||||
|
laststat ::= return [explist] | break
|
||||||
|
|
||||||
|
funcname ::= Name {`.' Name} [`:' Name]
|
||||||
|
funcbody ::= `(' [parlist] `)' [`:' ReturnType] block end
|
||||||
|
parlist ::= bindinglist [`,' `...'] | `...'
|
||||||
|
explist ::= {exp `,'} exp
|
||||||
|
bindinglist ::= (binding | `...') [`,' bindinglist]
|
||||||
|
|
||||||
|
subexpr ::= (asexp | unop subexpr) { binop subexpr }
|
||||||
|
prefixexp ::= NAME | '(' expr ')'
|
||||||
|
primaryexp ::= prefixexp { `.' NAME | `[' exp `]' | `:' NAME funcargs | funcargs }
|
||||||
|
asexp ::= simpleexp [`::' typeannotation]
|
||||||
|
simpleexp ::= NUMBER | STRING | NIL | true | false | ... | constructor | FUNCTION body | primaryexp
|
||||||
|
args ::= `(' [explist] `)' | tableconstructor | String
|
||||||
|
|
||||||
|
tableconstructor ::= `{' [fieldlist] `}'
|
||||||
|
fieldlist ::= field {fieldsep field} [fieldsep]
|
||||||
|
field ::= `[' exp `]' `=' exp | Name `=' exp | exp
|
||||||
|
fieldsep ::= `,' | `;'
|
||||||
|
|
||||||
|
typeannotation ::=
|
||||||
|
nil |
|
||||||
|
Name[`.' Name] [`<' namelist `>'] |
|
||||||
|
`{' [PropList] `}' |
|
||||||
|
`(' [TypeList] `)' `->` ReturnType
|
||||||
|
`typeof` typeannotation
|
||||||
|
|
||||||
|
typeannotation ::= nil | Name[`.' Name] [ `<' typeannotation [`,' ...] `>' ] | `typeof' `(' expr `)' | `{' [PropList] `}' | [`<' varlist `>'] `(' [TypeList] `)' `->` ReturnType
|
||||||
|
|
||||||
|
TypeList ::= TypeAnnotation [`,' TypeList] | ...TypeAnnotation
|
||||||
|
ReturnType ::= TypeAnnotation | `(' TypeList `)'
|
||||||
|
TableIndexer ::= `[' TypeAnnotation `]' `:' TypeAnnotation
|
||||||
|
TableProp ::= Name `:' TypeAnnotation
|
||||||
|
TablePropOrIndexer ::= TableProp | TableIndexer
|
||||||
|
PropList ::= TablePropOrIndexer {fieldsep TablePropOrIndexer} [fieldsep]
|
||||||
|
TableTypeAnnotation ::= `{' PropList `}'
|
||||||
|
FunctionTypeAnnotation ::= [`<' varlist `>'] `(' [TypeList] `)' `->` ReturnType
|
||||||
|
|
||||||
|
```
|
Loading…
Add table
Reference in a new issue