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
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.)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…