Syntax Cheat Sheet
This document describes the syntax of mobl in a BNF-like notation.
Top-level
Start ::= "application" QId Def*
| "module" QId Def*
| "configuration" Config*
QId ::= ID
| QId "::" ID
Configuration
Config ::= "title" STRING
| "database" STRING
| "icon" Path
| "version" STRING
| "stdlib" Path
| "lib" Path
| "html" FILENAME
| "output" STRING
| "release" "output" STRING
| "offline"
| "debug"
Path := {FILENAME "/"}+
| "/" {FILENAME "/"}+
| STRING
Scripting
Functions
Def ::= "function" ID "(" {FArg ","}* ")" (":" Type)?
"{" Stat* "}"
FArg ::= ID ":" Type ("=" Exp)?
Type ::= QId
| QId "<" {QId ","}+ ">"
Statements
Stat ::= "var" ID ":" Type "=" Exp ";"
| "var" ID "=" Exp ";"
| LVal "=" Exp ";"
| Exp ";"
| "if" "(" Exp ")" Stat ("else" Stat)?
| "foreach" "(" LVal ":" Type "in" Exp ")"
"{" Stat* "}"
| "foreach" "(" LVal "in" Exp ")" "{" Stat* "}"
| "while" "(" Exp ")" "{" Stat* "}"
| "{" Stat* "}"
| "return" Exp? ";"
| "screen" "return" Exp? ";"
| "return" ";"
| "async" "{" Stat* "}"
LVal ::= QId
| Exp "." ID
| "(" LVal "," {LVal ","}* ")"
Expressions
Exp ::= STRING
| NUMBER
| "true"
| "false"
| "null"
| "this"
| "event"
| QId "(" {NamedExp ","}* ")"
| "async" "(" Exp ("," Exp)? ")"
| "!" Exp
| QId
| "(" Exp ")"
| Exp "." ID "(" {NamedExp ","}* ")"
| Exp "." ID
| Exp "[" Exp "]"
| Exp Op Exp
| Exp "?" Exp ":" Exp
| QId "<" {Type ","}* ">" "(" {Exp ","}* ")"
| "[" {Exp ","}* "]"
| "(" Exp "," {Exp ","}* ")"
| "async" "(" {Exp ","}* ")"
| "{" Stat* "}"
| "function" "(" {FArg ","}* ")"
(":" Type")? "{" Stat* "}"
| "control" "(" {FArg ","}* ")"
"{" ScreenElem* "}"
| "$data" "(" Path ")"
| Exp Filter+
QId ::= ID | QId "::" ID
Op ::= "||" | "&&" | "==" | "!=" | "<" | "<=" | ">"
| ">=" | "*" | "/" | "<<" | ">>" | "&" | "|"
| "%" | "+" | "-" | "++" | "--"
NamedExp ::= Exp
| ID "=" Exp
Filter ::= "where" SetExp
| "order" "by" OrderExp
| "prefetch" {ID ","}+
| "limit" Exp
| "offset" Exp
OrderExp ::= ID
| ID "asc"
| ID "desc"
SetExp ::= ID "==" Exp
| ID "!=" Exp
| ID "<" Exp
| ID "<=" Exp
| ID ">" Exp
| ID ">=" Exp
| ID "in" Exp
| ID "not" "in" Exp
| SetExp "&&" SetExp
UI
Def ::= "control" ID "(" {FArg ","}* ")"
"{" ScreenElem* "}"
| "screen" ID "(" {FArg ","}* ")" ":" Type
"{" ScreenElem* "}"
ScreenElem ::= "<" HTMLID HtmlArg* ">"
ScreenElem*
"</" HTMLID ">"
| Exp "(" {NamedExp ","}* ")"
"{" ScreenElem* "}"
| "var" ID (":" Type")? "=" Exp
| "var" ID (":" Type")? "<-" Exp
| "list" "(" LVal (":" Type)? "in" Exp ")"
"{" ScreenElem* "}"
| "when" "(" Exp ")"
"{" ScreenElem* "}"
("else" "{" ScreenElem* "}")?
| "elements" "(" ")"
| "script" "{" Stat* "}"
HtmlArg ::= ID "=" Exp
| "databind" "=" Exp
NamedExp ::= Exp
| ID "=" Exp
Styling
Def ::= "style" StyleSelector+ "{" StyleElem* "}"
| "style" "$" ID "=" StyleExp
| "style" "mixin" "$" ID "(" {StyleFArg ","}* ")"
"{" StyleElem* "}"
StyleFArg ::= "$" ID
StyleSelector ::= QId
| QId ":" STYLEPROPID
| QId ":" STYLEPROPID "(" STYLEPROPID ")"
StyleElem ::= STYLEPROPID ":" StyleExp ";"
| "$" QId "(" {StyleExp ","}* ")" ";"
StyleExp ::= ANY_VALID_CSS_EXP
| "$" ID
| StyleExp "+" StyleExp
| StyleExp "~" StyleExp
| StyleExp "*" StyleExp
| "$" ID "." ID
| "$data" "(" Path ")"
Data Model
Def ::= "entity" ID "{" EBD* "}"
| "type" ID "{" EBD* "}"
EBD ::= ID ":" Type ("(" {Anno ","}* ")")?
| "static" "function" ID "(" {FArg ","}* ")"
(":" Type")? "{" Stat* "}"
| "function" ID "(" {FArg ","}* ")"
(":" Type")? "{" Stat* "}"
Anno ::= "inverse:" ID
| "searchable"
Services
Def ::= "service" ID "{" ServiceElem* "}"
ServiceElem ::= "root" "=" STRING
| "resource" ID "(" {FArg ","}* ")" ":" Type
"{" RPropVal "}"
RPropVal ::= "method" "=" STRING
| "data" "=" Exp
| "encoding" "=" STRING
| "mapper" "=" QId
Misc
Def ::= "load" Path
| "load" STRING
| "resource" Path
language/cheatsheet.txt · Last modified: 2020/06/27 09:00 by Zef Hemel