2012-01-12 152 views
1

不幸的是我必須解析一種語言(JScript)。我開始研究如何使用Flex,知道Qt提供了一個稱爲QLALR的有用工具來生成解析器。 在\ util \ qlalr \ examples \ qparser中我找到了一個非常有趣的例子,它集成了flex生成的掃描器和qlalr生成的解析器。此外,從我的理解(但它不可能是真實的......)該示例引入了一個有用的QParser接口,以避免重寫解析函數。爲了編譯它,我必須從http://sourceforge.net/projects/gnuwin32/files/flex/2.5.4a-1/flex-2.5.4a-1-lib.zip/download下載一個用於windows的unistd.h。它位於目錄include中。在任何情況下,它無非是:QLALR - QParser示例在Visual Studio 2008啓動時崩潰

/* 

This file is part of the Mingw32 package. 
* 
unistd.h maps (roughly) to io.h 
*/ 
#ifndef _STRICT_ANSI_ 

#include <io.h> 
#include <process.h> 

#endif 

使用這個文件我能夠編譯qparser例子,但是當我運行它,我進入主功能與錯誤消息之前得到一個崩潰:程序「[3736 ] qparser.exe:Native'已退出代碼2(0x2)。

我也越來越以下警告消息:

1>lex.calc.c(903) : warning C4003: not enough actual parameters for macro 'calcwrap' 
1>lex.calc.c(1056) : warning C4018: '<' : signed/unsigned mismatch 
1>lex.calc.c(1238) : warning C4003: not enough actual parameters for macro 'calcwrap' 
1>lex.calc.c(1402) : warning C4996: 'isatty': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _isatty. See online help for details. 
1> c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\io.h(312) : see declaration of 'isatty' 
1>lex.calc.c(1402) : warning C4996: 'fileno': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fileno. See online help for details. 
1> c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\stdio.h(722) : see declaration of 'fileno' 
1>Linking... 
1>LINK : debug 
qparser.exe not found or not built by the last incremental link; performing full link 

我使用Visual Studio 2008在Windows 7和Qt 4.8.0從同一個包在那裏我得到QLALR編譯。

有些建議? 謝謝

回答

1

好吧,我自己解決了這個問題。 問題是提供的.pro沒有包含win32-msvc2008:CONFIG + = console指令。 我還建議你在calc.l的開頭添加一個%選項nounistd和一個#include以便使用缺省include目錄中提供的atty函數。