forked from PuqiAR/Fig-TreeWalker
[VER] 0.4.0-alpha
[Fix] 修复恶性Bug: Parser: parseExpression没有正确解析二元表达式,没有用到 right binding power的问题,表现在生成类似 a * b * c时,结果为 a * (b * c) 的Bug [Impl][Fix] 修复跨文件(如import)报错信息错误的问题,现在Ast跟踪保存文件信息,报错统一从Error父类获取 [...] 忘了,好困不管了
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <format>
|
||||
#include <source_location>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Fig
|
||||
{
|
||||
@@ -16,8 +17,10 @@ namespace Fig
|
||||
explicit AddressableError(FString _msg,
|
||||
size_t _line,
|
||||
size_t _column,
|
||||
FString _sourcePath,
|
||||
std::vector<FString> _sourceLines,
|
||||
std::source_location loc = std::source_location::current()) :
|
||||
src_loc(loc), line(_line), column(_column)
|
||||
src_loc(loc), line(_line), column(_column), sourcePath(std::move(_sourcePath)), sourceLines(std::move(_sourceLines))
|
||||
{
|
||||
message = _msg;
|
||||
}
|
||||
@@ -33,9 +36,11 @@ namespace Fig
|
||||
}
|
||||
std::source_location src_loc;
|
||||
|
||||
size_t getLine() const { return line; }
|
||||
size_t getColumn() const { return column; }
|
||||
virtual size_t getLine() const { return line; }
|
||||
virtual size_t getColumn() const { return column; }
|
||||
FString getMessage() const { return message; }
|
||||
FString getSourcePath() const { return sourcePath; }
|
||||
std::vector<FString> getSourceLines() const { return sourceLines; }
|
||||
|
||||
virtual FString getErrorType() const
|
||||
{
|
||||
@@ -45,6 +50,9 @@ namespace Fig
|
||||
protected:
|
||||
size_t line, column;
|
||||
FString message;
|
||||
|
||||
FString sourcePath;
|
||||
std::vector<FString> sourceLines;
|
||||
};
|
||||
|
||||
class UnaddressableError : public std::exception
|
||||
@@ -84,14 +92,6 @@ namespace Fig
|
||||
public:
|
||||
using AddressableError::AddressableError;
|
||||
|
||||
explicit SyntaxError(FString _msg,
|
||||
size_t _line,
|
||||
size_t _column,
|
||||
std::source_location loc = std::source_location::current()) :
|
||||
AddressableError(_msg, _line, _column, loc)
|
||||
{
|
||||
}
|
||||
|
||||
virtual FString toString() const override
|
||||
{
|
||||
std::string msg = std::format("[SyntaxError] {} in [{}] {}", this->message.toBasicString(), this->src_loc.file_name(), this->src_loc.function_name());
|
||||
|
||||
Reference in New Issue
Block a user