Beispiel #1
0
Datei: main.c Projekt: cls/bohm
/* input and call the parser function.			*/
static void compile(char *file)
{
     printf("\n******** loading file %s ********\n",file);
     yypush_buffer_state(yy_create_buffer( yyin, 16384));
     yyin = fopen(file,"r");
     if (yyin==NULL)
	   printf("Fatal Error: cannot open file %s.\n",file);
     else
	{
	   loading_mode = 1;
	   while ((quit == 0) && (error_detected == false))
	     {
		yyparse();
	     }
	   if (error_detected == false)
	      printf("\n******** %s loaded ********\n",file);
	   else
	      {
		 printf("\n***** loading file %s aborted *****\n",file);
		 error_detected = false;
	      }
	   quit = 0;
	   loading_mode = 0;
	 }
     yypop_buffer_state();
}
Beispiel #2
0
void FidlParser::pop_import()
{
  // std::cout << "Found EOF in include file. Popping state in lexer. \n";
  yypop_buffer_state(lexer_);

  assert(open_files_.size() > 1);
  open_files_.pop_back();
}
Sexp* extract_sexpr(const char* in)
{
  Sexp* ret;
  yy_scan_string(in);
  ret = parse();
  yypop_buffer_state();
  return ret;
}
Beispiel #4
0
/* yylex_destroy is for both reentrant and non-reentrant scanners. */
int yylex_destroy  (void)
{
    
    /* Pop the buffer stack, destroying each element. */
	while(YY_CURRENT_BUFFER){
		yy_delete_buffer(YY_CURRENT_BUFFER  );
		YY_CURRENT_BUFFER_LVALUE = NULL;
		yypop_buffer_state();
	}

	/* Destroy the stack itself. */
	yyfree((yy_buffer_stack) );
	(yy_buffer_stack) = NULL;

    return 0;
}
/* yylex_destroy is for both reentrant and non-reentrant scanners. */
int yylex_destroy  (void)
{
    
    /* Pop the buffer stack, destroying each element. */
	while(YY_CURRENT_BUFFER){
		yy_delete_buffer(YY_CURRENT_BUFFER  );
		YY_CURRENT_BUFFER_LVALUE = NULL;
		yypop_buffer_state();
	}

	/* Destroy the stack itself. */
	yyfree((yy_buffer_stack) );
	(yy_buffer_stack) = NULL;

    /* Reset the globals. This is important in a non-reentrant scanner so the next time
     * yylex() is called, initialization will occur. */
    yy_init_globals( );

    return 0;
}