diff options
author | Christian <c@ethdev.com> | 2014-10-08 00:25:04 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2014-10-08 19:49:34 +0800 |
commit | 56e9cc8db71f8af949123e13e6a97cc056cf766d (patch) | |
tree | 6fc043aaa6b9562ab0d1de8f2aa51e6d99c8ab6b /grammar.txt | |
parent | ef59373871528ac72c447e5f014aa18a1f3776e5 (diff) | |
download | dexon-solidity-56e9cc8db71f8af949123e13e6a97cc056cf766d.tar dexon-solidity-56e9cc8db71f8af949123e13e6a97cc056cf766d.tar.gz dexon-solidity-56e9cc8db71f8af949123e13e6a97cc056cf766d.tar.bz2 dexon-solidity-56e9cc8db71f8af949123e13e6a97cc056cf766d.tar.lz dexon-solidity-56e9cc8db71f8af949123e13e6a97cc056cf766d.tar.xz dexon-solidity-56e9cc8db71f8af949123e13e6a97cc056cf766d.tar.zst dexon-solidity-56e9cc8db71f8af949123e13e6a97cc056cf766d.zip |
Solidity parser, can not parse much yet.
Diffstat (limited to 'grammar.txt')
-rw-r--r-- | grammar.txt | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/grammar.txt b/grammar.txt new file mode 100644 index 00000000..aec02489 --- /dev/null +++ b/grammar.txt @@ -0,0 +1,32 @@ +ContractDefinition = 'contract' Identifier '{' ContractPart* '}' +ContractPart = VariableDeclaration ';' | StructDefinition ';' | + FunctionDefinition ';' | 'public:' | 'private:' + +StructDefinition = 'struct' Identifier '{' + ( VariableDeclaration (';' VariableDeclaration)* )? '} + +FunctionDefinition = 'function' Identifier ArgumentList 'const'? + 'returns' ArgumentList Block +ArgumentList = '(' ( VariableDeclaration (',' VariableDeclaration)* )? ')' +// semantic restriction: mappings and structs (recursively) containing mappings +// are not allowed in argument lists +VariableDeclaration = TypeName Identifier +TypeName = PredefinedType | Identifier | MappingType +MappingType = 'mapping' '(' SimplePredefinedType '=>' TypeName ')' + +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 ')' |