mirror of
https://github.com/jorenchik/mdemory.git
synced 2026-03-22 00:26:21 +00:00
refactoring the source files
This commit is contained in:
@@ -113,6 +113,7 @@ Result<std::vector<Token>> tokenizeMdem(const std::string& fileRunes) {
|
||||
column = 0;
|
||||
}
|
||||
|
||||
// Add escape char
|
||||
if (c == '\\') {
|
||||
i += 1;
|
||||
if (i < fileRunes.size()) {
|
||||
@@ -139,7 +140,7 @@ Result<std::vector<Token>> tokenizeMdem(const std::string& fileRunes) {
|
||||
|
||||
// EmitTokens
|
||||
switch (c) {
|
||||
case '[':
|
||||
case '[': {
|
||||
makeTokenWithTokenBuffer(
|
||||
TokenType::CooldownStart,
|
||||
1,
|
||||
@@ -149,8 +150,8 @@ Result<std::vector<Token>> tokenizeMdem(const std::string& fileRunes) {
|
||||
previousColumn = column;
|
||||
textStarted = false;
|
||||
identifierStarted = true;
|
||||
break;
|
||||
case ']':
|
||||
} break;
|
||||
case ']': {
|
||||
if (!identifierStarted) {
|
||||
return {
|
||||
tokens,
|
||||
@@ -168,8 +169,8 @@ Result<std::vector<Token>> tokenizeMdem(const std::string& fileRunes) {
|
||||
previousColumn = column;
|
||||
textStarted = false;
|
||||
identifierStarted = false;
|
||||
break;
|
||||
case '-':
|
||||
} break;
|
||||
case '-': {
|
||||
makeTokenWithTokenBuffer(
|
||||
TokenType::ElementDashStart,
|
||||
1,
|
||||
@@ -178,8 +179,8 @@ Result<std::vector<Token>> tokenizeMdem(const std::string& fileRunes) {
|
||||
previousRow = row;
|
||||
previousColumn = column;
|
||||
textStarted = false;
|
||||
break;
|
||||
case '^':
|
||||
} break;
|
||||
case '^': {
|
||||
makeTokenWithTokenBuffer(
|
||||
TokenType::ElementOrderModifier,
|
||||
1,
|
||||
@@ -188,8 +189,8 @@ Result<std::vector<Token>> tokenizeMdem(const std::string& fileRunes) {
|
||||
previousRow = row;
|
||||
previousColumn = column;
|
||||
textStarted = false;
|
||||
break;
|
||||
case ':':
|
||||
} break;
|
||||
case ':': {
|
||||
makeTokenWithTokenBuffer(
|
||||
TokenType::MatchGroupEnd,
|
||||
1,
|
||||
@@ -198,8 +199,8 @@ Result<std::vector<Token>> tokenizeMdem(const std::string& fileRunes) {
|
||||
previousRow = row;
|
||||
previousColumn = column;
|
||||
textStarted = false;
|
||||
break;
|
||||
case '>':
|
||||
} break;
|
||||
case '>': {
|
||||
makeTokenWithTokenBuffer(
|
||||
TokenType::QuestionEnd,
|
||||
1,
|
||||
@@ -207,8 +208,9 @@ Result<std::vector<Token>> tokenizeMdem(const std::string& fileRunes) {
|
||||
);
|
||||
previousRow = row;
|
||||
previousColumn = column;
|
||||
break;
|
||||
case '+':
|
||||
textStarted = false;
|
||||
} break;
|
||||
case '+': {
|
||||
makeTokenWithTokenBuffer(
|
||||
TokenType::ElementPlusStart,
|
||||
1,
|
||||
@@ -217,7 +219,7 @@ Result<std::vector<Token>> tokenizeMdem(const std::string& fileRunes) {
|
||||
previousRow = row;
|
||||
previousColumn = column;
|
||||
textStarted = false;
|
||||
break;
|
||||
} break;
|
||||
}
|
||||
|
||||
column += 1;
|
||||
@@ -262,7 +264,7 @@ std::string Token::ToString(const TokenType* ttype) {
|
||||
case TokenType::Cooldown: return "cooldown";
|
||||
case TokenType::CooldownStart: return "start of cooldown";
|
||||
case TokenType::CooldownEnd: return "end of cooldown";
|
||||
case TokenType::StartOfFile: return "start of the file";
|
||||
case TokenType::StartOfFile: return "start of the file";
|
||||
case TokenType::EndOfFile: return "end of file";
|
||||
default: return "unrecognized token";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user