mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
43 lines
2.2 KiB
Plaintext
43 lines
2.2 KiB
Plaintext
ContractDefinition = 'contract' Identifier
|
|
( 'is' InheritanceSpecifier (',' InheritanceSpecifier )* )?
|
|
'{' ContractPart* '}'
|
|
ContractPart = VariableDeclaration ';' | StructDefinition | ModifierDefinition |
|
|
FunctionDefinition | 'public:' | 'private:'
|
|
|
|
InheritanceSpecifier = Identifier ( '(' Expression ( ',' Expression )* ')' )?
|
|
StructDefinition = 'struct' Identifier '{'
|
|
( VariableDeclaration (';' VariableDeclaration)* )? '}
|
|
ModifierDefinition = 'modifier' Identifier ParameterList? Block
|
|
FunctionDefinition = 'function' Identifier ParameterList ( Identifier | 'constant' )*
|
|
( 'returns' ParameterList )? Block
|
|
ParameterList = '(' ( VariableDeclaration (',' VariableDeclaration)* )? ')'
|
|
// semantic restriction: mappings and structs (recursively) containing mappings
|
|
// are not allowed in argument lists
|
|
VariableDeclaration = TypeName Identifier
|
|
TypeName = ElementaryTypeName | Identifier | Mapping
|
|
Mapping = 'mapping' '(' ElementaryTypeName '=>' TypeName ')'
|
|
|
|
Block = '{' Statement* '}'
|
|
Statement = IfStatement | WhileStatement | Block |
|
|
( Continue | Break | Return | VariableDefinition | ExpressionStatement ) ';'
|
|
|
|
ExpressionStatement = Expression
|
|
IfStatement = 'if' '(' Expression ')' Statement ( 'else' Statement )?
|
|
WhileStatement = 'while' '(' Expression ')' Statement
|
|
VardefOrExprStmt = Variabledefinition | ExpressionStatement
|
|
ForStatement = 'for' '(' (VardefOrExprStmt)? ';' (Expression)? ';' (ExpressionStatement)? ')' Statement
|
|
Continue = 'continue' ';'
|
|
Break = 'break' ';'
|
|
Return = 'return' Expression? ';'
|
|
VariableDefinition = VariableDeclaration ( = Expression )? ';'
|
|
|
|
Expression = Assignment | UnaryOperation | BinaryOperation | FunctionCall | NewExpression | IndexAccess |
|
|
MemberAccess | PrimaryExpression
|
|
// The expression syntax is actually much more complicated
|
|
Assignment = Expression (AssignmentOp Expression)
|
|
FunctionCall = Expression '(' Expression ( ',' Expression )* ')'
|
|
NewExpression = 'new' Identifier
|
|
MemberAccess = Expression '.' Identifier
|
|
IndexAccess = Expression '[' Expresison ']'
|
|
PrimaryExpression = Identifier | NumberLiteral | StringLiteral | ElementaryTypeName | '(' Expression ')'
|