`
chinamming
  • 浏览: 140839 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

windows 下 bison 命令行调用

 
阅读更多

目标:将bison集成到Visual studio中

做法:以cygwin下bison为例。

1.新建一个批处理文件 bison.bat,内如如下:

@set bison_dir="E:/SDK/cygwin/bin"
@set Path=Path;%bison_dir%
@REM bison command line
@REM Usage
@REM bison.bat %grammer_file_name
@REM
@REM bison parameters used in our command line
@REM -l don't generate `#line' directives
@REM --report=all complete report information
@REM --report-file=FILE write report to FILE
@REM --graph[=FILE] output a graph of the automaton
@REM
@REM call bison
@echo ">>>>>> bison parse begin... >>>>>> "
bison.exe -l --report=all --report-file=%1.report %1
@echo "<<<<<< bison parse end >>>>>> "

bison.bat接收一个参数,为bison语法描述文件( *.y )

除了生成源代码文件外,同时会生成最完整报告,包括状态机描述文件,移进规约冲突信息。

2. 以VS2008为例, 选择 “工具”-> “外部工具”,新建外部工具如下:

标题:bison

命令: C:/cygwin/bin/bison.bat

参数:($(ItemPath)

初始目录:$(ItemFileName)

勾选”使用输出窗口“

bison_vc9

3. 打开bison语法文件,选择 “工具”-> ”bison“ 进行调用。

正常情况下你将看到在VS2008 输出窗口中如下打印:

">>>>>> bison parse begin... >>>>>> "

e:/Work/lexertl/examples/example_work_with_bison>bison.exe -l --report=all --report-file="calc++-parser.yy".report "calc++-parser.yy"
"<<<<<< bison parse end >>>>>> "

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics