primary

primary ::= "(" expression ")"
| "[" expression ("," expression)* "]"
| "{" string ":" expression ("," string ":" expression)* "}"
| integer
| real
| string
| function
| identifier
| "super" "." identifier
Language Reference
Below is a formal expression of the ObjectTalk scripting language in Extended Backus–Naur Form (EBNF). You can read more about this notation on Wikipedia. The pretty diagrams were created using the "RailRoad Diagram Generator" which translates EBNF into HTML with pictures. This tool is highly recommended for visualizing grammar.

module ::= statement*

statement ::= expression ";"
| block
| "var" identifier ("=" expression)? ";"
| "class" identifier ":" expression block
| "function" identifier "(" ((identifier ("," identifier)*)?) ")" block
| "if" expression block ("elif" expression block)* ("else" block)?
| "while" expression block
| "do" block "while" expression ";"
| "for" identifier "in" expression block
| "throw" expression ";"
| "try" block "catch" identifier block
| "return" expression ";"

block ::= "{" statement* "}"

expression ::= conditional (
"=" expression |
"*=" expression |
"/=" expression |
"%=" expression |
"+=" expression |
"-=" expression |
"|=" expression |
"^=" expression |
"&=" expression)*

conditional ::= or ("?" expression ":" expression)?

or ::= and ("||" and)*

and ::= bytewise-or ("&&" bytewise-or)*

bytewise-or ::= bytewise-xor ("|" bytewise-xor)*

bytewise-xor ::= bytewise-and ("^" bytewise-and)*

bytewise-and ::= equal ("&" equal)*

equal ::= relation ("==" relation | "!=" relation)*

relation ::= shift (
"<" shift |
"<=" shift |
">" shift |
">=" shift |
"in" shift |
"not in" shift)*

shift ::= addition ("<<" addition | ">>" addition)*

addition ::= multiplication ("+" multiplication | "-" multiplication)*

multiplication ::= prefix ("*" prefix | "/" prefix | "%" prefix)*

prefix ::= ("-" | "!" | "^" | "++" | "--")? postfix

postfix ::= primary ("[" expression "]" | "(" expression ("," expression)* ")" | "." identifier | "++" | "--")*

primary ::= "(" expression ")"
| "[" expression ("," expression)* "]"
| "{" string ":" expression ("," string ":" expression)* "}"
| integer
| real
| string
| function
| identifier
| "super" "." identifier

integer ::= [-+]? ([1-9][0-9]* | "0"[Bb][01]+ | "0"[Oo][0-7]+ | "0"[Xx][0-9A-Fa-f]+ | "0"[0-7]*)

real ::= [-]? [0-9][0-9]*.[0-9][0-9]* ([Ee] [-]? [0-9][0-9]*)?

string ::= '"' ("\u" [0-9A-Fa-f] [0-9A-Fa-f] [0-9A-Fa-f] [0-9A-Fa-f] | '\' ["\bfnrt] | [^\\"])* '"'

function ::= "function" "(" ((identifier ("," identifier)*)?) ")" block

identifier ::= [a-zA-Z_][a-zA-Z0-9_]*