Skip to content

Commit 118b1fe

Browse files
committed
Fix issue #25
1 parent c91ddf7 commit 118b1fe

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

source/tcppLibrary.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ namespace tcpp
127127
CLOSE_BRACKET,
128128
OPEN_SQUARE_BRACKET,
129129
CLOSE_SQUARE_BRACKET,
130+
OPEN_BRACE,
131+
CLOSE_BRACE,
130132
COMMA,
131133
NEWLINE,
132134
LESS,
@@ -689,7 +691,7 @@ namespace tcpp
689691
"do", "if", "static", "while"
690692
};
691693

692-
static const std::string separators = ",()[]<>\"+-*/&|!=;";
694+
static const std::string separators = ",()[]<>\"+-*/&|!=;{}";
693695

694696
std::string currStr = EMPTY_STR_VALUE;
695697

@@ -1019,6 +1021,10 @@ namespace tcpp
10191021
return { E_TOKEN_TYPE::OPEN_SQUARE_BRACKET, "[", mCurrLineIndex, mCurrPos };
10201022
case ']':
10211023
return { E_TOKEN_TYPE::CLOSE_SQUARE_BRACKET, "]", mCurrLineIndex, mCurrPos };
1024+
case '{':
1025+
return { E_TOKEN_TYPE::OPEN_BRACE, "{", mCurrLineIndex, mCurrPos };
1026+
case '}':
1027+
return { E_TOKEN_TYPE::CLOSE_BRACE, "}", mCurrLineIndex, mCurrPos };
10221028
case '<':
10231029
if (!inputLine.empty())
10241030
{

tests/lexerTests.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ TEST_CASE("Lexer Tests")
8383

8484
SECTION("TestGetNextToken_PassStreamWithSeparators_ReturnsTheirTokens")
8585
{
86-
Lexer lexer(std::make_unique<MockInputStream>(std::vector<std::string> { ",()<>\"&|+-*/&&||<<>>!<=>===!=" }));
86+
Lexer lexer(std::make_unique<MockInputStream>(std::vector<std::string> { ",()<>\"&|+-*/&&||<<>>!<=>===!={}" }));
8787

8888
REQUIRE(lexer.GetNextToken().mType == E_TOKEN_TYPE::COMMA);
8989
REQUIRE(lexer.GetNextToken().mType == E_TOKEN_TYPE::OPEN_BRACKET);
@@ -106,6 +106,8 @@ TEST_CASE("Lexer Tests")
106106
REQUIRE(lexer.GetNextToken().mType == E_TOKEN_TYPE::GE);
107107
REQUIRE(lexer.GetNextToken().mType == E_TOKEN_TYPE::EQ);
108108
REQUIRE(lexer.GetNextToken().mType == E_TOKEN_TYPE::NE);
109+
REQUIRE(lexer.GetNextToken().mType == E_TOKEN_TYPE::OPEN_BRACE);
110+
REQUIRE(lexer.GetNextToken().mType == E_TOKEN_TYPE::CLOSE_BRACE);
109111
REQUIRE(lexer.GetNextToken().mType == E_TOKEN_TYPE::END);
110112
}
111113

0 commit comments

Comments
 (0)