Przeglądaj źródła

refactor & feat: 提取Parser部分

SongZihuan 3 lat temu
rodzic
commit
58f0bb38b0

+ 1 - 0
cmake/export-head.cmake

@@ -18,6 +18,7 @@ endfunction()
 define_export_head(tool-shared tool-static aFunToolExport AFUN_TOOL)
 define_export_head(code-shared code-static aFunCodeExport AFUN_CODE)
 define_export_head(core-shared core-static aFunCoreExport AFUN_CORE)
+define_export_head(parser-shared parser-static aFunParserExport AFUN_PARSER)
 define_export_head(it-shared it-static aFunlangExport AFUN_LANG)
 
 # 两个库需要额外定义

+ 0 - 1
include/code/code-logger.inline.h

@@ -8,5 +8,4 @@ namespace aFuncode {
     }
 }
 
-
 #endif //AFUN_CODE_LOGGER_INLINE_H

+ 5 - 1
include/code/code.h

@@ -29,7 +29,7 @@ namespace aFuncode {
         bool write_v1(FILE *f, bool debug=false) const;
         bool read_v1(FILE *f, bool debug=false);
     };
-    
+
     class AFUN_CODE_EXPORT Code::ByteCode {
         friend class Code;
     public:
@@ -45,6 +45,10 @@ namespace aFuncode {
             block_c = '{',
         } BlockType;
 
+        AFUN_STATIC constexpr const char *E_PREFIX = "$`'";  /* element前缀 */
+        AFUN_STATIC constexpr const char *B_PREFIX = "$`'%^&<?>";  /* block前缀 */
+        AFUN_STATIC constexpr const char *ALL_PREFIX = "$`'%^&<?>";  /* 所有前缀 */
+
         explicit ByteCode(Code &belong, aFuntool::FileLine line);
         ByteCode(Code &belong, const std::string &element, aFuntool::FileLine line, char prefix=aFuntool::NUL);
         ByteCode(Code &belong, BlockType block_type, ByteCode *son, aFuntool::FileLine line, char prefix=aFuntool::NUL);

+ 0 - 2
include/core/aFuncore.h

@@ -9,7 +9,5 @@
 #include "object-value.h"
 #include "core-activation.h"
 #include "core-exception.h"
-#include "reader.h"
-#include "core-parser.h"
 
 #endif //AFUN_AFUNCORE_H

+ 1 - 4
include/core/inter.h

@@ -64,10 +64,7 @@ namespace aFuncore {
             prefix_exec_first = 1,
         } Prefix;
 
-        AFUN_STATIC const int PREFIX_COUNT = 2;
-        AFUN_STATIC constexpr const char *E_PREFIX = "$`'";  /* NOLINT element前缀 */
-        AFUN_STATIC constexpr const char *B_PREFIX = "$`'%^&<?>";  /* NOLINT block前缀 */
-        AFUN_STATIC constexpr const char *ALL_PREFIX = "$`'%^&<?>";  /* NOLINT block前缀 */
+        AFUN_STATIC const int PREFIX_COUNT = 2;  // env 记录的前缀  TODO-szh 取消
 
         explicit Inter(Environment &env_);
         Inter(const Inter &base_inter);

+ 3 - 0
include/interface/init.h

@@ -2,6 +2,7 @@
 #define AFUN_INIT_H
 #include "aFunlangExport.h"
 #include "aFuncore.h"
+#include "aFunparser.h"
 #include "aFuncode.h"
 #include "aFuntool.h"
 
@@ -9,6 +10,7 @@ namespace aFunit {
     struct InitInfo {
         aFuntool::LogFactory &factor;
         aFuntool::Logger &core_logger;
+        aFuntool::Logger &parser_logger;
         aFuntool::Logger &code_logger;
         aFuntool::Logger &sys_logger;
         aFuntool::Logger &afun_logger;
@@ -16,6 +18,7 @@ namespace aFunit {
         AFUN_INLINE InitInfo(aFuntool::LogFactory &factor_,
                              aFuntool::Logger &afun_logger_,
                              aFuntool::Logger &core_logger_,
+                             aFuntool::Logger &parser_logger_,
                              aFuntool::Logger &code_logger_,
                              aFuntool::Logger &sys_logger_);
     };

+ 7 - 5
include/interface/init.inline.h

@@ -5,11 +5,13 @@
 
 namespace aFunit {
     InitInfo::InitInfo(aFuntool::LogFactory &factor_,
-                               aFuntool::Logger &afun_logger_,
-                               aFuntool::Logger &core_logger_,
-                               aFuntool::Logger &code_logger_,
-                               aFuntool::Logger &sys_logger_)
-        : factor{factor_}, core_logger{core_logger_}, code_logger{code_logger_}, sys_logger{sys_logger_}, afun_logger{afun_logger_} {
+                       aFuntool::Logger &afun_logger_,
+                       aFuntool::Logger &core_logger_,
+                       aFuntool::Logger &parser_logger_,
+                       aFuntool::Logger &code_logger_,
+                       aFuntool::Logger &sys_logger_)
+        : factor{factor_}, core_logger{core_logger_}, parser_logger{parser_logger_}, code_logger{code_logger_},
+          sys_logger{sys_logger_}, afun_logger{afun_logger_} {
         aFuntool::aFunAtExit(aFuntool::DlcHandle::dlcExit);
     }
 

+ 3 - 3
include/interface/it-reader.h

@@ -2,11 +2,11 @@
 #define AFUN_IT_READER_H
 #include <functional>
 #include "aFunlangExport.h"
-#include "aFuncore.h"
+#include "aFunparser.h"
 #include "init.h"
 
 namespace aFunit {
-    class AFUN_LANG_EXPORT StringReader : public aFuncore::Reader {
+    class AFUN_LANG_EXPORT StringReader : public aFunparser::Reader {
     public:
         AFUN_INLINE StringReader(std::string str_, const aFuntool::FilePath &path_);
         size_t readText(char *dest, size_t read_len, ReadMode &mode) override;
@@ -16,7 +16,7 @@ namespace aFunit {
         size_t len;
     };
 
-    class AFUN_LANG_EXPORT FileReader : public aFuncore::Reader {
+    class AFUN_LANG_EXPORT FileReader : public aFunparser::Reader {
     public:
         AFUN_INLINE explicit FileReader(const aFuntool::FilePath &path_) noexcept(false);
         size_t readText(char *dest, size_t read_len, ReadMode &mode) override;

+ 8 - 0
include/parser/aFunparser.h

@@ -0,0 +1,8 @@
+#ifndef AFUN_AFUNPARSER_H
+#define AFUN_AFUNPARSER_H
+
+#include "parser-logger.h"
+#include "parser-parser.h"
+#include "parser-reader.h"
+
+#endif //AFUN_AFUNPARSER_H

+ 12 - 0
include/parser/parser-logger.h

@@ -0,0 +1,12 @@
+#ifndef AFUN_PARSER_LOGGER_H
+#define AFUN_PARSER_LOGGER_H
+#include "aFunParserExport.h"
+#include "aFuntool.h"
+
+namespace aFunparser {
+    AFUN_PARSER_EXPORT extern aFuntool::Logger *aFunParserLogger;
+    AFUN_STATIC void setParserLogger(aFuntool::Logger *log);
+}
+
+#include "parser-logger.inline.h"
+#endif //AFUN_PARSER_LOGGER_H

+ 11 - 0
include/parser/parser-logger.inline.h

@@ -0,0 +1,11 @@
+#ifndef AFUN_PARSER_LOGGER_INLINE_H
+#define AFUN_PARSER_LOGGER_INLINE_H
+#include "parser-logger.h"
+
+namespace aFunparser {
+    void setParserLogger(aFuntool::Logger *log) {
+        aFunParserLogger = log;
+    }
+}
+
+#endif //AFUN_PARSER_LOGGER_INLINE_H

+ 8 - 8
include/core/core-parser.h → include/parser/parser-parser.h

@@ -1,12 +1,12 @@
-#ifndef AFUN_CORE_PARSER_H
-#define AFUN_CORE_PARSER_H
-#include "aFunToolExport.h"
-#include "reader.h"
+#ifndef AFUN_PARSER_PARSER_H
+#define AFUN_PARSER_PARSER_H
+#include "aFunParserExport.h"
+#include "parser-reader.h"
 #include "aFuncode.h"
 #include <queue>
 
-namespace aFuncore {
-    class AFUN_CORE_EXPORT Parser {
+namespace aFunparser {
+    class AFUN_PARSER_EXPORT Parser {
     public:
         typedef enum LexicalStatus {
             lex_begin = 0,  // 起始类型
@@ -131,5 +131,5 @@ namespace aFuncore {
 
 }
 
-#include "core-parser.inline.h"
-#endif //AFUN_CORE_PARSER_H
+#include "parser-parser.inline.h"
+#endif //AFUN_PARSER_PARSER_H

+ 5 - 5
include/core/core-parser.inline.h → include/parser/parser-parser.inline.h

@@ -1,8 +1,8 @@
-#ifndef AFUN_CORE_PARSER_INLINE_H
-#define AFUN_CORE_PARSER_INLINE_H
-#include "core-parser.h"
+#ifndef AFUN_PARSER_PARSER_INLINE_H
+#define AFUN_PARSER_PARSER_INLINE_H
+#include "parser-parser.h"
 
-namespace aFuncore {
+namespace aFunparser {
     Parser::Parser(Reader &reader_)
         : reader{reader_},
           lexical{lex_begin, TK_PREFIX, 0, 0, false, false},
@@ -34,4 +34,4 @@ namespace aFuncore {
     }
 }
 
-#endif //AFUN_CORE_PARSER_INLINE_H
+#endif //AFUN_PARSER_PARSER_INLINE_H

+ 7 - 7
include/core/reader.h → include/parser/parser-reader.h

@@ -1,10 +1,10 @@
-#ifndef AFUN_READER_H
-#define AFUN_READER_H
+#ifndef AFUN_PARSER_READER_H
+#define AFUN_PARSER_READER_H
 #include "aFuntool.h"
-#include "aFunCoreExport.h"
+#include "aFunParserExport.h"
 
-namespace aFuncore {
-    class AFUN_CORE_EXPORT Reader {
+namespace aFunparser {
+    class AFUN_PARSER_EXPORT Reader {
     public:
         typedef enum ReadMode {
             read_mode_normal = 0,
@@ -43,6 +43,6 @@ namespace aFuncore {
     };
 }
 
-#include "reader.inline.h"
+#include "parser-reader.inline.h"
 
-#endif //AFUN_READER_H
+#endif //AFUN_PARSER_READER_H

+ 5 - 5
include/core/reader.inline.h → include/parser/parser-reader.inline.h

@@ -1,8 +1,8 @@
-#ifndef AFUN_READER_INLINE_H
-#define AFUN_READER_INLINE_H
-#include "reader.h"
+#ifndef AFUN_PARSER_READER_INLINE_H
+#define AFUN_PARSER_READER_INLINE_H
+#include "parser-reader.h"
 
-namespace aFuncore {
+namespace aFunparser {
     Reader::Reader(aFuntool::FilePath path_, aFuntool::FileLine line_)
             : buf{aFuntool::safeCalloc<char>(DEFAULT_BUF_SIZE + 1)}, buf_size{DEFAULT_BUF_SIZE}, read{buf}, read_end{false},
               read_error{false}, line{line_}, path{std::move(path_)} {
@@ -30,4 +30,4 @@ namespace aFuncore {
     }
 }
 
-#endif //AFUN_READER_INLINE_H
+#endif //AFUN_PARSER_READER_INLINE_H

+ 6 - 2
src/CMakeLists.txt

@@ -1,11 +1,13 @@
 set(build_include_tool ${PROJECT_SOURCE_DIR}/include/tool)
 set(build_include_code ${PROJECT_SOURCE_DIR}/include/code)
 set(build_include_core ${PROJECT_SOURCE_DIR}/include/core)
+set(build_include_parser ${PROJECT_SOURCE_DIR}/include/parser)
 set(build_include_interface ${PROJECT_SOURCE_DIR}/include/interface)
 
 set(install_include_tool ${INSTALL_INCLUDEDIR})
 set(install_include_code ${INSTALL_INCLUDEDIR})
 set(install_include_core ${INSTALL_INCLUDEDIR})
+set(install_include_parser ${INSTALL_INCLUDEDIR})
 set(install_include_interface ${INSTALL_INCLUDEDIR})
 
 set(build_include)
@@ -15,6 +17,7 @@ foreach(dir
         ${build_include_tool}
         ${build_include_code}
         ${build_include_core}
+        ${build_include_parser}
         ${build_include_interface})
     list(APPEND build_include $<BUILD_INTERFACE:${dir}>)
 endforeach()
@@ -23,8 +26,9 @@ set(install_include $<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}>)
 
 add_subdirectory(tool)
 add_subdirectory(code)
-add_subdirectory(core)  # core 依赖 tool
-add_subdirectory(interface)  # interface 依赖 core
+add_subdirectory(core)
+add_subdirectory(parser)
+add_subdirectory(interface)
 
 ## source在子目录中被使用, 为了避免子目录访问到source, 子目录将在此前面被执行
 #file(GLOB source

+ 1 - 2
src/core/core-logger.cpp

@@ -1,5 +1,4 @@
-#include <clocale>
-#include "core-logger.h"
+#include "core-logger.h"
 
 namespace aFuncore {
     aFuntool::Logger *aFunCoreLogger = nullptr;

+ 2 - 2
src/interface/CMakeLists.txt

@@ -37,8 +37,8 @@ endforeach()
 set_target_properties(it-shared PROPERTIES OUTPUT_NAME "aFunit")
 set_target_properties(it-static PROPERTIES OUTPUT_NAME "aFunit-s")
 
-target_link_libraries(it-shared PUBLIC tool-shared code-shared core-shared)
-target_link_libraries(it-static PUBLIC tool-static code-static core-static)
+target_link_libraries(it-shared PUBLIC tool-shared code-shared core-shared parser-shared)
+target_link_libraries(it-static PUBLIC tool-static code-static core-static parser-static)
 
 #install(TARGETS it-shared it-static
 #        EXPORT aFunlang

+ 1 - 0
src/interface/init.cpp

@@ -13,6 +13,7 @@ namespace aFunit {
 
         setAFunLogger(&info->afun_logger);
         aFuncore::setCoreLogger(&info->core_logger);
+        aFunparser::setParserLogger(&info->parser_logger);
         aFuncode::setCodeLogger(&info->code_logger);
         aFuntool::setSysLogger(&info->sys_logger);
 

+ 1 - 1
src/interface/it-reader.cpp → src/interface/reader.cpp

@@ -16,7 +16,7 @@ namespace aFunit {
         return read_len;
     }
 
-    size_t FileReader::readText(char *dest, size_t read_len, aFuncore::Reader::ReadMode &mode) {
+    size_t FileReader::readText(char *dest, size_t read_len, aFunparser::Reader::ReadMode &mode) {
         if (!no_first) {
             no_first = true;
             char ch;

+ 40 - 0
src/parser/CMakeLists.txt

@@ -0,0 +1,40 @@
+file(GLOB source
+        LIST_DIRECTORIES FALSE
+        ${CMAKE_CURRENT_LIST_DIR}/*.cpp)
+
+file(GLOB public_h
+        LIST_DIRECTORIES FALSE
+        RELATIVE "${build_include_parser}"
+        "${build_include_parser}/*.h")
+
+set(public_h_build)
+set(public_h_install)
+
+foreach(h IN LISTS public_h)
+    file(RELATIVE_PATH _path ${CMAKE_CURRENT_LIST_DIR} "${build_include_parser}/${h}")
+    list(APPEND public_h_build   "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/${_path}>")  # 相对路径的转换, 此处只能使用相对路径
+    list(APPEND public_h_install "$<INSTALL_INTERFACE:${install_include_parser}/${h}>")
+endforeach()
+
+add_library(parser-shared SHARED "")
+add_library(parser-static STATIC "")
+
+foreach(tgt parser-shared parser-static)
+    target_sources(${tgt} PRIVATE ${source} PUBLIC ${public_h_build} ${public_h_install})
+    target_include_directories(${tgt} PUBLIC ${build_include} ${install_include})
+    set_target_properties(${tgt} PROPERTIES PUBLIC_HEADER "${public_h_build}")
+    define_filename(${tgt})
+endforeach()
+
+set_target_properties(parser-shared PROPERTIES OUTPUT_NAME "aFunparser")
+set_target_properties(parser-static PROPERTIES OUTPUT_NAME "aFunparser-s")
+
+target_link_libraries(parser-shared PUBLIC tool-shared code-shared)
+target_link_libraries(parser-static PUBLIC tool-static code-static)
+
+#install(TARGETS parser-shared parser-static
+#        EXPORT aFunlang
+#        RUNTIME DESTINATION ${INSTALL_BINDIR} COMPONENT base-runtime
+#        ARCHIVE DESTINATION ${INSTALL_LIBDIR} COMPONENT dev
+#        LIBRARY DESTINATION ${INSTALL_LIBDIR} COMPONENT base-runtime
+#        PUBLIC_HEADER DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT dev)

+ 10 - 10
src/core/lexical.cpp → src/parser/lexical.cpp

@@ -3,9 +3,9 @@
  * 目标: aFunlang词法分析
  */
 #include <cctype>
-#include "core-parser.h"
-#include "core-logger.h"
-#include "inter.h"
+#include "parser-parser.h"
+#include "parser-logger.h"
+#include "aFuncode.h"
 
 #ifndef isascii
 #define isascii(c) (((c) & ~0x7f) == 0)
@@ -14,7 +14,7 @@
 #define isignore(ch) (isascii(ch) && (iscntrl(ch) || isspace(ch) || (ch) == ','))  /* 被忽略的符号 */
 #define iselement(ch) (!isascii(ch) || isgraph(ch))  /* 可以作为element的符号 */
 
-namespace aFuncore {
+namespace aFunparser {
     void Parser::setLexicalLast(LexicalStatus status, TokenType token) {
         lexical.status = status;
         lexical.last = reader.countRead();
@@ -54,7 +54,7 @@ namespace aFuncore {
         if (ch == aFuntool::NUL) {
             setLexicalLast(lex_nul, TK_EOF);
             return FINISH_TOKEN;
-        } else if (strchr(Inter::ALL_PREFIX, ch)) {  /* 属于前缀 */
+        } else if (strchr(aFuncode::Code::ByteCode::ALL_PREFIX, ch)) {  /* 属于前缀 */
             setLexicalLast(lex_prefix, TK_PREFIX);
             return FINISH_TOKEN;
         } else if (strchr("!@#", ch)) {
@@ -69,7 +69,7 @@ namespace aFuncore {
                     lexical.status = lex_prefix_block_c;
                     return CONTINUE_TOKEN;
                 default:
-                    fatalErrorLog(aFunCoreLogger, EXIT_FAILURE, "Switch illegal characters");
+                    fatalErrorLog(aFunParserLogger, EXIT_FAILURE, "Switch illegal characters");
                     pushEvent({ParserEvent::parser_error_unknown, reader.getFileLine(), ""});
                     return ERROR_TOKEN;
             }
@@ -94,7 +94,7 @@ namespace aFuncore {
                     setLexicalLast(lex_rc, TK_RC);
                     return FINISH_TOKEN;
                 default:
-                    fatalErrorLog(aFunCoreLogger, EXIT_FAILURE, "Switch illegal characters");
+                    fatalErrorLog(aFunParserLogger, EXIT_FAILURE, "Switch illegal characters");
                     pushEvent({ParserEvent::parser_error_unknown, reader.getFileLine(), ""});
                     return ERROR_TOKEN;
             }
@@ -137,7 +137,7 @@ namespace aFuncore {
                     setLexicalLast(lex_lc, TK_LC);
                     return FINISH_TOKEN;
                 default:
-                    fatalErrorLog(aFunCoreLogger, EXIT_FAILURE, "Switch illegal characters");
+                    fatalErrorLog(aFunParserLogger, EXIT_FAILURE, "Switch illegal characters");
                     pushEvent({ParserEvent::parser_error_unknown, reader.getFileLine(), ""});
                     return ERROR_TOKEN;
             }
@@ -153,7 +153,7 @@ namespace aFuncore {
                     setLexicalLast(lex_rc, TK_RC);
                     return FINISH_TOKEN;
                 default:
-                    fatalErrorLog(aFunCoreLogger, EXIT_FAILURE, "Switch illegal characters");
+                    fatalErrorLog(aFunParserLogger, EXIT_FAILURE, "Switch illegal characters");
                     pushEvent({ParserEvent::parser_error_unknown, reader.getFileLine(), ""});
                     return ERROR_TOKEN;
             }
@@ -373,7 +373,7 @@ namespace aFuncore {
                     re = doneElementLongEnd(ch);
                     break;
                 default:
-                    fatalErrorLog(aFunCoreLogger, EXIT_FAILURE, "Switch illegal characters");
+                    fatalErrorLog(aFunParserLogger, EXIT_FAILURE, "Switch illegal characters");
                     re = ERROR_TOKEN;
                     break;
             }

+ 5 - 0
src/parser/parser-logger.cpp

@@ -0,0 +1,5 @@
+#include "parser-logger.h"
+
+namespace aFunparser {
+    aFuntool::Logger *aFunParserLogger = nullptr;
+}

+ 4 - 4
src/core/reader.cpp → src/parser/reader.cpp

@@ -1,7 +1,7 @@
-#include "core-logger.h"
-#include "reader.h"
+#include "parser-reader.h"
+#include "parser-logger.h"
 
-namespace aFuncore {
+namespace aFunparser {
     Reader::~Reader() {
         aFuntool::safeFree(buf);
     }
@@ -42,7 +42,7 @@ namespace aFuncore {
 
         if (!aFuntool::isCharUTF8(re)) {
             aFuntool::safeFree(re);
-            errorLog(aFunCoreLogger, "Is not utf-8");
+            errorLog(aFunParserLogger, "Is not utf-8");
             return nullptr;
         }
 

+ 3 - 3
src/core/syntactic.cpp → src/parser/syntactic.cpp

@@ -1,7 +1,7 @@
-#include "core-parser.h"
-#include "core-logger.h"
+#include "parser-parser.h"
+#include "parser-logger.h"
 
-namespace aFuncore {
+namespace aFunparser {
     bool Parser::getToken() {
         if (syntactic.back) {
             syntactic.back = false;

+ 6 - 4
test/src/CMakeLists.txt

@@ -4,7 +4,7 @@ foreach(src IN LISTS src_list)
     cmake_path(GET src STEM file_name)
     add_executable(${file_name})
     target_sources(${file_name} PRIVATE ${src})
-    target_link_libraries(${file_name} PUBLIC tool-static code-static core-static it-static)  # 链接静态库 (导出所有符号)
+    target_link_libraries(${file_name} PUBLIC tool-static code-static core-static parser-static it-static)  # 链接静态库 (导出所有符号)
     set_target_properties(${file_name}
                           PROPERTIES OUTPUT_NAME "test-${file_name}")
     target_compile_definitions(${file_name} PRIVATE IN_CTEST)
@@ -51,9 +51,11 @@ set_test_label(code code-create)
 add_new_test(core-env-var COMMAND "$<TARGET_FILE:core-env-var>")
 add_new_test(core-down-msg COMMAND "$<TARGET_FILE:core-down-msg>")
 add_new_test(core-up-msg COMMAND "$<TARGET_FILE:core-up-msg>")
-add_new_test(core-reader COMMAND "$<TARGET_FILE:core-reader>")
-add_new_test(core-lexical COMMAND "$<TARGET_FILE:core-lexical>")
-set_test_label(core core-env-var core-down-msg core-up-msg core-reader core-lexical)
+set_test_label(core core-env-var core-down-msg core-up-msg)
+
+add_new_test(parser-reader COMMAND "$<TARGET_FILE:parser-reader>")
+add_new_test(parser-lexical COMMAND "$<TARGET_FILE:parser-lexical>")
+set_test_label(parser parser-reader parser-lexical)
 
 add_new_test(it-syntactic COMMAND "$<TARGET_FILE:it-syntactic>")
 add_new_test(it-init COMMAND "$<TARGET_FILE:it-init>")

+ 1 - 1
test/src/it-init.cpp

@@ -5,7 +5,7 @@ int main() {
     auto core_logger = aFuntool::Logger(factor, "aFun-core");
     auto sys_logger = aFuntool::Logger(factor, "aFun-sys");
     auto aFun_logger = aFuntool::Logger(factor, "aFun");
-    auto info = aFunit::InitInfo(factor, aFun_logger, core_logger, core_logger, sys_logger);
+    auto info = aFunit::InitInfo(factor, aFun_logger, core_logger, core_logger, core_logger, sys_logger);
 
     if (!aFunInit(&info)) {
         aFuntool::printf_stderr(0, "aFunlang init error.");

+ 6 - 6
test/src/it-syntactic.cpp

@@ -4,7 +4,7 @@
 const char *str = "{if true [HelloWorld (10)]}\n";
 const char *str2 = "{if true [HelloWorld (10)\n";
 
-class ConsoleReader : public aFuncore::Reader {
+class ConsoleReader : public aFunparser::Reader {
 public:
     size_t STDIN_MAX_SIZE = 1024;
     explicit ConsoleReader(std::function<bool()> interrupt_, const aFuntool::FilePath &path_="console.aun");
@@ -26,7 +26,7 @@ inline ConsoleReader::ConsoleReader(std::function<bool()> interrupt_, const aFun
 }
 
 
-size_t ConsoleReader::readText(char *dest, size_t read_len, aFuncore::Reader::ReadMode &mode) {
+size_t ConsoleReader::readText(char *dest, size_t read_len, aFunparser::Reader::ReadMode &mode) {
     if (index == len) {  // 读取内容
         if (aFuntool::clear_stdin()) {
             mode = read_mode_error;
@@ -90,7 +90,7 @@ int main(int argc, char **) {
 
     {
         auto reader = aFunit::StringReader(str, "str");
-        auto parser = aFuncore::Parser(reader);
+        auto parser = aFunparser::Parser(reader);
         auto code = aFuncode::Code("test.aun");
         bool ret = parser.parserCode(code);
         if (!ret)
@@ -102,7 +102,7 @@ int main(int argc, char **) {
 
     {
         auto reader = aFunit::StringReader(str2, "str2");
-        auto parser = aFuncore::Parser(reader);
+        auto parser = aFunparser::Parser(reader);
         auto code = aFuncode::Code("test2.aun");
         parser.parserCode(code);
 
@@ -122,7 +122,7 @@ int main(int argc, char **) {
         aFuntool::fileClose(file);
 
         auto reader = aFunit::FileReader("test.aun");
-        auto parser = aFuncore::Parser(reader);
+        auto parser = aFunparser::Parser(reader);
         auto code = aFuncode::Code("test.aun");
         bool ret = parser.parserCode(code);
         if (!ret)
@@ -139,7 +139,7 @@ int main(int argc, char **) {
 
     {
         auto reader = ConsoleReader(nothing, "stdin.aun");
-        auto parser = aFuncore::Parser(reader);
+        auto parser = aFunparser::Parser(reader);
         auto code = aFuncode::Code("stdin.aun");
         bool ret = parser.parserCode(code);
 

+ 5 - 5
test/src/core-lexical.cpp → test/src/parser-lexical.cpp

@@ -1,5 +1,5 @@
 #include <cstdio>
-#include "core-parser.h"
+#include "parser-parser.h"
 
 const char *str = "Hello_var\n"
                   "10 20.32 100var\n"
@@ -17,7 +17,7 @@ const char *str = "Hello_var\n"
                   ";= comment\n"
                   ";= var-300\n";
 
-class ReaderString : public aFuncore::Reader {
+class ReaderString : public aFunparser::Reader {
     std::string str;
     size_t index;
     size_t len;
@@ -44,15 +44,15 @@ public:
 
 int main() {
     auto reader = ReaderString(str, "str");
-    auto parser = aFuncore::Parser(reader);
+    auto parser = aFunparser::Parser(reader);
 
-    aFuncore::Parser::TokenType tt;
+    aFunparser::Parser::TokenType tt;
     std::string text;
 
     do {
         tt = parser.getTokenFromLexical(text);
         printf("tt = %d, text = %s\n", tt, text.c_str());
-    } while (tt != aFuncore::Parser::TK_EOF && tt != aFuncore::Parser::TK_ERROR);
+    } while (tt != aFunparser::Parser::TK_EOF && tt != aFunparser::Parser::TK_ERROR);
 
     return 0;
 }

+ 2 - 2
test/src/core-reader.cpp → test/src/parser-reader.cpp

@@ -1,6 +1,6 @@
-#include "reader.h"
+#include "parser-reader.h"
 
-class ReaderText : public aFuncore::Reader {
+class ReaderText : public aFunparser::Reader {
     int count;
 public:
     ReaderText() : Reader{"Test", 0} {

+ 1 - 1
test/src/run-code.cpp

@@ -357,7 +357,7 @@ int main() {
         auto it_logger = aFuntool::Logger(factor, "aFun");
         auto core_logger = aFuntool::Logger(factor, "aFun-core");
         auto sys_logger = aFuntool::Logger(factor, "aFun-sys");
-        auto info = aFunit::InitInfo(factor, core_logger, core_logger, sys_logger, it_logger);
+        auto info = aFunit::InitInfo(factor, core_logger, core_logger, core_logger, sys_logger, it_logger);
 
         if (!aFunInit(&info)) {
             aFuntool::printf_stderr(0, "aFunlang init error.");