aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/parsing/Parser.h
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-05-16 20:43:57 +0800
committerGitHub <noreply@github.com>2018-05-16 20:43:57 +0800
commite67f0147998a9e3835ed3ce8bf6a0a0c634216c5 (patch)
treeb9c0b7d41cd9f78ae3404704a888da30e767edbe /libsolidity/parsing/Parser.h
parent124ca40dc525a987a88176c6e5170978e82fa290 (diff)
parent1e45d3ab2e0ca688c2ae48ab657f11496ccebc12 (diff)
downloaddexon-solidity-e67f0147998a9e3835ed3ce8bf6a0a0c634216c5.tar
dexon-solidity-e67f0147998a9e3835ed3ce8bf6a0a0c634216c5.tar.gz
dexon-solidity-e67f0147998a9e3835ed3ce8bf6a0a0c634216c5.tar.bz2
dexon-solidity-e67f0147998a9e3835ed3ce8bf6a0a0c634216c5.tar.lz
dexon-solidity-e67f0147998a9e3835ed3ce8bf6a0a0c634216c5.tar.xz
dexon-solidity-e67f0147998a9e3835ed3ce8bf6a0a0c634216c5.tar.zst
dexon-solidity-e67f0147998a9e3835ed3ce8bf6a0a0c634216c5.zip
Merge pull request #4148 from ethereum/develop
Merge develop into release for 0.4.24
Diffstat (limited to 'libsolidity/parsing/Parser.h')
-rw-r--r--libsolidity/parsing/Parser.h42
1 files changed, 24 insertions, 18 deletions
diff --git a/libsolidity/parsing/Parser.h b/libsolidity/parsing/Parser.h
index eb120a61..08653364 100644
--- a/libsolidity/parsing/Parser.h
+++ b/libsolidity/parsing/Parser.h
@@ -118,19 +118,19 @@ private:
);
ASTPointer<ExpressionStatement> parseExpressionStatement(
ASTPointer<ASTString> const& _docString,
- ASTPointer<Expression> const& _lookAheadIndexAccessStructure = ASTPointer<Expression>()
+ ASTPointer<Expression> const& _partiallyParsedExpression = ASTPointer<Expression>()
);
ASTPointer<Expression> parseExpression(
- ASTPointer<Expression> const& _lookAheadIndexAccessStructure = ASTPointer<Expression>()
+ ASTPointer<Expression> const& _partiallyParsedExpression = ASTPointer<Expression>()
);
ASTPointer<Expression> parseBinaryExpression(int _minPrecedence = 4,
- ASTPointer<Expression> const& _lookAheadIndexAccessStructure = ASTPointer<Expression>()
+ ASTPointer<Expression> const& _partiallyParsedExpression = ASTPointer<Expression>()
);
ASTPointer<Expression> parseUnaryExpression(
- ASTPointer<Expression> const& _lookAheadIndexAccessStructure = ASTPointer<Expression>()
+ ASTPointer<Expression> const& _partiallyParsedExpression = ASTPointer<Expression>()
);
ASTPointer<Expression> parseLeftHandSideExpression(
- ASTPointer<Expression> const& _lookAheadIndexAccessStructure = ASTPointer<Expression>()
+ ASTPointer<Expression> const& _partiallyParsedExpression = ASTPointer<Expression>()
);
ASTPointer<Expression> parsePrimaryExpression();
std::vector<ASTPointer<Expression>> parseFunctionCallListArguments();
@@ -143,26 +143,32 @@ 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. For this to be valid, path cannot be empty, but indices can be empty.
+ struct IndexAccessedPath
+ {
+ std::vector<ASTPointer<PrimaryExpression>> path;
+ std::vector<std::pair<ASTPointer<Expression>, SourceLocation>> indices;
+ bool empty() const;
};
+ std::pair<LookAheadInfo, IndexAccessedPath> 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.
LookAheadInfo peekStatementType() const;
- /// @returns a typename parsed in look-ahead fashion from something like "a.b[8][2**70]".
- ASTPointer<TypeName> typeNameIndexAccessStructure(
- std::vector<ASTPointer<PrimaryExpression>> const& _path,
- std::vector<std::pair<ASTPointer<Expression>, SourceLocation>> const& _indices
- );
- /// @returns an expression parsed in look-ahead fashion from something like "a.b[8][2**70]".
- ASTPointer<Expression> expressionFromIndexAccessStructure(
- std::vector<ASTPointer<PrimaryExpression>> const& _path,
- std::vector<std::pair<ASTPointer<Expression>, SourceLocation>> const& _indices
- );
+ /// @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]",
+ /// or an empty pointer if an empty @a _pathAndIncides has been supplied.
+ ASTPointer<TypeName> typeNameFromIndexAccessStructure(IndexAccessedPath const& _pathAndIndices);
+ /// @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<Expression> expressionFromIndexAccessStructure(IndexAccessedPath const& _pathAndIndices);
- std::string currentTokenName();
- Token::Value expectAssignmentOperator();
ASTPointer<ASTString> expectIdentifierToken();
ASTPointer<ASTString> getLiteralAndAdvance();
///@}