Hi Dan,
bison is 2.3 build 0009 and bash is 4.2 build 0005. I think bash should have nothing to do with it as I can use those tools even from IBM’s /bin/sh.
Here the calc.y
/* Mini Calculator /
/ calc.y */
%{
#include "heading.h"
int yyerror(char *s);
int yylex(void);
%}
%union{
int int_val;
string* op_val;
}
%start input
%token <int_val> INTEGER_LITERAL
%type <int_val> exp
%left PLUS
%left MULT
%%
input: /* empty */
| exp { cout << "Result: " << $1 << endl; }
;
exp: INTEGER_LITERAL { $$ = $1; }
| exp PLUS exp { $$ = $1 + $3; }
| exp MULT exp { $$ = $1 * $3; }
;
%%
int yyerror(string s)
{
extern int yylineno; // defined and maintained in lex.c
extern char *yytext; // defined and maintained in lex.c
cerr << "ERROR: " << s << " at symbol “” << yytext;
cerr << “” on line " << yylineno << endl;
exit(1);
}
int yyerror(char *s)
{
return yyerror(string(s));
}
Thanks, Manfred