llvm-journey

LLVM Journey
git clone git://0xff.ir/g/llvm-journey.git
Log | Files | Refs | README | LICENSE

commit 90b9c7410e85cb7c6f0376a1bd762419dadb039e
parent 2e68f7df509ce176e4fe7518161553cf99934b14
Author: Mohammad-Reza Nabipoor <m.nabipoor@yahoo.com>
Date:   Thu,  6 Aug 2020 09:17:13 +0430

kaleidoscope_lexer.hpp: Use std::string

Diffstat:
Mkaleidoscope_lexer.hpp | 10+++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/kaleidoscope_lexer.hpp b/kaleidoscope_lexer.hpp @@ -4,6 +4,7 @@ #include <algorithm> #include <cctype> #include <iterator> +#include <string> namespace kal { @@ -27,8 +28,8 @@ template<typename FwdIt, typename TokenOp> FwdIt lex(FwdIt f, FwdIt l, TokenOp token) { - static const char sDef[] = "def"; - static const char sExtern[] = "extern"; + static const std::string sDef{ "def" }; + static const std::string sExtern{ "extern" }; FwdIt b; // begin FwdIt e; // end @@ -45,10 +46,9 @@ lex(FwdIt f, FwdIt l, TokenOp token) ++f; e = f; - if (std::equal(b, e, std::cbegin(sDef), std::cend(sDef) - 1 /*'\0'*/)) + if (std::equal(b, e, std::cbegin(sDef), std::cend(sDef))) token(TkType::Def, b, e); - else if (std::equal( - b, e, std::begin(sExtern), std::end(sExtern) - 1 /*'\0'*/)) + else if (std::equal(b, e, std::begin(sExtern), std::end(sExtern))) token(TkType::Extern, b, e); else // [a-zA-Z][a-zA-Z0-9]* token(TkType::Id, b, e);