Hi all,

I'm searching for a solution to my problem with running Lex/Yacc parser generator in Visual Studio 2008.

I have successfully ported my .l and .y code to VS2008 following these steps
- copy bison/yacc version 1.9 and flex version 2.5.35 into the same folder my other codes are.
- in the Solution I add .l .y and compiled version of these files in c (lex.myfile.c and myfile_tab.c).
- I create a new rule in Custom Build Rules in order to compile .l and .y files with the parser generator.

My program does compile. But it's giving some strange behavior from the lex scanner.
I even tried with a very simple example. This error never happened when I run my parser in UNIX or cygwin.

some excerpt from
att1 { return ATT1;}   // ATT1 = 1
att2 { return ATT2;}   // ATT1 = 2

[0-9]+ {
yylval.attval = atoi(yytext);
printf("lex debugging %s %d %d\n", yytext,yylval.attval, INTEGER);
return INTEGER;
%union {
	int attval;
%token <attval> DE TH


		printf("expr: INTEGER %d\n", $1);
		$$ = val($1);  // to create an entry for constant value.
	|	attribute 
		printf("expr: attribute\n");
		$$ = name($1);   // to create an entry for an attribute.
	'(' attribute ')'
		printf("attribute: ( atrribute )\n");
	| ATT1	
	  printf("attribute: ATT1\n");
      $$ = ATT1;
	| ATT2
	  printf("attribute: ATT2 %d  %d\n", $$, ATT2);
      $$ = ATT2;

Example 1, when I parse "att1"

it's giving me a token of "att2" instead (no error).

output from printf

parsing.. "att1"
attribute: ATT2 --> it has got a token of "att2" instead of "att1"

Example 2, when I parse "2"

it's giving me an error

parsing.. "2"
lex debugging 2 2 258 --> until here value and its token are still correct. (INTEGER's token is 258)
1: syntax error at 2 yylval.attval=2
Myparser parse failed

I don't understand at all what's wrong here.
In Unix or cygwin environment, I could even parse much more complex statement like
(log(att1)/(att2-2)) + (att1*5)

Could somebody give me a pointer? Thanks!