Closed DistinctWind closed 1 year ago
按照官方文档,可以使用find_package(FLEX)
和find_package(BISON)
来让cmake寻找系统中已经安装的flex
和bison
阅读随cmake安装的模块FindFLEX.cmake
的源代码发现,该模块也会寻找win_flex
,证实该模块也会寻找Windows下的flex移植版本。
在Windows下,将win_flex
和win_bison
添加到PATH环境变量中,然后发现确实也能找到:
-- Found FLEX: D:/utils/win_flex_bison/win_flex.exe (found version "2.6.4")
-- Found BISON: D:/utils/win_flex_bison/win_bison.exe (found version "3.8.2")
并能正常编译。
在一定程度上解决了跨平台问题。目前的外部工具依赖flex/bison,C++第三方库VCPKG和编译工具集MINGW都有Windows移植版本,并且也能在cmake当中共同合作。
为了生成词法分析器和语法分析器,使用一些外部工具来加速这个过程。
任务:阅读flex和bison的文档,熟悉其使用方法。 额外任务:学习flex和bison如何集成到cmake当中。