2015-01-19 20:05:47 +00:00
|
|
|
ContractDefinition = 'contract' Identifier
|
|
|
|
( 'is' InheritanceSpecifier (',' InheritanceSpecifier )* )?
|
|
|
|
'{' ContractPart* '}'
|
2015-01-22 00:02:38 +00:00
|
|
|
ContractPart = VariableDeclaration ';' | StructDefinition | ModifierDefinition |
|
2014-10-08 18:53:50 +00:00
|
|
|
FunctionDefinition | 'public:' | 'private:'
|
2014-10-07 16:25:04 +00:00
|
|
|
|
2015-01-19 20:05:47 +00:00
|
|
|
InheritanceSpecifier = Identifier ( '(' Expression ( ',' Expression )* ')' )?
|
2014-10-07 16:25:04 +00:00
|
|
|
StructDefinition = 'struct' Identifier '{'
|
|
|
|
( VariableDeclaration (';' VariableDeclaration)* )? '}
|
2015-01-22 00:02:38 +00:00
|
|
|
ModifierDefinition = 'modifier' Identifier ParameterList? Block
|
|
|
|
FunctionDefinition = 'function' Identifier ParameterList ( Identifier | 'constant' )*
|
2014-10-08 18:53:50 +00:00
|
|
|
( '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* '}'
|
2014-10-09 13:57:49 +00:00
|
|
|
Statement = IfStatement | WhileStatement | Block |
|
2014-12-16 13:46:17 +00:00
|
|
|
( Continue | Break | Return | VariableDefinition | ExpressionStatement ) ';'
|
2014-10-07 16:25:04 +00:00
|
|
|
|
2014-12-16 13:46:17 +00:00
|
|
|
ExpressionStatement = Expression
|
2014-10-07 16:25:04 +00:00
|
|
|
IfStatement = 'if' '(' Expression ')' Statement ( 'else' Statement )?
|
|
|
|
WhileStatement = 'while' '(' Expression ')' Statement
|
2014-12-16 13:46:17 +00:00
|
|
|
VardefOrExprStmt = Variabledefinition | ExpressionStatement
|
|
|
|
ForStatement = 'for' '(' (VardefOrExprStmt)? ';' (Expression)? ';' (ExpressionStatement)? ')' Statement
|
2014-10-07 16:25:04 +00:00
|
|
|
Continue = 'continue' ';'
|
|
|
|
Break = 'break' ';'
|
|
|
|
Return = 'return' Expression? ';'
|
2014-10-09 13:57:49 +00:00
|
|
|
VariableDefinition = VariableDeclaration ( = Expression )? ';'
|
2014-10-07 16:25:04 +00:00
|
|
|
|
2014-12-12 15:49:26 +00:00
|
|
|
Expression = Assignment | UnaryOperation | BinaryOperation | FunctionCall | NewExpression | IndexAccess |
|
2014-10-09 13:57:49 +00:00
|
|
|
MemberAccess | PrimaryExpression
|
|
|
|
// The expression syntax is actually much more complicated
|
2014-10-07 16:25:04 +00:00
|
|
|
Assignment = Expression (AssignmentOp Expression)
|
2014-12-16 15:15:34 +00:00
|
|
|
FunctionCall = Expression '(' Expression ( ',' Expression )* ')'
|
2015-01-13 17:12:19 +00:00
|
|
|
NewExpression = 'new' Identifier
|
2014-10-07 16:25:04 +00:00
|
|
|
MemberAccess = Expression '.' Identifier
|
|
|
|
IndexAccess = Expression '[' Expresison ']'
|
2014-10-09 13:57:49 +00:00
|
|
|
PrimaryExpression = Identifier | NumberLiteral | StringLiteral | ElementaryTypeName | '(' Expression ')'
|