Skip to content
Snippets Groups Projects
Gmsh.tab.cpp 404 KiB
Newer Older
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	  yysize += yystrlen ("parse error, unexpected ") + 1;
	  yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
	  yymsg = (char *) YYSTACK_ALLOC (yysize);
	  if (yymsg != 0)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	      char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
	      yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	      if (yycount < 5)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
		  yycount = 0;
		  for (yyx = yyn < 0 ? -yyn : 0;
		       yyx < (int) (sizeof (yytname) / sizeof (char *));
		       yyx++)
		    if (yycheck[yyx + yyn] == yyx)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
			const char *yyq = ! yycount ? ", expecting " : " or ";
			yyp = yystpcpy (yyp, yyq);
			yyp = yystpcpy (yyp, yytname[yyx]);
			yycount++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	      yyerror (yymsg);
	      YYSTACK_FREE (yymsg);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	    yyerror ("parse error; also virtual memory exhausted");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#endif /* defined (YYERROR_VERBOSE) */
	yyerror ("parse error");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  goto yyerrlab1;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

/*--------------------------------------------------.
| yyerrlab1 -- error raised explicitly by an action |
`--------------------------------------------------*/
yyerrlab1:
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      /* If just tried and failed to reuse lookahead token after an
	 error, discard it.  */
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      /* return failure if at end of input */
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	YYABORT;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
		  yychar, yytname[yychar1]));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  /* Else will try to reuse lookahead token after shifting the error
     token.  */
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  yyerrstatus = 3;		/* Each real token shifted decrements this */
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  goto yyerrhandle;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
/*-------------------------------------------------------------------.
| yyerrdefault -- current state does not do anything special for the |
| error token.                                                       |
`-------------------------------------------------------------------*/
yyerrdefault:
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#if 0
  /* This is wrong; only states that explicitly want error tokens
     should shift them.  */
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

  /* If its default is to accept any token, ok.  Otherwise pop it.  */
  yyn = yydefact[yystate];
  if (yyn)
    goto yydefault;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#endif
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
/*---------------------------------------------------------------.
| yyerrpop -- pop the current state because it cannot handle the |
| error token                                                    |
`---------------------------------------------------------------*/
yyerrpop:
  if (yyssp == yyss)
    YYABORT;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  yyvsp--;
  yystate = *--yyssp;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#if YYLSP_NEEDED
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  yylsp--;
#endif
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#if YYDEBUG
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  if (yydebug)
    {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      short *yyssp1 = yyss - 1;
      YYFPRINTF (stderr, "Error: state stack now");
      while (yyssp1 != yyssp)
	YYFPRINTF (stderr, " %d", *++yyssp1);
      YYFPRINTF (stderr, "\n");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
/*--------------.
| yyerrhandle.  |
`--------------*/
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
yyerrhandle:
  yyn = yypact[yystate];
  if (yyn == YYFLAG)
    goto yyerrdefault;

  yyn += YYTERROR;
  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
    goto yyerrdefault;

  yyn = yytable[yyn];
  if (yyn < 0)
    {
      if (yyn == YYFLAG)
	goto yyerrpop;
      yyn = -yyn;
      goto yyreduce;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  else if (yyn == 0)
    goto yyerrpop;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  YYDPRINTF ((stderr, "Shifting error token, "));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#if YYLSP_NEEDED
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  *++yylsp = yylloc;
#endif
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
/*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here.  |
`-------------------------------------*/
yyacceptlab:
  yyresult = 0;
  goto yyreturn;

/*-----------------------------------.
| yyabortlab -- YYABORT comes here.  |
`-----------------------------------*/
yyabortlab:
  yyresult = 1;
  goto yyreturn;

/*---------------------------------------------.
| yyoverflowab -- parser overflow comes here.  |
`---------------------------------------------*/
yyoverflowlab:
  yyerror ("parser stack overflow");
  yyresult = 2;
  /* Fall through.  */

yyreturn:
#ifndef yyoverflow
  if (yyss != yyssa)
    YYSTACK_FREE (yyss);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  return yyresult;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#line 3835 "Gmsh.y"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
void DeleteSymbol(void *a, void *b){
  Symbol *s = (Symbol*)a;
  Free(s->Name);
  List_Delete(s->val);
}

int CompareSymbols (const void *a, const void *b){
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  return(strcmp(((Symbol*)a)->Name, ((Symbol*)b)->Name));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
void InitSymbols(void){
  if(Symbol_T){
    Tree_Action(Symbol_T, DeleteSymbol);
    Tree_Delete(Symbol_T);
  }
  Symbol_T = Tree_Create(sizeof(Symbol), CompareSymbols);
}

int PrintListOfDouble(char *format, List_T *list, char *buffer){
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  int j, k;
  char tmp1[256], tmp2[256];

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  j = 0;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  while(j < (int)strlen(format) && format[j]!='%') j++;
  strncpy(buffer, format, j); 
  buffer[j]='\0'; 
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  for(int i = 0; i < List_Nbr(list); i++){
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    if(j < (int)strlen(format)){
      if(format[j] == '%'){
	strcat(buffer, "%");
	j++;
      }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      while(format[j] != '%' && j < (int)strlen(format)) j++;
      if(k != j){
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	strncpy(tmp1, &(format[k]), j-k);
	tmp1[j-k]='\0';
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	sprintf(tmp2, tmp1, *(double*)List_Pointer(list, i)); 
	strcat(buffer, tmp2);
      }
    }
    else{
      return List_Nbr(list)-i;
    }
  }
  if(j != (int)strlen(format))
    return -1;
  return 0;
}
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  Msg(GERROR, "'%s', line %d : %s (%s)", yyname, yylineno-1, s, yytext);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  yyerrorstate++;
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  char tmp[1024];

  va_start (args, fmt);
  vsprintf (tmp, fmt, args);
  va_end (args);

  Msg(type, "'%s', line %d : %s", yyname, yylineno-1, tmp);

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  if(type == GERROR) yyerrorstate++;