diff options
| Commit | 12232668d931b0f3593807d2096a2c2f26844b0b (patch) | |
|---|---|---|
| Author | 2018-11-18 20:32:58 +0200 | |
| Committer | 2018-11-18 20:32:58 +0200 | |
| Files | eb05bfcde4de31a03ce033ed479db29c4b527bcc /JSImpl/src/Lexer.cpp | |
| IPL-12232668d931b0f3593807d2096a2c2f26844b0b.tar IPL-12232668d931b0f3593807d2096a2c2f26844b0b.tar.gz IPL-12232668d931b0f3593807d2096a2c2f26844b0b.zip | ||
| Parent | 5729bc0ea96fc0b944c243230910c537d692bcad (diff) | |
Code generation improvements (#56)
* Implement code generation for some unary expressions
Implement debug code augmentation.
Now part of expresions have source location.
Extend Tokens with Column information.
Refactor byte code generation.
Add options for byte code generator.
* Fix linux build
* Little refactoring in byte code generation
* Fix couple bugs in byte code generation and add some tests.
* Fix some linux warnings.
1 files changed, 6 insertions, 2 deletions
| -rw-r--r-- | JSImpl/src/Lexer.cpp | 8 |
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() |
