- Parser.h/cpp:POU 外壳(PROGRAM/FUNCTION/FUNCTION_BLOCK)、变量段、语句(赋值/IF/WHILE/FB 调用)、表达式优先级爬升(NOT/AND/OR 短路/比较/算术/函数调用/负号) - Unit 结构:顶层 VAR_GLOBAL 段(GVL 文件形态)+ POU 列表 - 拒绝:VAR_IN_OUT/REF/CLASS/ANY 等保留名、链式比较、FB 字段赋值、顶层非 GVL 段 - THEN/DO 补入关键字表(12.5 修订,同步 12.1 与词法文档) - parser_test:98 断言(line1 三文件 AST、FUNCTION 调用、IF/WHILE/TON、9 类负例),ctest 6/6
24 lines
781 B
CMake
24 lines
781 B
CMake
# CMake最低版本
|
|
cmake_minimum_required(VERSION 3.21)
|
|
|
|
# 工程名、版本号、工程描述
|
|
project(Compiler
|
|
VERSION 0.1
|
|
DESCRIPTION "ST / toml 编译器")
|
|
|
|
# 词法、语法、符号表、类型检查、codegen、链接都留在 compiler 一个库里
|
|
add_library(compiler STATIC
|
|
./src/Lexer.cpp
|
|
./src/Project.cpp
|
|
./src/Parser.cpp)
|
|
|
|
target_include_directories(compiler PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
|
target_include_directories(compiler PRIVATE ${CMAKE_SOURCE_DIR}/third_party/tomlplusplus/include)
|
|
target_link_libraries(compiler PUBLIC isa)
|
|
|
|
# 可执行入口:STCompiler <project.toml> -o <name>.stb
|
|
add_executable(STCompiler
|
|
./src/main.cpp)
|
|
|
|
target_link_libraries(STCompiler PRIVATE compiler)
|