Skip to content

Commit

Permalink
pipeline: small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jumanji144 committed Nov 4, 2023
1 parent 1975be8 commit fd3618b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions lib/source/pl/core/lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ std::optional<Token> Lexer::parseStringLiteral() {
m_cursor++;
while(m_sourceCode[m_cursor] != '\"') {

if(peek() == '\n') {
error("Unexpected newline in string literal");
return std::nullopt;
}

auto character = parseCharacter();

if(character.has_value()) {
Expand Down
7 changes: 4 additions & 3 deletions lib/source/pl/core/preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ namespace pl::core {
Location start = location();
u32 depth = 1;
while(peek() != 0 && depth > 0) {
if(m_code.substr(m_offset, 6) == "#endif") {
if(m_code.substr(m_offset, 6) == "#endif" && !m_inString && m_startOfLine) {
m_offset += 6;
depth--;
}
Expand Down Expand Up @@ -356,7 +356,7 @@ namespace pl::core {

if (this->m_pragmaHandlers.contains(type)) {
if (!this->m_pragmaHandlers[type](runtimeRef, value))
error_at(Location { m_source, 0, line },
error_at(Location { m_source, line, 0 },
"Value '{}' cannot be used with the '{}' pragma directive.", value, type);
}
}
Expand Down Expand Up @@ -388,7 +388,8 @@ namespace pl::core {
}

Location Preprocessor::location() {
return { m_source, m_lineNumber, (u32) (m_offset - m_lineBeginOffset) };
u32 column = (u32) (m_offset - m_lineBeginOffset);
return { m_source, m_lineNumber, column };
}

void Preprocessor::registerDirectiveHandler(const std::string& name, auto memberFunction) {
Expand Down

0 comments on commit fd3618b

Please sign in to comment.