Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
297 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...