Fixes Natspec parser error when whitespace is missing.

This commit is contained in:
Erik Kundt 2019-04-26 17:05:26 +02:00
parent 661b08e16c
commit 656364d967
3 changed files with 33 additions and 3 deletions

View File

@ -17,6 +17,7 @@
#include <libsolidity/parsing/DocStringParser.h>
#include <liblangutil/Common.h>
#include <liblangutil/ErrorReporter.h>
#include <liblangutil/Exceptions.h>
@ -39,12 +40,19 @@ string::const_iterator skipLineOrEOS(
return (_nlPos == _end) ? _end : ++_nlPos;
}
string::const_iterator firstSpaceOrTab(
string::const_iterator firstNonIdentifier(
string::const_iterator _pos,
string::const_iterator _end
)
{
return boost::range::find_first_of(make_pair(_pos, _end), " \t");
auto currPos = _pos;
if (currPos == _pos && isIdentifierStart(*currPos))
{
currPos++;
while (currPos != _end && isIdentifierPart(*currPos))
currPos++;
}
return currPos;
}
string::const_iterator firstWhitespaceOrNewline(
@ -135,7 +143,7 @@ DocStringParser::iter DocStringParser::parseDocTagParam(iter _pos, iter _end)
appendError("No param name given");
return _end;
}
auto nameEndPos = firstSpaceOrTab(nameStartPos, _end);
auto nameEndPos = firstNonIdentifier(nameStartPos, _end);
auto paramName = string(nameStartPos, nameEndPos);
auto descStartPos = skipWhitespace(nameEndPos, _end);

View File

@ -0,0 +1,11 @@
contract C {
/**
* @dev a function
* @param _from 5 from address
* @param _5to : to address
* @param value: token transfer amount
* @param value? token transfer amount
*/
function f(address _from, address _5to, uint256 value) internal {
}
}

View File

@ -0,0 +1,11 @@
contract C {
/**
* @param 5value a value parameter
* @param _ a value parameter
*/
function f(uint256 _5value, uint256 _value, uint256 value) internal {
}
}
// ----
// DocstringParsingError: Documented parameter "" not found in the parameter list of the function.
// DocstringParsingError: Documented parameter "_" not found in the parameter list of the function.