[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Problem generating code from bison
From: |
Manish Katiyar |
Subject: |
Problem generating code from bison |
Date: |
Wed, 31 May 2006 21:34:21 +0530 |
Hello friends,
I downloaded the bison-2.1 and built it on an HPUX-Itanium machine.
Now whenever i try to compile the C file generated from bison I am
getting syntax errors. I am generating with the command "bison -d a.y"
and running it with "cc a.tab.c" ........Is there anything that we
need to specify on Itanium to work???
My .y file looks like this which I downloaded from a site. Please help
/* example.y */
%{
#define YYSTYPE int
%}
%token PLUS MINUS STAR LPAREN RPAREN NUMBER NEWLINE
%left PLUS MINUS
%left STAR
%%
line : /* empty */
| line expr NEWLINE { printf("%d\n", $2); }
expr : LPAREN expr RPAREN { $$ = $2; }
| expr PLUS expr { $$ = $1 + $3; }
| expr MINUS expr { $$ = $1 - $3; }
| expr STAR expr { $$ = $1 * $3; }
| NUMBER { $$ = $1; }
;
%%
int yyerror (char const *msg) {
printf("Error: %s\n", msg);
}
int main() {
printf("%d\n", yyparse());
return 0;
}
The Flex lexer used by this parser looks like this:
/* example.lex */
%{
#include "example.parser.h"
%}
%option noyywrap
%%
[ \t]+ { /* ignore whitespace */ }
"(" { return LPAREN; }
")" { return RPAREN; }
"+" { return PLUS; }
"-" { return MINUS; }
"*" { return STAR; }
\n { return NEWLINE; }
[0-9]+ { yylval = atoi(yytext); return NUMBER; }
. { printf("Invalid character '%s'", yytext); }
%%
The errors which i am getting are
Warning 361: "a.y", line 21 # Value-returning function might end
without executing a return statement.
int yyerror (char const *msg) {
^^^^^^^
Error 419: "a.y", line 30 # 'The' is used as a type, but has not been
defined as a type.
The Flex lexer used by this parser looks like this:
^^^
Error 20: "a.y", line 30 # ';' expected before 'lexer'.
The Flex lexer used by this parser looks like this:
^^^^^
Error 419: "a.y", line 30 # 'lexer' is used as a type, but has not
been defined as a type.
The Flex lexer used by this parser looks like this:
^^^^^
Error 20: "a.y", line 30 # ';' expected before 'by'.
The Flex lexer used by this parser looks like this:
^^
Error 419: "a.y", line 30 # 'by' is used as a type, but has not been
defined as a type.
The Flex lexer used by this parser looks like this:
^^
Error 20: "a.y", line 30 # ';' expected before 'parser'.
The Flex lexer used by this parser looks like this:
^^^^^^
Error 419: "a.y", line 30 # 'parser' is used as a type, but has not
been defined as a type.
The Flex lexer used by this parser looks like this:
--
Thanks & Regards,
********************************************
Manish Katiyar
Ozone 2, SP Infocity (Software Park),
New Survey #208 Manjari Stud Farms Ltd.,
Phursungi Village, Haveli Taluka, Saswad Road,
Hadapsar, Pune - 412308, India
***********************************************
- Problem generating code from bison,
Manish Katiyar <=