From 309b607672db9ee76031861a3cfdc0cc891e0a71 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 1 Mar 2015 16:03:10 -0500 Subject: [PATCH] Lexer - Number digits followed by non-whitespace, non-operators are not numbers, ie "2nd" is not "2","nd". --- src/Lexer.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Lexer.cpp b/src/Lexer.cpp index 3cbfa9b8b..a098db942 100644 --- a/src/Lexer.cpp +++ b/src/Lexer.cpp @@ -554,6 +554,7 @@ bool Lexer::isHexNumber (std::string& token, Lexer::Type& type) // \d+ // [ . \d+ ] // [ e|E [ +|- ] \d+ [ . \d+ ] ] +// not followed by non-operator. bool Lexer::isNumber (std::string& token, Lexer::Type& type) { 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); type = Lexer::Type::number; _cursor = marker;