-
Notifications
You must be signed in to change notification settings - Fork 16
PICO 8 language
Sam Hocevar edited this page Jun 7, 2020
·
1 revision
PICO-8 uses Lua 5.2, however through various feature extensions its syntax has become closer to Lua 5.3, so the following syntax is adapted from the official Lua 5.3 manual, is as follows:
chunk ::= block
block ::= {stat} [retstat]
stat ::= β;β |
varlist β=β explist |
var compop exp |
functioncall |
β?β [explist] |
label |
βbreakβ |
βgotoβ Name |
βdoβ block βendβ |
βwhileβ exp βdoβ block βendβ |
βwhileβ β(β exp β)β block |
βrepeatβ block βuntilβ exp |
βifβ exp βthenβ block {βelseifβ exp βthenβ block} [βelseβ block] βendβ |
βifβ β(β exp β)β block [βelseβ block] |
βforβ Name β=β exp β,β exp [β,β exp] βdoβ block βendβ |
βforβ namelist βinβ explist βdoβ block βendβ |
βfunctionβ funcname funcbody |
βlocalβ βfunctionβ Name funcbody |
βlocalβ namelist [β=β explist]
retstat ::= βreturnβ [explist] [β;β]
label ::= β::β Name β::β
funcname ::= Name {β.β Name} [β:β Name]
varlist ::= var {β,β var}
var ::= Name | prefixexp β[β exp β]β | prefixexp β.β Name
namelist ::= Name {β,β Name}
explist ::= exp {β,β exp}
exp ::= βnilβ | βfalseβ | βtrueβ | Numeral | LiteralString | β...β | functiondef |
prefixexp | tableconstructor | exp binop exp | unop exp
prefixexp ::= var | functioncall | β(β exp β)β
functioncall ::= prefixexp args | prefixexp β:β Name args
args ::= β(β [explist] β)β | tableconstructor | LiteralString
functiondef ::= βfunctionβ funcbody
funcbody ::= β(β [parlist] β)β block βendβ
parlist ::= namelist [β,β β...β] | β...β
tableconstructor ::= β{β [fieldlist] β}β
fieldlist ::= field {fieldsep field} [fieldsep]
field ::= β[β exp β]β β=β exp | Name β=β exp | exp
fieldsep ::= β,β | β;β
binop ::= β+β | β-β | β*β | β/β | β^β | β%β | β\β | β^^β |
β&β | β|β | β>>β | β>>>β | β<<β | β>><β | β<<>β | β..β |
β<β | β<=β | β>β | β>=β | β==β | β~=β | βandβ | βorβ
compop ::= β+=β | β-=β | β*=β | β/=β | β^=β | β%=β | β\=β | β^^=β |
β&=β | β|=β | β>>=β | β>>>=β | β<<=β | β>><=β | β<<>=β | β..=β |
unop ::= β-β | βnotβ | β#β | β~β | β@β | β%β | β$β