2014-10-07 16:25:04 +00:00
|
|
|
ContractDefinition = 'contract' Identifier '{' ContractPart* '}'
|
2014-10-08 18:53:50 +00:00
|
|
|
ContractPart = VariableDeclaration ';' | StructDefinition |
|
|
|
|
FunctionDefinition | 'public:' | 'private:'
|
2014-10-07 16:25:04 +00:00
|
|
|
|
|
|
|
StructDefinition = 'struct' Identifier '{'
|
|
|
|
( VariableDeclaration (';' VariableDeclaration)* )? '}
|
|
|
|
|
2014-10-08 18:53:50 +00:00
|
|
|
FunctionDefinition = 'function' Identifier ParameterList 'const'?
|
|
|
|
( 'returns' ParameterList )? Block
|
|
|
|
ParameterList = '(' ( VariableDeclaration (',' VariableDeclaration)* )? ')'
|
2014-10-07 16:25:04 +00:00
|
|
|
// semantic restriction: mappings and structs (recursively) containing mappings
|
|
|
|
// are not allowed in argument lists
|
|
|
|
VariableDeclaration = TypeName Identifier
|
2014-10-08 18:53:50 +00:00
|
|
|
TypeName = ElementaryTypeName | Identifier | Mapping
|
|
|
|
Mapping = 'mapping' '(' ElementaryTypeName '=>' TypeName ')'
|
2014-10-07 16:25:04 +00:00
|
|
|
|
|
|
|
Block = '{' Statement* '}'
|
|
|
|
Statement = IfStatement | WhileStatement | Continue | Break | Return | VariableAssignment | Expression ';' | Block
|
|
|
|
|
|
|
|
IfStatement = 'if' '(' Expression ')' Statement ( 'else' Statement )?
|
|
|
|
WhileStatement = 'while' '(' Expression ')' Statement
|
|
|
|
Continue = 'continue' ';'
|
|
|
|
Break = 'break' ';'
|
|
|
|
Return = 'return' Expression? ';'
|
|
|
|
VariableAssignment = VariableDeclaration ( AssignmentOp Expression )? ';'
|
|
|
|
|
|
|
|
Expression = Assignment | UnaryOperation | BinaryOperation | FunctionCall | IndexAccess | MemberAccess | PrimaryExpression
|
|
|
|
Assignment = Expression (AssignmentOp Expression)
|
|
|
|
FunctionCall = Identifier '(' ( Expression ( ',' Expression )* ) ')'
|
|
|
|
MemberAccess = Expression '.' Identifier
|
|
|
|
IndexAccess = Expression '[' Expresison ']'
|
|
|
|
PrimaryExpression = Identifier | NumberLiteral | StringLiteral | '(' Expression ')'
|