Skip to content

Commit

Permalink
error: support printing compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jumanji144 committed Nov 1, 2023
1 parent 5ceb712 commit 1975be8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
14 changes: 3 additions & 11 deletions lib/source/pl/core/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,11 @@ namespace pl::core::err {

auto lines = wolv::util::splitString(location.source->content, "\n");

std::cout << "location.line: " << location.line << std::endl;
std::cout << "location.column: " << location.column << std::endl;
std::cout << "location.source->source: " << location.source->source << std::endl;
std::cout << "location.source->content: " << std::endl;

for (const auto &item: lines) {
std::cout << item << std::endl;
}

if ((location.line - 1) < lines.size()) {
const auto &errorLine = lines[location.line - 1];
const auto lineNumberPrefix = fmt::format("{} | ", location.line);
errorMessage += fmt::format("{}{}", lineNumberPrefix, errorLine);
const auto &errorLine = wolv::util::replaceStrings(lines[location.line - 1], "\r", "");

errorMessage += fmt::format("{}{}\n", lineNumberPrefix, errorLine);

{
const auto descriptionSpacing = std::string(lineNumberPrefix.length() + location.column - 1, ' ');
Expand Down
2 changes: 2 additions & 0 deletions lib/source/pl/core/resolvers.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <pl/core/resolver.hpp>
#include <wolv/io/file.hpp>

#include <iostream>

using namespace pl::core;
using namespace pl::api;
using namespace pl::hlp;
Expand Down
2 changes: 2 additions & 0 deletions lib/source/pl/pattern_language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <wolv/io/file.hpp>
#include <wolv/utils/string.hpp>

#include <iostream>

namespace pl {

PatternLanguage::PatternLanguage(bool addLibStd) : m_internals() {
Expand Down

0 comments on commit 1975be8

Please sign in to comment.