@@ -65,25 +65,32 @@ vector<dev::solidity::test::FunctionCall> TestFileParser::parseFunctionCalls()
65
65
{
66
66
FunctionCall call;
67
67
68
- expect (SoltToken::Newline);
69
- call.signature = parseFunctionSignature ();
68
+ // / If this is not the first call in the test,
69
+ // / the last call to parseParameter could have eaten the
70
+ // / new line already. This could only be fixed with a one
71
+ // / token lookahead that checks parseParameter
72
+ // / if the next token is an identifier.
73
+ if (calls.empty ())
74
+ expect (SoltToken::Newline);
75
+ else
76
+ accept (SoltToken::Newline, true );
70
77
78
+ call.signature = parseFunctionSignature ();
71
79
if (accept (SoltToken::Comma, true ))
72
80
call.value = parseFunctionCallValue ();
73
81
if (accept (SoltToken::Colon, true ))
74
82
call.arguments = parseFunctionCallArguments ();
75
83
76
- call.displayMode = parseNewline ();
84
+ if (accept (SoltToken::Newline, true ))
85
+ call.displayMode = FunctionCall::DisplayMode::MultiLine;
86
+
77
87
call.arguments .comment = parseComment ();
78
88
79
89
if (accept (SoltToken::Newline, true ))
80
90
call.displayMode = FunctionCall::DisplayMode::MultiLine;
81
- expect (SoltToken::Arrow);
82
91
92
+ expect (SoltToken::Arrow);
83
93
call.expectations = parseFunctionCallExpectations ();
84
-
85
- if (accept (SoltToken::Newline, false ))
86
- call.displayMode = parseNewline ();
87
94
call.expectations .comment = parseComment ();
88
95
89
96
calls.emplace_back (std::move (call));
@@ -121,12 +128,12 @@ bool TestFileParser::accept(SoltToken _token, bool const _expect)
121
128
bool TestFileParser::expect (SoltToken _token, bool const _advance)
122
129
{
123
130
if (m_scanner.currentToken () != _token)
124
- throw Error
125
- ( Error::Type::ParserError,
126
- " Unexpected " + formatToken (m_scanner.currentToken ()) + " : \" " +
127
- m_scanner.currentLiteral () + " \" . " +
128
- " Expected \" " + formatToken (_token) + " \" ."
129
- );
131
+ throw Error (
132
+ Error::Type::ParserError,
133
+ " Unexpected " + formatToken (m_scanner.currentToken ()) + " : \" " +
134
+ m_scanner.currentLiteral () + " \" . " +
135
+ " Expected \" " + formatToken (_token) + " \" ."
136
+ );
130
137
if (_advance)
131
138
m_scanner.scanNextToken ();
132
139
return true ;
@@ -184,7 +191,10 @@ FunctionCallExpectations TestFileParser::parseFunctionCallExpectations()
184
191
185
192
auto param = parseParameter ();
186
193
if (param.abiType .type == ABIType::None)
194
+ {
195
+ expectations.failure = false ;
187
196
return expectations;
197
+ }
188
198
expectations.parameters .emplace_back (param);
189
199
190
200
while (accept (SoltToken::Comma, true ))
@@ -227,7 +237,7 @@ pair<bytes, ABIType> TestFileParser::parseABITypeLiteral()
227
237
abiType = ABIType{ABIType::UnsignedDec, 32 };
228
238
number = convertNumber (parseNumber ());
229
239
}
230
- if (accept (SoltToken::Failure, true ))
240
+ else if (accept (SoltToken::Failure, true ))
231
241
{
232
242
abiType = ABIType{ABIType::Failure, 0 };
233
243
return make_pair (bytes{}, abiType);
@@ -241,13 +251,6 @@ pair<bytes, ABIType> TestFileParser::parseABITypeLiteral()
241
251
}
242
252
}
243
253
244
- solidity::test::FunctionCall::DisplayMode TestFileParser::parseNewline ()
245
- {
246
- if (accept (SoltToken::Newline, true ))
247
- return FunctionCall::DisplayMode::MultiLine;
248
- return FunctionCall::DisplayMode::SingleLine;
249
- }
250
-
251
254
string TestFileParser::parseComment ()
252
255
{
253
256
string comment = m_scanner.currentLiteral ();
@@ -348,8 +351,6 @@ void TestFileParser::Scanner::scanNextToken()
348
351
}
349
352
}
350
353
while (token.first == SoltToken::Whitespace);
351
-
352
- m_nextToken = token;
353
354
m_currentToken = token;
354
355
}
355
356
0 commit comments