2015-01-19 20:05:47 +00:00
|
|
|
ContractDefinition = 'contract' Identifier
|
|
|
|
( 'is' InheritanceSpecifier (',' InheritanceSpecifier )* )?
|
|
|
|
'{' ContractPart* '}'
|
2015-02-13 21:56:46 +00:00
|
|
|
ContractPart = StateVariableDeclaration | StructDefinition | ModifierDefinition | FunctionDefinition | EnumDefinition
|
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-02-18 12:35:12 +00:00
|
|
|
StateVariableDeclaration = TypeName ( 'public' | 'inheritable' | 'private' )? Identifier ';'
|
2015-01-22 00:02:38 +00:00
|
|
|
ModifierDefinition = 'modifier' Identifier ParameterList? Block
|
2015-02-02 16:24:09 +00:00
|
|
|
FunctionDefinition = 'function' Identifier ParameterList
|
2015-02-18 12:35:12 +00:00
|
|
|
( Identifier | 'constant' | 'external' | 'public' | 'inheritable' | 'private' )*
|
2014-10-08 18:53:50 +00:00
|
|
|
( 'returns' ParameterList )? Block
|
2015-02-13 21:56:46 +00:00
|
|
|
|
|
|
|
EnumValue = Identifier
|
2015-02-13 22:47:55 +00:00
|
|
|
EnumDefinition = 'enum' '{' EnumValue (',' EnumValue)* '}'
|
2014-10-08 18:53:50 +00:00
|
|
|
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
|
2015-02-21 17:25:08 +00:00
|
|
|
TypeName = ElementaryTypeName | Identifier | Mapping | ArrayTypeName
|
2014-10-08 18:53:50 +00:00
|
|
|
Mapping = 'mapping' '(' ElementaryTypeName '=>' TypeName ')'
|
2015-02-21 17:25:08 +00:00
|
|
|
ArrayTypeName = TypeName '[' (Expression)? ']'
|
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
|
2015-02-21 17:25:08 +00:00
|
|
|
IndexAccess = Expression '[' (Expresison)? ']'
|
2014-10-09 13:57:49 +00:00
|
|
|
PrimaryExpression = Identifier | NumberLiteral | StringLiteral | ElementaryTypeName | '(' Expression ')'
|