help-bison
[Top][All Lists]
Advanced

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

Acces violation in re-entrant parser.


From: Toto from_moon
Subject: Acces violation in re-entrant parser.
Date: Wed, 03 May 2006 14:58:27 +0200


Hello,
I have made a non re-entrant parser succesfully with bison 1.875 and flex 2.5.4a to parse user-defined formulas and retrieve the result. I have tried afterwards to do the same with re-entrants options ("%pure_parser" in bison and "%option reentrant stack" in flex), with the help of bison 1.875 and flex 2.5.33. Flex file l.yy.c was generated under linux, and put together with other bison files under windows XP.
I have modified the yyparse and yylex functions like this :
 int yyparse (void *YYPARSE_PARAM, void *TabSymbols);
 int yylex (YYSTYPE * yylval_param ,yyscan_t yyscanner, void * TabSymbols);

The parser works well in interactive mode when yyin = stdin, but when I use yy_scan_string the program hangs up or crashes on an access violation on the following line
defined in yylex :
 *yy_cp = yyg->yy_hold_char;
while yy_scan_string is invoked like this :
  buffer = yy_scan_string(f->formula, scanner);
f->formula is the formula string to parse.

I have tested this with MinGW (gcc for windows) and Visual C++ 6.0

I have no idea of what is wrong so I was wondering if you could give me some highlights to go on.
Thanks you in advance for your help.
Philippe.
___________________

Call function code :

double ParserCall(struct FStruct *f)
{
  int i;
  struct symtab *sp;
  int okflag;
  YY_BUFFER_STATE buffer;
  void *scanner;
  struct symtab tab[NSYMS];

  for (i=0; i < NSYMS; i++)
                tab[i].name = NULL;

  for (i=0; i < NSYMS; i++)
           if (strcmp(f->name[i],"")) {
                   addvar(f->name[i], f->value[i], tab);
           }

  addfunc1("sqrt", sqrt, 1, tab);
  addfunc1("exp", exp, 1, tab);
  addfunc1("log", log, 1, tab);
  addfunc2("min", min_, 2, tab);
  addfunc2("max", max_, 2, tab);

  yylex_init(&scanner);
  buffer = yy_scan_string(f->formula, scanner);

  okflag = yyparse((void *) &tab, (void *) &tab);
  yy_delete_buffer(buffer, scanner);

  if (okflag != 0)
       return 0.0;
  else {
       sp = symlook("result", tab);
       return sp->value;
  }

  yylex_destroy(scanner);
  free(sp);
  return 0.0;
}






reply via email to

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