Skip to content

Commit f52b404

Browse files
committed
Fix auto code-formatter disaster
1 parent 95e0ccf commit f52b404

3 files changed

Lines changed: 31 additions & 33 deletions

File tree

lib/include/pl/core/lexer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,6 @@ namespace pl::core {
8484
u32 m_tabCompensation = 0;
8585
u32 m_lineBegin = 0;
8686
size_t m_longestLineLength = 0;
87-
u32 m_errorLength;
87+
u32 m_errorLength = 0
8888
};
8989
}

lib/include/pl/pattern_language.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ namespace pl {
397397
return this->m_subRuntime;
398398
}
399399

400-
[[nodiscard]] const std::set<pl::ptrn::Pattern*>& getPatternsWithAttribute(const std::string& attribute) const;
400+
[[nodiscard]] const std::set<pl::ptrn::Pattern*>& getPatternsWithAttribute(const std::string & attribute) const;
401401

402402
private:
403403
void flattenPatterns();

lib/source/pl/core/lexer.cpp

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ namespace pl::core {
1616

1717
static bool isIntegerCharacter(const char c, const int base) {
1818
switch (base) {
19-
case 16:
20-
return std::isxdigit(c);
21-
case 10:
22-
return std::isdigit(c);
23-
case 8:
24-
return c >= '0' && c <= '7';
25-
case 2:
26-
return c == '0' || c == '1';
27-
default:
28-
return false;
19+
case 16:
20+
return std::isxdigit(c);
21+
case 10:
22+
return std::isdigit(c);
23+
case 8:
24+
return c >= '0' && c <= '7';
25+
case 2:
26+
return c == '0' || c == '1';
27+
default:
28+
return false;
2929
}
3030
}
3131

@@ -46,7 +46,7 @@ namespace pl::core {
4646
static size_t getIntegerLiteralLength(const std::string_view& literal) {
4747
const auto count = literal.find_first_not_of("0123456789ABCDEFabcdef'xXoOpP.uU+-");
4848
const std::string_view intLiteral = count == std::string_view::npos ? literal : literal.substr(0, count);
49-
if (const auto signPos = intLiteral.find_first_of("+-"); signPos != std::string_view::npos && ((literal.at(signPos-1) != 'e' && literal.at(signPos-1) != 'E') || literal.starts_with("0x")))
49+
if (const auto signPos = intLiteral.find_first_of("+-"); signPos != std::string_view::npos && ((literal.at(signPos-1) != 'e' && literal.at(signPos-1) != 'E') || literal.starts_with("0x")))
5050
return signPos;
5151
return intLiteral.size();
5252
}
@@ -76,35 +76,33 @@ namespace pl::core {
7676
case '\\':
7777
return '\\';
7878
case 'x': {
79-
const char hex[3] = {m_sourceCode[m_cursor], m_sourceCode[m_cursor + 1], 0};
79+
const char hex[3] = { m_sourceCode[m_cursor], m_sourceCode[m_cursor + 1], 0 };
8080
m_cursor += 2;
8181
try {
8282
return static_cast<char>(std::stoul(hex, nullptr, 16));
83-
}
84-
catch (const std::invalid_argument&) {
83+
} catch (const std::invalid_argument&) {
8584
m_errorLength = 2;
8685
error("Invalid hex escape sequence: {}", hex);
8786
return std::nullopt;
8887
}
8988
}
9089
case 'u': {
91-
const char hex[5] = {m_sourceCode[m_cursor], m_sourceCode[m_cursor + 1], m_sourceCode[m_cursor + 2],
92-
m_sourceCode[m_cursor + 3], 0};
90+
const char hex[5] = { m_sourceCode[m_cursor], m_sourceCode[m_cursor + 1], m_sourceCode[m_cursor + 2],
91+
m_sourceCode[m_cursor + 3], 0 };
9392
m_cursor += 4;
9493
try {
9594
return static_cast<char>(std::stoul(hex, nullptr, 16));
96-
}
97-
catch (const std::invalid_argument &) {
95+
} catch (const std::invalid_argument&) {
9896
m_errorLength = 4;
9997
error("Invalid unicode escape sequence: {}", hex);
10098
return std::nullopt;
10199
}
102100
}
103101
default:
104102
m_errorLength = 1;
105-
error("Unknown escape sequence: {}", m_sourceCode[m_cursor - 1]);
106-
return std::nullopt;
107-
}
103+
error("Unknown escape sequence: {}", m_sourceCode[m_cursor-1]);
104+
return std::nullopt;
105+
}
108106
}
109107
return c;
110108
}
@@ -122,11 +120,10 @@ namespace pl::core {
122120
std::optional<Token> Lexer::parseDirectiveValue() {
123121
std::string result;
124122

125-
// TODO: What if there are two spaces? Tabs? BUG!
126123
m_cursor++; // Skip space
127124
auto location = this->location();
128125

129-
while (!std::isblank(m_sourceCode[m_cursor]) && !std::isspace(m_sourceCode[m_cursor]) && m_sourceCode[m_cursor] != '\0') {
126+
while (!std::isblank(m_sourceCode[m_cursor]) && !std::isspace(m_sourceCode[m_cursor]) && m_sourceCode[m_cursor] != '\0' ) {
130127

131128
auto character = parseCharacter();
132129
if (!character.has_value()) {
@@ -136,7 +133,8 @@ namespace pl::core {
136133
result += character.value();
137134
}
138135

139-
skipLineEnding();
136+
if (hasTheLineEnded(m_sourceCode[m_cursor]))
137+
m_cursor++;
140138

141139
return makeTokenAt(Literal::makeString(result), location, result.size());
142140
}
@@ -201,35 +199,35 @@ namespace pl::core {
201199
u8 base = 10;
202200

203201
u128 value = 0;
204-
if (literal[0] == '0') {
205-
if (literal.size() == 1) {
202+
if(literal[0] == '0') {
203+
if(literal.size() == 1) {
206204
return 0;
207205
}
208206
bool hasPrefix = true;
209207
switch (literal[1]) {
210208
case 'x':
211209
case 'X':
212210
base = 16;
213-
break;
211+
break;
214212
case 'o':
215213
case 'O':
216214
base = 8;
217-
break;
215+
break;
218216
case 'b':
219217
case 'B':
220218
base = 2;
221-
break;
219+
break;
222220
default:
223221
hasPrefix = false;
224-
break;
222+
break;
225223
}
226224
if (hasPrefix) {
227225
literal = literal.substr(2);
228226
}
229227
}
230228

231229
for (const char c : literal) {
232-
if (c == integerSeparator) continue;
230+
if(c == integerSeparator) continue;
233231

234232
if (!isIntegerCharacter(c, base)) {
235233
m_errorLength = literal.size();

0 commit comments

Comments
 (0)