From 289780c8cc946bc56f88501ef8fa9a51acadf032 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 20 Mar 2015 17:16:00 -0400 Subject: [PATCH] Lexer: Added comments --- src/CLI.cpp | 4 ++-- src/Lexer.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/CLI.cpp b/src/CLI.cpp index 7fb55a7e3..1a15e65eb 100644 --- a/src/CLI.cpp +++ b/src/CLI.cpp @@ -712,8 +712,8 @@ void CLI::addArg (const std::string& arg, Lexer::Type type /* = Lexer::Type::wor _original_args.push_back (raw); } - // The argument may require lexing. Lex anyway, and analyze before comitting - // that. + // The argument may require lexing. Lex anyway, and analyze before comitting + // to that. else { // Lex each remaining argument. The apply a series of disqualifying tests diff --git a/src/Lexer.cpp b/src/Lexer.cpp index e16758852..9a6169b5e 100644 --- a/src/Lexer.cpp +++ b/src/Lexer.cpp @@ -608,6 +608,7 @@ bool Lexer::isNumber (std::string& token, Lexer::Type& type) } } + // Lookahread: ! | ! // If there is an immediately consecutive character, that is not an operator, fail. if (_eos > marker && ! isWhitespace (_text[marker]) && @@ -753,9 +754,7 @@ bool Lexer::isTag (std::string& token, Lexer::Type& type) { std::size_t marker = _cursor; - // This test requires a tag to have a preceding space or start a string. - // bad: 'a+b' --> identifier tag - // good: 'a+b' --> identifier op identifier + // Lookbehind: ^ | if (marker > 0 && ! isWhitespace (_text[marker - 1])) return false; @@ -844,6 +843,7 @@ bool Lexer::isSubstitution (std::string& token, Lexer::Type& type) if (_text[_cursor] == 'g') ++_cursor; + // Lookahread: if (isWhitespace (_text[_cursor])) { token = _text.substr (marker, _cursor - marker);