如何列出lex/yacc或flex/bison模式? [英] How to list lex/yacc or flex/bison patterns?

查看:111
本文介绍了如何列出lex/yacc或flex/bison模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从flex/bison文件中提取所有模式,以便一起查看它们.我对目前适用于这些模式的规则不感兴趣.

I would like to extract all patterns from a flex/bison file to look at them altogether. I am not interested in the rules applying to the patterns for now.

肯定有人已经为此写了一个flex/bison文件吗? :)

Surely someone has written a flex/bison file for this already? :)

推荐答案

如果为它提供-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.)

这篇关于如何列出lex/yacc或flex/bison模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆