1
votes

Learning lex yacc for first time. but no code in bison is running ERROR: C:\GnuWin32\bin\bison.exe: m4: Invalid argument I reinstalled bison checked the path but still the error is not going. Something wrong with m4 file

PS C:\Users\Vishwajeet\Desktop\lab\Compiler\D2> bison -dy gm2.y conflicts: 1 shift/reduce, 1 reduce/reduce C:\GnuWin32\bin\bison.exe: m4: Invalid argument

path: C:\GnuWin32\bin path without space

%{
   #include<stdio.h>
   #include<stdlib.h>
   int yylex();
%}

%token A B C NL

%%

stmt: S NL  { printf("valid string\n");
              exit(0); }
;
S: X Y | W
;
X: A X B |
;
Y: C Y |
;
W: A W C | Z
;
Z: B Z |
;
%%

int yyerror(char *msg)
 {strong text
  printf("invalid string\n");
  exit(0);
 }
1
What's the full command line you use to run bison? (please edit it into to your question. Be precise; copy and paste from your terminal. Or from your build log, if you're using some kind of build tool/IDE.)rici
(This problem usually has to do with spaces in filepaths, by the way.)rici
Bison is installed on path without space C:\GnuWin32\bin.Mohit Patil
there is also this: planet.mysql.com/entry/?id=31873rici
I don't know a solution, but I had the same problem and running the exact command in a make file, e.g. calc.tab.c calc.tab.h: calc.y bison -t -v -d calc.y produces no error for meDoot

1 Answers

-1
votes

Most likely then, you have another m4 in your path environment variable before the gnuwin32 one that accompanies bison. Check this carefully. You can set the path C:\GnuWin32\bin at the top of the environment path variable list. Just move up this path on the top