diff options
author | Lefteris Karapetsas <lefteris@refu.co> | 2015-08-19 20:57:25 +0800 |
---|---|---|
committer | Lefteris Karapetsas <lefteris@refu.co> | 2015-08-19 20:57:25 +0800 |
commit | 1690f1c947b1b1bfaf84d0a586d2a56ffed11f37 (patch) | |
tree | cbf27ebb57b629ae7a4a10cc1342a359481de7d3 /libsolidity/grammar.txt | |
parent | 2f41438715137e7f123481b2ca8e163a4d35bd78 (diff) | |
download | dexon-solidity-1690f1c947b1b1bfaf84d0a586d2a56ffed11f37.tar.gz dexon-solidity-1690f1c947b1b1bfaf84d0a586d2a56ffed11f37.tar.zst dexon-solidity-1690f1c947b1b1bfaf84d0a586d2a56ffed11f37.zip |
Add CMakeLists.txt for libsolidity
Diffstat (limited to 'libsolidity/grammar.txt')
-rw-r--r-- | libsolidity/grammar.txt | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/libsolidity/grammar.txt b/libsolidity/grammar.txt new file mode 100644 index 00000000..6503516c --- /dev/null +++ b/libsolidity/grammar.txt @@ -0,0 +1,47 @@ +ContractDefinition = 'contract' Identifier + ( 'is' InheritanceSpecifier (',' InheritanceSpecifier )* )? + '{' ContractPart* '}' +ContractPart = StateVariableDeclaration | StructDefinition | ModifierDefinition | FunctionDefinition | EnumDefinition + +InheritanceSpecifier = Identifier ( '(' Expression ( ',' Expression )* ')' )? +StructDefinition = 'struct' Identifier '{' + ( VariableDeclaration (';' VariableDeclaration)* )? '} +StateVariableDeclaration = TypeName ( 'public' | 'inheritable' | 'private' )? Identifier ';' +ModifierDefinition = 'modifier' Identifier ParameterList? Block +FunctionDefinition = 'function' Identifier ParameterList + ( Identifier | 'constant' | 'external' | 'public' | 'inheritable' | 'private' )* + ( 'returns' ParameterList )? Block + +EnumValue = Identifier +EnumDefinition = 'enum' '{' EnumValue (',' EnumValue)* '}' +ParameterList = '(' ( VariableDeclaration (',' VariableDeclaration)* )? ')' +// semantic restriction: mappings and structs (recursively) containing mappings +// are not allowed in argument lists +VariableDeclaration = TypeName Identifier +TypeName = ElementaryTypeName | Identifier | Mapping | ArrayTypeName +Mapping = 'mapping' '(' ElementaryTypeName '=>' TypeName ')' +ArrayTypeName = TypeName '[' (Expression)? ']' + +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 ')' |