Website Summary Files Commits Branches @commit @diff @stats
path: root / JSImpl / src
diff options
context:
space:
mode:
Commit1384d7ea4e80eaa6b195195af81de974575b2bb0 (patch)
Author
 omalinov <ognyan.m@coherent-labs.com>
2018-10-21 17:36:32 +0300
Committer
 Martin Dobrev <martindobrev0@gmail.com>
2018-10-21 17:36:32 +0300
Files4e73618753e1d42f9cfa60a247a8bcf35c483db7 /JSImpl/src
IPL-1384d7ea4e80eaa6b195195af81de974575b2bb0.tar
IPL-1384d7ea4e80eaa6b195195af81de974575b2bb0.tar.gz
IPL-1384d7ea4e80eaa6b195195af81de974575b2bb0.zip
Parent7509dce0686d9a418975f73b3721ecaa2d534f16 (diff)
Lexer/homework (#15)
* Initial commit * code is formatted * Homework finished * Genie project generation. * Updated code with new constructors
3 files changed, 6 insertions, 2 deletions
-rw-r--r--JSImpl/src/Lexer.cpp3
-rw-r--r--JSImpl/src/Lexer.h1
-rw-r--r--JSImpl/src/main.cpp4
diff --git a/JSImpl/src/Lexer.cpp b/JSImpl/src/Lexer.cpp
index 5d85570..8b3b909 100644
--- a/JSImpl/src/Lexer.cpp
+++ b/JSImpl/src/Lexer.cpp
@@ -342,6 +342,8 @@ inline Token Tokenizer::ProduceToken(TokenType type)
return ProduceToken(type, ";");
case TokenType::Star:
return ProduceToken(type, "*");
+ case TokenType::Backslash:
+ return ProduceToken(type, "\\");
default: // EoF Invalid
break;
}
@@ -585,6 +587,7 @@ Token Tokenizer::NextToken()
case ':': NextSymbol(); return ProduceToken(TokenType::Colon);
case '[': NextSymbol(); return ProduceToken(TokenType::LeftSquareBracket);
case ']': NextSymbol(); return ProduceToken(TokenType::RightSquareBracket);
+ case '\\': NextSymbol(); return ProduceToken(TokenType::Backslash);
default:
break;
}
diff --git a/JSImpl/src/Lexer.h b/JSImpl/src/Lexer.h
index e17270d..5ea5064 100644
--- a/JSImpl/src/Lexer.h
+++ b/JSImpl/src/Lexer.h
@@ -53,6 +53,7 @@ enum class TokenType
BitwiseAndEqual,
BitwiseXorEqual,
BitwiseOrEqual,
+ Backslash,
Identifier,
String,
diff --git a/JSImpl/src/main.cpp b/JSImpl/src/main.cpp
index 3950569..73f883f 100644
--- a/JSImpl/src/main.cpp
+++ b/JSImpl/src/main.cpp
@@ -86,7 +86,6 @@ void TestStringError()
{
IPLVector<Token> tokens;
const auto& res = Tokenize("\" aaaa", tokens);
-
CHECK(!res.IsSuccessful && res.Error.Row == 0 && res.Error.Column == 6);
}
@@ -183,7 +182,7 @@ void TestConsecutiveMultiLineCommentWithSpaceWithTokens()
void TestCommentError()
{
IPLVector<Token> tokens;
- const auto& res = Tokenize(" aa\n /*", tokens, { false, true });
+ const auto& res = Tokenize(" aa\n /*", tokens);
CHECK(!res.IsSuccessful && res.Error.Row == 1 && res.Error.Column == 3);
}
@@ -235,6 +234,7 @@ int main()
EXECUTE_TEST(TestCommentError);
EXECUTE_TEST(TestHexNumber);
EXECUTE_TEST(TestScientificNotationNumber);
+
// TestParseUnaryExpr();
#if defined(_WIN32)
std::system("pause");