QLALR - QParser示例在Visual Studio 2008上启动时崩溃

时间:2012-01-12 17:37:45

标签: visual-studio qt flex-lexer

不幸的是我必须解析一种语言(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下载一个unistd.h for windows。它在目录include中。无论如何,它只不过是:

/*

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示例,但是当我运行它时,我在进入main函数之前遇到了一个崩溃错误消息:程序'[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

我正在使用Windows 7上的Visual Studio 2008和从我获得QLALR的同一个软件包编译的Qt 4.8.0。

一些建议? 感谢

1 个答案:

答案 0 :(得分:1)

好的,我自己解决了这个问题。 问题是提供的.pro没有包含win32-msvc2008:CONFIG + = console指令。 我建议您在calc.l的开头添加%选项nounistd和#include,以便使用默认包含目录中提供的atty函数。