Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
45 lines (40 sloc) 1.89 KB
program = {funcDecl | classDecl}
classDecl = "class" ident classBlock
classBlock = "{" {varDecl | funcDecl} "}"
funcDecl = "func" ident paramList returnList block
paramList = "(" {ident ":" varType ","} [ident ":" varType] ")"
returnList = varType | "(" varType {"," varType} ")" // Return void or nothing?
block = "{" {statement} "}"
statement = expr ";"
| varDecl ";"
| varAssignment ";"
| mutliAssignment ";"
| ifStatement
| forStatement
| whileStatement
| jumpStatement ";"
ifStatement = "if" expr block {"else" "if" expr block} ["else" block]
forStatement = "for" ident ":" varType "in" expr block
whileStatement = "while" expr block
jumpStatement = "continue" | "break" | "return" [expr {"," expr}]
varDecl = "var" ident ":" varType {"," ident : varType} "=" expr
varAssignment = expr {"," expr} assignOp expr
varRef = expr {"[" expr "]"} // REMOVE
varType = ident | "[" varType "]" | ident "[" varType {"," varType} "]"
// Tuples? "[" varType {"," varType} "]"
argList = "(" [expr {"," expr}] ")"
expr = logical
logical = equality {("&&" | "||") equality}
equality = cast {("!=" | "==") cast}
cast = comparison {"as" ident}
comparison = addition {(">" | ">=" | "<" | "<=") addition}
addition = multiplication {( "-" | "+" ) multiplication}
multiplication = unary {( "/" | "*" ) unary}
unary = (("!" | "-" | "+") unary) | postfix
postfix = paran {"[" expr "]" | argList | "." ident}
paran = "(" expr ")" | special
special = primary | "new" varType | "typeof" "(" expr ")"
listLiteral = "[" [expr {"," expr}] "]"
primary = ident | int | float | string | "false" | "true" | "nil" | listLiteral
// Consider moving "(" expr ")" into primary from paran.
// Missing... interfaces, switch, contracts, typedef, typeof operator, casting, several literals (byte, hex, rune, char), function pointers, import, module, concurrency
You can’t perform that action at this time.