From f0f1e5abfa21e97253bbc9d3e9791c8f4a956d06 Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Wed, 14 Jun 2017 19:15:35 -0300 Subject: grammar.txt: Fix grammar for f.gas(p).value(q)() style calls --- docs/grammar.txt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'docs') diff --git a/docs/grammar.txt b/docs/grammar.txt index b38b7ffa..da9e27d6 100644 --- a/docs/grammar.txt +++ b/docs/grammar.txt @@ -20,9 +20,12 @@ StateVariableDeclaration = TypeName ( 'public' | 'internal' | 'private' )? Ident UsingForDeclaration = 'using' Identifier 'for' ('*' | TypeName) ';' StructDefinition = 'struct' Identifier '{' ( VariableDeclaration ';' (VariableDeclaration ';')* )? '}' + ModifierDefinition = 'modifier' Identifier ParameterList? Block +ModifierInvocation = Identifier ( '(' ExpressionList? ')' )? + FunctionDefinition = 'function' Identifier? ParameterList - ( FunctionCall | Identifier | 'constant' | 'payable' | 'external' | 'public' | 'internal' | 'private' )* + ( ModifierInvocation | 'constant' | 'payable' | 'external' | 'public' | 'internal' | 'private' )* ( 'returns' ParameterList )? ( ';' | Block ) EventDefinition = 'event' Identifier IndexedParameterList 'anonymous'? ';' @@ -72,8 +75,12 @@ VariableDefinition = ('var' IdentifierList | VariableDeclaration) ( '=' Expressi IdentifierList = '(' ( Identifier? ',' )* Identifier? ')' // Precedence by order (see github.com/ethereum/solidity/pull/732) -Expression = - ( Expression ('++' | '--') | FunctionCall | IndexAccess | MemberAccess | '(' Expression ')' ) +Expression + = Expression ('++' | '--') + | FunctionCall + | NewExpression + | MemberAccess + | IndexAccess | ('!' | '~' | 'delete' | '++' | '--' | '+' | '-') Expression | Expression '**' Expression | Expression ('*' | '/' | '%') Expression @@ -101,7 +108,7 @@ PrimaryExpression = Identifier ExpressionList = Expression ( ',' Expression )* NameValueList = Identifier ':' Expression ( ',' Identifier ':' Expression )* -FunctionCall = ( PrimaryExpression | NewExpression | TypeName ) ( ( '.' Identifier ) | ( '[' Expression ']' ) )* '(' FunctionCallArguments ')' +FunctionCall = Expression '(' FunctionCallArguments ')' FunctionCallArguments = '{' NameValueList? '}' | ExpressionList? -- cgit v1.2.3 From 9fc4c877d35f87d6efef6ca9143d196c9cfb9f7f Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Wed, 14 Jun 2017 22:59:58 -0300 Subject: Fix and improve grammar.txt --- docs/grammar.txt | 9 +++++---- docs/miscellaneous.rst | 4 +++- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'docs') diff --git a/docs/grammar.txt b/docs/grammar.txt index da9e27d6..6c041460 100644 --- a/docs/grammar.txt +++ b/docs/grammar.txt @@ -77,10 +77,11 @@ IdentifierList = '(' ( Identifier? ',' )* Identifier? ')' // Precedence by order (see github.com/ethereum/solidity/pull/732) Expression = Expression ('++' | '--') - | FunctionCall | NewExpression - | MemberAccess | IndexAccess + | MemberAccess + | FunctionCall + | '(' Expression ')' | ('!' | '~' | 'delete' | '++' | '--' | '+' | '-') Expression | Expression '**' Expression | Expression ('*' | '/' | '%') Expression @@ -97,12 +98,12 @@ Expression | Expression ('=' | '|=' | '^=' | '&=' | '<<=' | '>>=' | '+=' | '-=' | '*=' | '/=' | '%=') Expression | PrimaryExpression -PrimaryExpression = Identifier - | BooleanLiteral +PrimaryExpression = BooleanLiteral | NumberLiteral | HexLiteral | StringLiteral | TupleExpression + | Identifier | ElementaryTypeNameExpression ExpressionList = Expression ( ',' Expression )* diff --git a/docs/miscellaneous.rst b/docs/miscellaneous.rst index 2e0ccf45..17f2dcf9 100644 --- a/docs/miscellaneous.rst +++ b/docs/miscellaneous.rst @@ -394,12 +394,14 @@ The following is the order of precedence for operators, listed in order of evalu +============+=====================================+============================================+ | *1* | Postfix increment and decrement | ``++``, ``--`` | + +-------------------------------------+--------------------------------------------+ -| | Function-like call | ``()`` | +| | New expression | ``new `` | + +-------------------------------------+--------------------------------------------+ | | Array subscripting | ``[]`` | + +-------------------------------------+--------------------------------------------+ | | Member access | ``.`` | + +-------------------------------------+--------------------------------------------+ +| | Function-like call | ``()`` | ++ +-------------------------------------+--------------------------------------------+ | | Parentheses | ``()`` | +------------+-------------------------------------+--------------------------------------------+ | *2* | Prefix increment and decrement | ``++``, ``--`` | -- cgit v1.2.3