Website Summary Files Commits Branches @commit @diff @stats
path: root / JSImpl / src / Lexer.cpp
diff options
context:
space:
mode:
Commit156d0957c1b36bba2685fef548a8573e9337309a (patch)
Author
 omalinov <ognyan.m@coherent-labs.com>
2018-11-18 23:01:20 +0200
Committer
 GitHub <noreply@github.com>
2018-11-18 23:01:20 +0200
Files3a882d71f65d8b5c129e348985c2c1a4fe70a031 /JSImpl/src/Lexer.cpp
IPL-156d0957c1b36bba2685fef548a8573e9337309a.tar
IPL-156d0957c1b36bba2685fef548a8573e9337309a.tar.gz
IPL-156d0957c1b36bba2685fef548a8573e9337309a.zip
Parenta5ebf986574bdcdad968962751d9ab8dbe90980d (diff)
Parent12232668d931b0f3593807d2096a2c2f26844b0b (diff)
Merge branch 'master' into json-to-ast
1 files changed, 6 insertions, 2 deletions
-rw-r--r--JSImpl/src/Lexer.cpp8
diff --git a/JSImpl/src/Lexer.cpp b/JSImpl/src/Lexer.cpp
index 8b3b909..dbbf92d 100644
--- a/JSImpl/src/Lexer.cpp
+++ b/JSImpl/src/Lexer.cpp
@@ -105,6 +105,7 @@ private:
unsigned m_Line;
unsigned m_Column;
unsigned m_Current;
+ unsigned m_LastTokenPozition;
const char* m_Code;
IPLError m_Error;
@@ -132,6 +133,7 @@ Tokenizer::Tokenizer(const char* code, const LexerSettings& settings)
: m_Line(0)
, m_Column(0)
, m_Current(0)
+ , m_LastTokenPozition(0)
, m_Code(code)
, m_Error()
, m_GenerationState(State::Success)
@@ -253,12 +255,14 @@ inline void Tokenizer::NextLine()
{
++m_Current;
++m_Line;
- m_Column = 0;
+ m_LastTokenPozition = m_Column = 0;
}
inline Token Tokenizer::ProduceToken(TokenType type, IPLString lexeme, double number = 0.0)
{
- return Token{ type, m_Line, lexeme, number };
+ auto token = Token{ type, m_Line, m_LastTokenPozition, lexeme, number };
+ m_LastTokenPozition = m_Column;
+ return token;
}
inline Token Tokenizer::ProduceSkipToken()