help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

memory lost


From: alexandre.gouraud
Subject: memory lost
Date: Mon, 30 Apr 2001 23:30:16 +0200

Hi,

I have a problem with my parser. I am loosing 80 bytes of
memory, and I can't manage to find out where. I have written
some wrappers to trace calls to malloc/calloc/realloc and
free, and everything looks good. I have reduced my problem to
a small file (actually two : one for bison, the other one for
flex), so that you can check if I am accessing things
correctly. I don't think the memory lost is due to flex,
because the amount of free memory doesn't change before and
after each call to yylex.

Thank you for your help.

**********************  BISON file ************************
%pure_parser

%union
{
   int itype;
   char * charPtr;
}

%{
#include <stdio.h>

#define YYDEBUG 1
#define YYERROR_VERBOSE
#define YYPARSE_PARAM parm
#define YYLEX_PARAM parm


int yylex(YYSTYPE *lvalp,char *name);

int yyerror(char *s);


%}

%token <charPtr> SANJAY_TOKEN

%type <charPtr> hostname_group
%type <charPtr> hostname


%%

hostname_group : hostname
   | hostname hostname_group
   | error
      {
         yyerrok;
         yyclearin;
      }
;

hostname :SANJAY_TOKEN
;

%%

int yyerror(char *s)
{
   printf("yyerror: %s\n",s);
   return 0;
}

int mymain(void)
{
   int i;
   char aname[20]="spp.port3..tid1.ans\0";
   /*char aname[]="\0";*/
   stderr=stdout;
   yydebug=1;
   printf ("yyparse answer %d\n",yyparse((void *)aname));
   return 0;
}

******************  END of BISON file  *********************




****************** FLEX file *******************************

%{
#include <stdio.h>
#include "y.tab.h"

#define YY_DECL int yylex(YYSTYPE *lvalp,void *theName)
#define YY_USER_INIT input_buffer=yy_scan_string(theName)
%}

%%

     static YY_BUFFER_STATE input_buffer;


"sanjay"          {lvalp->charPtr=yytext;return SANJAY_TOKEN;}


<<EOF>>           {yy_delete_buffer(input_buffer);fprintf
(stderr,"yylex ends here\n");yy_init=1;yyterminate();}

%%

int yywrap(void)
{
        return 1;
}

*********************** end of flex file *********************






reply via email to

[Prev in Thread] Current Thread [Next in Thread]