yoyo
yoyo

Reputation: 1133

Is there a tool to make a c compiler in win7 with yacc and lex?

The only tool is found is this Parser Generator:

Operating System:   Windows 95 / 98 / ME / NT / 2000 / XP

But seems it's not supporting win7,when I try to build for Visual C++(32 bit), got this error:

yyaslvar.c
C:\Program Files\Parser Generator 2\Cpp\Source\yyaslvar.c(35) : error C2099: initializer is not a constant
C:\Program Files\Parser Generator 2\Cpp\Source\yyaslvar.c(36) : error C2099: initializer is not a constant
C:\Program Files\Parser Generator 2\Cpp\Source\yyaslvar.c(37) : error C2099: initializer is not a constant

FILE YYFAR *YYNEAR YYDCDECL yyin = stdin;
FILE YYFAR *YYNEAR YYDCDECL yyout = stdout;
FILE YYFAR *YYNEAR YYDCDECL yylexererr = stderr;

I'm using Visual Studio 2010 Express.

Upvotes: 0

Views: 739

Answers (3)

paulsm4
paulsm4

Reputation: 121699

The problem has nothing to do with Win7 per se, and everything to do with (stricter!) ANSI C standards. The C compiler simply won't let you assign a macro (like "stdin" or "stdout") to a "non-automatic variable":

http://msdn.microsoft.com/en-us/library/t801az8a%28VS.80%29.aspx

Here's one workaround:

http://coding.derkeiler.com/Archive/C_CPP/comp.lang.c/2009-10/msg00982.html

stdin and stdout need not be constants, so you can't use them to initalise static or global variables. Do the assignments in an initialisation function instead.

Moreover, this link might get you pointed in the right direction:

http://msdn.microsoft.com/en-us/library/aa730877%28VS.80%29.aspx

'Hope that helps

Upvotes: 0

casablanca
casablanca

Reputation: 70701

I don't know about VS2010, but I've used this Win32 port of Lex/Yacc (Flex/Bison) on VS2005 without problems: http://userpages.monmouth.com/~wstreett/lex-yacc/lex-yacc.html

Also, your error is due to the fact that VC++ actually defines stdin, stdout etc. as macros which expand to function calls that return a FILE *. Clearly, these are not compile-time constants, which is what the error says.

Upvotes: 1

pyfunc
pyfunc

Reputation: 66729

Not so easy with windows. If you are ready to shell out some money , then you can use MKS lex and Yacc toolkit

Upvotes: 0

Related Questions