aboutsummaryrefslogtreecommitdiffstats
path: root/Parser.h
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2015-02-20 22:52:30 +0800
committerChristian <c@ethdev.com>2015-02-21 22:10:01 +0800
commit5e3208317922d20a5b3b760df872a589d87bf94d (patch)
tree982cb7d888c7ae395de3f533c8e8d1bdd27c5c27 /Parser.h
parent75498a48d83277240605b43e27197be36c02ce23 (diff)
downloaddexon-solidity-5e3208317922d20a5b3b760df872a589d87bf94d.tar.gz
dexon-solidity-5e3208317922d20a5b3b760df872a589d87bf94d.tar.zst
dexon-solidity-5e3208317922d20a5b3b760df872a589d87bf94d.zip
Parsing of array types and basic implementation.
Diffstat (limited to 'Parser.h')
-rw-r--r--Parser.h40
1 files changed, 29 insertions, 11 deletions
diff --git a/Parser.h b/Parser.h
index 4034aec8..8726decb 100644
--- a/Parser.h
+++ b/Parser.h
@@ -64,7 +64,9 @@ private:
ASTPointer<StructDefinition> parseStructDefinition();
ASTPointer<EnumDefinition> parseEnumDefinition();
ASTPointer<EnumValue> parseEnumValue();
- ASTPointer<VariableDeclaration> parseVariableDeclaration(VarDeclParserOptions const& _options = VarDeclParserOptions());
+ ASTPointer<VariableDeclaration> parseVariableDeclaration(
+ VarDeclParserOptions const& _options = VarDeclParserOptions(),
+ ASTPointer<TypeName> const& _lookAheadArrayType = ASTPointer<TypeName>());
ASTPointer<ModifierDefinition> parseModifierDefinition();
ASTPointer<EventDefinition> parseEventDefinition();
ASTPointer<ModifierInvocation> parseModifierInvocation();
@@ -77,13 +79,20 @@ private:
ASTPointer<IfStatement> parseIfStatement();
ASTPointer<WhileStatement> parseWhileStatement();
ASTPointer<ForStatement> parseForStatement();
- ASTPointer<Statement> parseVarDeclOrExprStmt();
- ASTPointer<VariableDeclarationStatement> parseVariableDeclarationStatement();
- ASTPointer<ExpressionStatement> parseExpressionStatement();
- ASTPointer<Expression> parseExpression();
- ASTPointer<Expression> parseBinaryExpression(int _minPrecedence = 4);
- ASTPointer<Expression> parseUnaryExpression();
- ASTPointer<Expression> parseLeftHandSideExpression();
+ /// A "simple statement" can be a variable declaration statement or an expression statement.
+ ASTPointer<Statement> parseSimpleStatement();
+ ASTPointer<VariableDeclarationStatement> parseVariableDeclarationStatement(
+ ASTPointer<TypeName> const& _lookAheadArrayType = ASTPointer<TypeName>());
+ ASTPointer<ExpressionStatement> parseExpressionStatement(
+ ASTPointer<Expression> const& _lookAheadArrayExpression = ASTPointer<Expression>());
+ ASTPointer<Expression> parseExpression(
+ ASTPointer<Expression> const& _lookAheadArrayExpression = ASTPointer<Expression>());
+ ASTPointer<Expression> parseBinaryExpression(int _minPrecedence = 4,
+ ASTPointer<Expression> const& _lookAheadArrayExpression = ASTPointer<Expression>());
+ ASTPointer<Expression> parseUnaryExpression(
+ ASTPointer<Expression> const& _lookAheadArrayExpression = ASTPointer<Expression>());
+ ASTPointer<Expression> parseLeftHandSideExpression(
+ ASTPointer<Expression> const& _lookAheadArrayExpression = ASTPointer<Expression>());
ASTPointer<Expression> parsePrimaryExpression();
std::vector<ASTPointer<Expression>> parseFunctionCallListArguments();
std::pair<std::vector<ASTPointer<Expression>>, std::vector<ASTPointer<ASTString>>> parseFunctionCallArguments();
@@ -92,9 +101,18 @@ private:
///@{
///@name Helper functions
- /// Peeks ahead in the scanner to determine if a variable declaration statement is going to follow
- bool peekVariableDeclarationStatement();
-
+ /// Performs limited look-ahead to distinguish between variable declaration and expression statement.
+ /// @returns 1 if it is a variable declaration, -1 if it is an expression statement and 0 if
+ /// it might be an array-typed variable declaration or an index access to an existing variable.
+ int peekVariableDeclarationStatement() const;
+ /// Returns a typename parsed in look-ahead fashion from something like "a[8][2**70]".
+ ASTPointer<TypeName> typeNameFromArrayIndexStructure(
+ ASTPointer<PrimaryExpression> const& _primary,
+ std::vector<std::pair<ASTPointer<Expression>, Location>> const& _indices);
+ /// Returns an expression parsed in look-ahead fashion from something like "a[8][2**70]".
+ ASTPointer<Expression> expressionFromArrayIndexStructure(
+ ASTPointer<PrimaryExpression> const& _primary,
+ std::vector<std::pair<ASTPointer<Expression>, Location>> const& _indices);
/// If current token value is not _value, throw exception otherwise advance token.
void expectToken(Token::Value _value);
Token::Value expectAssignmentOperator();