-
Notifications
You must be signed in to change notification settings - Fork 2
Macrosyntax
juansc edited this page Jan 31, 2015
·
10 revisions
newLine = '\r?\n'
Program = Block
Block = (Stmt + newLine)*
Stmt = 'while' Exp ':' (newLine Block 'end' | Exp newLine)
| 'for' id 'in' Exp ':' (newLine Block 'end' | Exp newLine)
| Exp
Exp = id|TupLit ':' (Type)? '=' Exp
| id|TupLit '=' Exp
| ConditionalExp
| Class
| Function
ConditionalExp = Exp 'if' Exp ('else' Exp)?
| 'if' Exp ':' newLine Block ('else if' Exp ':' newLine Block)* ('else:' newLine Block 'end')?
| 'if' Exp ':' Exp
| Exp0
Exp0 = Exp1 ('or' Exp1)*
Exp1 = Exp2 ('and' Exp2)*
Exp2 = Exp3 (relop Exp3)?
Exp3 = Exp4 (addop Exp4)*
Exp4 = Exp5 (mulop Exp5)*
Exp5 = prefixop? Exp6
Exp6 = boolLit | intLit | id | '(' Exp ')' | StringLit | TupLit | SetLit | MapLit | ListLit
Index = Exp '[' Exp ']'
Prop = Exp '.' id
range = Exp '..' Exp ('by' Exp)?
slice = Exp '[' range ']'
comprehension = '[' Exp ('if' Exp ('else' Exp)?)? 'for' id 'in' Exp ']'
PropertySignature = id (ArgsDeclaration)?
trait = 'trait:' Newline (PropertySignature Newline)* 'end'
ArgsDeclaration = '(' Arg? | ( Arg ( ',' Arg )*) ')'
Class = 'class:' Newline (Exp Newline)* 'end'
Arg = id ( ':' type)? ( '=' Exp )?
FunctionBlock = Exp | Newline Block 'end'
Function = ArgsDeclaration '->' FunctionBlock