mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-21 16:53:08 +02:00
Lexer
- Number digits followed by non-whitespace, non-operators are not numbers, ie "2nd" is not "2","nd".
This commit is contained in:
parent
abe8819f2f
commit
309b607672
1 changed files with 7 additions and 0 deletions
|
@ -554,6 +554,7 @@ bool Lexer::isHexNumber (std::string& token, Lexer::Type& type)
|
||||||
// \d+
|
// \d+
|
||||||
// [ . \d+ ]
|
// [ . \d+ ]
|
||||||
// [ e|E [ +|- ] \d+ [ . \d+ ] ]
|
// [ e|E [ +|- ] \d+ [ . \d+ ] ]
|
||||||
|
// not followed by non-operator.
|
||||||
bool Lexer::isNumber (std::string& token, Lexer::Type& type)
|
bool Lexer::isNumber (std::string& token, Lexer::Type& type)
|
||||||
{
|
{
|
||||||
std::size_t marker = _cursor;
|
std::size_t marker = _cursor;
|
||||||
|
@ -603,6 +604,12 @@ bool Lexer::isNumber (std::string& token, Lexer::Type& type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If there is an immediately consecutive character, that is not an operator, fail.
|
||||||
|
if (_eos > marker &&
|
||||||
|
! isWhitespace (_text[marker]) &&
|
||||||
|
! isSingleCharOperator (_text[marker]))
|
||||||
|
return false;
|
||||||
|
|
||||||
token = _text.substr (_cursor, marker - _cursor);
|
token = _text.substr (_cursor, marker - _cursor);
|
||||||
type = Lexer::Type::number;
|
type = Lexer::Type::number;
|
||||||
_cursor = marker;
|
_cursor = marker;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue