实现 12.4 词法:25 关键字、小写折叠、TIME 字面量、lex error。

- Lexer.h/cpp:关键字表(大小写不敏感折小写)、(* *) 注释不嵌套、整数/T# 段式字面量、最长匹配符号
- token 带 source_file + 行列(起始位置,修了消费后行列的偏差)
- lexer_test:75 断言(line1 三文件 token 流 21/34/27、大小写、符号、注释、行列、5 类负例)
- Doc/compiler/词法.md:设计文档 + 执行计划
This commit is contained in:
2026-08-21 10:51:45 +08:00
parent 9a07f938f9
commit d4e2c1ae7c
6 changed files with 786 additions and 2 deletions
+11
View File
@@ -23,3 +23,14 @@ target_compile_definitions(compiler_test PRIVATE
add_test(NAME compiler_toml
COMMAND compiler_test)
# 词法测试:token 流 + 负例(REPO_ROOT 注入源目录绝对路径)
add_executable(lexer_test
./src/lexer_test.cpp)
target_link_libraries(lexer_test PRIVATE compiler)
target_compile_definitions(lexer_test PRIVATE
REPO_ROOT="${CMAKE_SOURCE_DIR}")
add_test(NAME lexer_tokens
COMMAND lexer_test)