error in my flex bison code

Page 1 of 1

0 Replies - 2400 Views - Last Post: 01 November 2007 - 04:37 PM Rate Topic: -----

#1 nakshay09  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 01-November 07

error in my flex bison code

Posted 01 November 2007 - 04:37 PM

hi,

can anyone explain me the error i get in my program
my program:

%{
/***
  test parser for initial batch spreadsheet
***/
#include <stdio.h>

#include "ss.h"

int yylex( void);			   /* to avoid gcc warnings */
extern char *yytext;			/* current text matched by flex */
extern int yy_flex_debug;	   /* flex debug flag */
%}

%union{
  char *string;
  double number;
  Cell cell;
  Range range;
}

%token <string> STRING
%token <number> NUMBER
%token <cell>   CELL
%token <range>  RANGE

%token ABS
%token AVG
%token COPY
%type <n> expr post number assg stmt

%%

stmt:	 /* nothing */
		| stmt '\n'					{ return 0; }
		| stmt CELL '=' expr '\n'
		| stmt CELL '=' STRING '\n'	 {  add_string($4);  }
		| stmt COPY RANGE RANGE '\n'	{  do_copy($3,$4);  }
		| stmt error '\n'			   { yyerrok; }
	   ;

expr:   assg
		{
		  #if DEBUG
			print_list();
		  #endif
		  print_tree( root);
		  putchar( '\n');
		  free_tree( root);
		  root = NULL;
		}
	   ;
assg:   post
		| cell '=' assg
	   ;
		 
post:  primary
	   | ABS  '('  expr ')'	  { add_op( ABS, $3, 0);  }
	   | AVG  '('  expr ')'	  {  $$ = root = add_op( AVG, $3, 0);  }
	  ;
			
primary:  number
		  | cell
		  | '(' expr ')' 
		 ;
		  
number: {			}
	   ;
		
cell:   {			}

	 ;
%%
		 
int main( void)
{
#if YYDEBUG
	yydebug = 0;
#endif  
			
	yy_flex_debug = 0;
		  
	return yyparse();	
}
		  
void yyerror( const char *msg)		  /* called for parser syntax error */
{
	printf( "error: %s\n", msg);
}

int yywrap( void)					   /* called at EOF */
{		
	return 1;  
}




my error is:
Linux:felix$ make
make: *** Warning: File `parse.y' has modification time in the future (2007-11-01 19:19:27 > 2007-11-01 18:34:45.323685)
bison -t -v -d -o parse.c parse.y
parse.y:34: empty rule for typed nonterminal, and no action
parse.y:56: type clash (`n' `') on default action
parse.y:59: type clash (`n' `') on default action
parse.y:64: type clash (`' `n') on default action
make: *** [parse.c] Error 1

please jhelp me out with this

Regards,
Akshay

Is This A Good Question/Topic? 0
  • +

Page 1 of 1