[Feat] 模块系统支持,使用 import x.x.x导入
[Fix] Context内部辅助函数修改, getStructName .... [Feat] 增加字符串下标获取操作,和修改字符操作,实现使用了第四点的函数 [Impl] FString添加新方法 getRealChar, realReplace [Fun] 在utf8_iterator中辱骂了C++
This commit is contained in:
31
src/main.cpp
31
src/main.cpp
@@ -36,36 +36,12 @@ This software is licensed under the MIT License. See LICENSE.txt for details.
|
||||
#include <Parser/parser.hpp>
|
||||
#include <Evaluator/evaluator.hpp>
|
||||
#include <Utils/AstPrinter.hpp>
|
||||
#include <Utils/utils.hpp>
|
||||
#include <Error/errorLog.hpp>
|
||||
|
||||
static size_t addressableErrorCount = 0;
|
||||
static size_t unaddressableErrorCount = 0;
|
||||
|
||||
std::vector<FString> splitSource(FString source)
|
||||
{
|
||||
UTF8Iterator it(source);
|
||||
std::vector<FString> lines;
|
||||
FString currentLine;
|
||||
while (!it.isEnd())
|
||||
{
|
||||
UTF8Char c = *it;
|
||||
if (c == U'\n')
|
||||
{
|
||||
lines.push_back(currentLine);
|
||||
currentLine = FString(u8"");
|
||||
}
|
||||
else
|
||||
{
|
||||
currentLine += c.getString();
|
||||
}
|
||||
++it;
|
||||
}
|
||||
if (!currentLine.empty())
|
||||
{
|
||||
lines.push_back(currentLine);
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
@@ -119,7 +95,7 @@ int main(int argc, char **argv)
|
||||
Fig::Parser parser(lexer);
|
||||
std::vector<Fig::Ast::AstBase> asts;
|
||||
|
||||
std::vector<FString> sourceLines = splitSource(Fig::FString(source));
|
||||
std::vector<FString> sourceLines = Fig::Utils::splitSource(Fig::FString(source));
|
||||
|
||||
try
|
||||
{
|
||||
@@ -151,8 +127,11 @@ int main(int argc, char **argv)
|
||||
// }
|
||||
|
||||
Fig::Evaluator evaluator;
|
||||
|
||||
evaluator.SetSourcePath(sourcePath);
|
||||
evaluator.CreateGlobalContext();
|
||||
evaluator.RegisterBuiltins();
|
||||
|
||||
try
|
||||
{
|
||||
evaluator.Run(asts);
|
||||
|
||||
Reference in New Issue
Block a user