aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/parsing/Parser.h
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-04-28 06:26:56 +0800
committerchriseth <chris@ethereum.org>2018-05-09 17:48:21 +0800
commitbe54f4819713ce5737a271bbdc43ac0a73a8e456 (patch)
treebbb504047efb23d50f16ef001059b124831a5a33 /libsolidity/parsing/Parser.h
parent86b7adc18f14049c7ea4aed9eaaa9b0368d8ec9e (diff)
downloaddexon-solidity-be54f4819713ce5737a271bbdc43ac0a73a8e456.tar.gz
dexon-solidity-be54f4819713ce5737a271bbdc43ac0a73a8e456.tar.zst
dexon-solidity-be54f4819713ce5737a271bbdc43ac0a73a8e456.zip
Further refactor.
Diffstat (limited to 'libsolidity/parsing/Parser.h')
-rw-r--r--libsolidity/parsing/Parser.h12
1 files changed, 8 insertions, 4 deletions
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<ASTPointer<PrimaryExpression>> path;
std::vector<std::pair<ASTPointer<Expression>, SourceLocation>> indices;
+ bool empty() const { return path.empty() && indices.empty(); }
};
+ 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.
@@ -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<TypeName> 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<Expression> expressionFromIndexAccessStructure(IndexAccessedPath const& _pathAndIndices);
ASTPointer<ASTString> expectIdentifierToken();