windows下bison安装使用
欢迎转载,转载请标明出处:http://blog.csdn.net/notbaron/article/details/51100524
GNU bison 是属于 GNU 项目的一个语法分析器生成器。Bison 把一个关于“向前查看从左到右 最右”(LALR) 上下文无关文法的描述转化成可以分析该文法的 C 或 C++ 程序。它也可以为二义文法生成 “通用的 从左到右 最右” (GLR)语法分析器。
Bison 基本上与 Yacc 兼容,并且在 Yacc 之上进行了改进。它经常和 Flex (一个自动的词法分析器生成器)一起使用。
下载时候选择“Completepackage exceptsources”,安装路径不要选择默认C:\ProgramFiles\GnuWin32,选择C:\GnuWin32,把C:\Gnuwin32\bin加载到PATH变量。
下载路径:http://gnuwin32.sourceforge.net/packages/bison.htm
GnuWin provides ports of tools with a GNU or similar open source license, to modernMS-Windows (Microsoft Windows 2000 / XP / 2003 / Vista / 2008 / 7)
安装完毕后执行
>bison–help
Usage: bison [OPTION]... FILE
Generate LALR(1) and GLR parsers.
Mandatory arguments to long options are mandatory for short optionstoo.
The same is true for optional arguments.
Operation modes:
-h, --help display this help and exit
-V, --version output version information andexit
--print-localedir output directory containinglocale-dependent data
--print-datadir output directory containing skeletonsand XSLT
-y, --yacc emulate POSIX Yacc
-W,--warnings=[CATEGORY] report thewarnings falling in CATEGORY
Parser:
-L, --language=LANGUAGE specify the output programming language
(this is an experimental feature)
-S, --skeleton=FILE specify the skeleton to use
-t, --debug instrument the parser fordebugging
--locations enable locations computation
-p,--name-prefix=PREFIX prepend PREFIX tothe external symbols
-l, --no-lines don't generate `#line' directives
-k, --token-table include a table of token names
Output:
--defines[=FILE] also produce a header file
-d likewise but cannotspecify FILE (for POSIX Yacc)
-r, --report=THINGS also produce details on the automaton
--report-file=FILE write report to FILE
-v, --verbose same as `--report=state'
-b,--file-prefix=PREFIX specify a PREFIXfor output files
-o, --output=FILE leave output to FILE
-g, --graph[=FILE] also output a graph of the automaton
-x, --xml[=FILE] also output an XML report of the automaton
(the XML schema is experimental)
Warning categories include:
`midrule-values' unset or unusedmidrule values
`yacc' incompatibilities with POSIX YACC
`all' all the warnings
`no-CATEGORY' turn off warnings in CATEGORY
`none' turn off all the warnings
`error' treat warnings as errors
THINGS is a list of comma separated words that can include:
`state' describe the states
`itemset' complete the core item sets with theirclosure
`lookahead' explicitly associate lookahead tokens toitems
`solved' describe shift/reduce conflicts solving
`all' include all the above information
`none' disable the report
Report bugs to <[email protected]>.