aboutsummaryrefslogtreecommitdiffstats
path: root/Parser.cpp
diff options
context:
space:
mode:
authorLiana Husikyan <liana@ethdev.com>2015-02-09 09:06:30 +0800
committerLiana Husikyan <liana@ethdev.com>2015-02-09 09:06:30 +0800
commit2a5c2578bd7e07326412ac0345ed5f5283908ccb (patch)
tree863e089d25f486125099417bcc8f963a034bf41f /Parser.cpp
parenta66db516fb1025b406c8fcdb694b7fb760f84695 (diff)
downloaddexon-solidity-2a5c2578bd7e07326412ac0345ed5f5283908ccb.tar
dexon-solidity-2a5c2578bd7e07326412ac0345ed5f5283908ccb.tar.gz
dexon-solidity-2a5c2578bd7e07326412ac0345ed5f5283908ccb.tar.bz2
dexon-solidity-2a5c2578bd7e07326412ac0345ed5f5283908ccb.tar.lz
dexon-solidity-2a5c2578bd7e07326412ac0345ed5f5283908ccb.tar.xz
dexon-solidity-2a5c2578bd7e07326412ac0345ed5f5283908ccb.tar.zst
dexon-solidity-2a5c2578bd7e07326412ac0345ed5f5283908ccb.zip
- implemented Empty parameter name story. Now the name of input/return parameters of function can be not specified.
- added appropriate tests Conflicts: test/SolidityEndToEndTest.cpp test/SolidityNameAndTypeResolution.cpp
Diffstat (limited to 'Parser.cpp')
-rw-r--r--Parser.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/Parser.cpp b/Parser.cpp
index d8c15c36..2f5b18a0 100644
--- a/Parser.cpp
+++ b/Parser.cpp
@@ -268,17 +268,28 @@ ASTPointer<VariableDeclaration> Parser::parseVariableDeclaration(VarDeclParserOp
ASTNodeFactory nodeFactory(*this);
ASTPointer<TypeName> type = parseTypeName(_options.allowVar);
bool isIndexed = false;
+ ASTPointer<ASTString> identifier;
Token::Value token = m_scanner->getCurrentToken();
+ Declaration::Visibility visibility(Declaration::Visibility::DEFAULT);
+ if (_options.isStateVariable && Token::isVisibilitySpecifier(token))
+ visibility = parseVisibilitySpecifier(token);
if (_options.allowIndexed && token == Token::INDEXED)
{
isIndexed = true;
m_scanner->next();
}
- Declaration::Visibility visibility(Declaration::Visibility::DEFAULT);
- if (_options.isStateVariable && Token::isVisibilitySpecifier(token))
- visibility = parseVisibilitySpecifier(token);
+ if (_options.allowEmptyName && m_scanner->getCurrentToken() != Token::IDENTIFIER)
+ {
+ identifier = make_shared<ASTString>("");
+ nodeFactory.setEndPositionFromNode(type);
+ }
+ else
+ {
+ nodeFactory.markEndPosition();
+ identifier = expectIdentifierToken();
+ }
nodeFactory.markEndPosition();
- return nodeFactory.createNode<VariableDeclaration>(type, expectIdentifierToken(),
+ return nodeFactory.createNode<VariableDeclaration>(type, identifier,
visibility, _options.isStateVariable,
isIndexed);
}
@@ -402,6 +413,7 @@ ASTPointer<ParameterList> Parser::parseParameterList(bool _allowEmpty, bool _all
vector<ASTPointer<VariableDeclaration>> parameters;
VarDeclParserOptions options;
options.allowIndexed = _allowIndexed;
+ options.allowEmptyName = true;
expectToken(Token::LPAREN);
if (!_allowEmpty || m_scanner->getCurrentToken() != Token::RPAREN)
{