From 86b7adc18f14049c7ea4aed9eaaa9b0368d8ec9e Mon Sep 17 00:00:00 2001 From: chriseth Date: Sat, 28 Apr 2018 00:17:35 +0200 Subject: Refactor expression parser. --- libsolidity/parsing/Parser.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'libsolidity/parsing/Parser.h') diff --git a/libsolidity/parsing/Parser.h b/libsolidity/parsing/Parser.h index 7f02d895..7a1a390e 100644 --- a/libsolidity/parsing/Parser.h +++ b/libsolidity/parsing/Parser.h @@ -118,19 +118,19 @@ private: ); ASTPointer parseExpressionStatement( ASTPointer const& _docString, - ASTPointer const& _lookAheadIndexAccessStructure = ASTPointer() + ASTPointer const& _partiallyParsedExpression = ASTPointer() ); ASTPointer parseExpression( - ASTPointer const& _lookAheadIndexAccessStructure = ASTPointer() + ASTPointer const& _partiallyParsedExpression = ASTPointer() ); ASTPointer parseBinaryExpression(int _minPrecedence = 4, - ASTPointer const& _lookAheadIndexAccessStructure = ASTPointer() + ASTPointer const& _partiallyParsedExpression = ASTPointer() ); ASTPointer parseUnaryExpression( - ASTPointer const& _lookAheadIndexAccessStructure = ASTPointer() + ASTPointer const& _partiallyParsedExpression = ASTPointer() ); ASTPointer parseLeftHandSideExpression( - ASTPointer const& _lookAheadIndexAccessStructure = ASTPointer() + ASTPointer const& _partiallyParsedExpression = ASTPointer() ); ASTPointer parsePrimaryExpression(); std::vector> parseFunctionCallListArguments(); -- cgit v1.2.3 From be54f4819713ce5737a271bbdc43ac0a73a8e456 Mon Sep 17 00:00:00 2001 From: chriseth Date: Sat, 28 Apr 2018 00:26:56 +0200 Subject: Further refactor. --- libsolidity/parsing/Parser.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'libsolidity/parsing/Parser.h') diff --git a/libsolidity/parsing/Parser.h b/libsolidity/parsing/Parser.h index 7a1a390e..902312e8 100644 --- a/libsolidity/parsing/Parser.h +++ b/libsolidity/parsing/Parser.h @@ -143,16 +143,18 @@ private: /// Used as return value of @see peekStatementType. enum class LookAheadInfo { - IndexAccessStructure, VariableDeclarationStatement, ExpressionStatement + IndexAccessStructure, VariableDeclaration, Expression }; /// Structure that represents a.b.c[x][y][z]. Can be converted either to an expression - /// or to a type name. Path cannot be empty, but indices can be empty. + /// or to a type name. For this to be valid, path cannot be empty, but indices can be empty. struct IndexAccessedPath { std::vector> path; std::vector, SourceLocation>> indices; + bool empty() const { return path.empty() && indices.empty(); } }; + std::pair tryParseIndexAccessedPath(); /// Performs limited look-ahead to distinguish between variable declaration and expression statement. /// For source code of the form "a[][8]" ("IndexAccessStructure"), this is not possible to /// decide with constant look-ahead. @@ -160,9 +162,11 @@ private: /// @returns an IndexAccessedPath as a prestage to parsing a variable declaration (type name) /// or an expression; IndexAccessedPath parseIndexAccessedPath(); - /// @returns a typename parsed in look-ahead fashion from something like "a.b[8][2**70]". + /// @returns a typename parsed in look-ahead fashion from something like "a.b[8][2**70]", + /// or an empty pointer if an empty @a _pathAndIncides has been supplied. ASTPointer typeNameFromIndexAccessStructure(IndexAccessedPath const& _pathAndIndices); - /// @returns an expression parsed in look-ahead fashion from something like "a.b[8][2**70]". + /// @returns an expression parsed in look-ahead fashion from something like "a.b[8][2**70]", + /// or an empty pointer if an empty @a _pathAndIncides has been supplied. ASTPointer expressionFromIndexAccessStructure(IndexAccessedPath const& _pathAndIndices); ASTPointer expectIdentifierToken(); -- cgit v1.2.3 From fe8f38a7a47241f4f910ef229e6655de7648c98b Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 9 May 2018 14:55:36 +0200 Subject: Assert integrity of empty IndexAccessPath structure. --- libsolidity/parsing/Parser.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libsolidity/parsing/Parser.h') diff --git a/libsolidity/parsing/Parser.h b/libsolidity/parsing/Parser.h index 902312e8..08653364 100644 --- a/libsolidity/parsing/Parser.h +++ b/libsolidity/parsing/Parser.h @@ -151,7 +151,7 @@ private: { std::vector> path; std::vector, SourceLocation>> indices; - bool empty() const { return path.empty() && indices.empty(); } + bool empty() const; }; std::pair tryParseIndexAccessedPath(); -- cgit v1.2.3