且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何列出lex/yacc或flex/bison模式?

更新时间:2021-07-08 00:04:36

如果为它提供-v命令行选项,则bison会将格式正确的语法版本(以及所有状态)输出到带有以下内容的文件中:扩展名.output.您可以使用--report-file=PATH指定要写入的精确文件名,并使用--report=THINGS指定要报告的内容列表.有关详细信息,请参见bison --help.但是afaik,语法总是在冲突列表之后(如果有的话)之后的报告文件的开头附近打印.

If you give it the -v command-line option, bison will output a nicely formatted version of the grammar (and all the states) to a file with extension .output. You can specify the precise file name to write to with --report-file=PATH and a list of things to report on with --report=THINGS; see bison --help for details. But afaik, the grammar is always printed, near the beginning of the report file, just after the list of conflicts, if any.

flex没有等效选项,但是如果指定-T标志(旨在调试flex本身),则flex将转储到stderr模式列表以及其他可能更少的信息.使用. (如果使用开始条件块,输出将有点难以理解,并且其展开的宏可能是您想要的,也可能不是.)

flex does not have an equivalent option, but if you specify the -T flag (intended for debugging flex itself), then flex will dump to stderr a list of the patterns, as well as other information of possibly less use. (The output is a little hard to read if you use start condition blocks, and it has macros expanded, which might or might not be what you're looking for.)