Skip to content
Snippets Groups Projects
Gmsh.tab.cpp 377 KiB
Newer Older
      if(flag) yymsg(GERROR, "Unknown color '%s'", yyvsp[0].c);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    ;
    break;}
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#line 3063 "Gmsh.y"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
{
      if(!(pColCat = Get_ColorOptionCategory(yyvsp[-4].c))){
	yymsg(GERROR, "Unknown color option class '%s'", yyvsp[-4].c);
	yyval.u = 0 ;
      }
	if(!(pColOpt =  (unsigned int (*) (int, int, unsigned int))Get_ColorOption(yyvsp[0].c, pColCat))){
	  yymsg(GERROR, "Unknown color option '%s.Color.%s'", yyvsp[-4].c, yyvsp[0].c);
	  yyval.u = 0 ;
	}
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    ;
    break;}
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#line 3082 "Gmsh.y"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
{
      yyval.l = yyvsp[-1].l;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    ;
    break;}
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#line 3086 "Gmsh.y"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
{
      yyval.l = List_Create(256,10,sizeof(unsigned int)) ;
      GmshColorTable *ct = Get_ColorTable((int)yyvsp[-3].d);
	yymsg(GERROR, "View[%d] does not exist", (int)yyvsp[-3].d);
	  List_Add(yyval.l, &ct->table[i]);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    ;
    break;}
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#line 3100 "Gmsh.y"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
{
      yyval.l = List_Create(256,10,sizeof(unsigned int)) ;
      List_Add(yyval.l, &(yyvsp[0].u)) ;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    ;
    break;}
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#line 3105 "Gmsh.y"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
{
      List_Add(yyval.l, &(yyvsp[0].u)) ;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    ;
    break;}
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#line 3112 "Gmsh.y"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
{
      yyval.c = yyvsp[0].c;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    ;
    break;}
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#line 3116 "Gmsh.y"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
{
      yyval.c = (char *)Malloc((strlen(yyvsp[-3].c)+strlen(yyvsp[-1].c)+1)*sizeof(char)) ;
      strcpy(yyval.c, yyvsp[-3].c) ;  
      strcat(yyval.c, yyvsp[-1].c) ;
      Free(yyvsp[-3].c);
      Free(yyvsp[-1].c);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    ;
    break;}
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#line 3124 "Gmsh.y"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
{
      yyval.c = (char *)Malloc((strlen(yyvsp[-1].c)+1)*sizeof(char)) ;
      for(i=strlen(yyvsp[-1].c)-1; i>=0; i--){
	if(yyvsp[-1].c[i] == '.'){
	  strncpy(yyval.c,yyvsp[-1].c,i);
	  yyval.c[i]='\0';
	  break;
	}
      }
      if(i<=0) strcpy(yyval.c,yyvsp[-1].c);
      Free(yyvsp[-1].c);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    ;
    break;}
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#line 3137 "Gmsh.y"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
{
      yyval.c = yyvsp[-1].c;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    ;
    break;}
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#line 3141 "Gmsh.y"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
{
      i = PrintListOfDouble(yyvsp[-3].c,yyvsp[-1].l,tmpstring);
      if(i<0){
	yymsg(GERROR, "Too few arguments in Sprintf");
	yyval.c = yyvsp[-3].c;
      }
      else if(i>0){
	yymsg(GERROR, "Too many arguments (%d) in Sprintf", i);
	yyval.c = yyvsp[-3].c;
      }
      else{
	yyval.c = (char*)Malloc((strlen(tmpstring)+1)*sizeof(char));
	strcpy(yyval.c, tmpstring);
	Free(yyvsp[-3].c);
      List_Delete(yyvsp[-1].l);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    ;
    break;}
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#line 3159 "Gmsh.y"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
{ 
      if(!(pStrCat = Get_StringOptionCategory(yyvsp[-3].c)))
	yymsg(GERROR, "Unknown string option class '%s'", yyvsp[-3].c);
      else{
	if(!(pStrOpt = (char *(*) (int, int, char *))Get_StringOption(yyvsp[-1].c, pStrCat)))
	  yymsg(GERROR, "Unknown string option '%s.%s'", yyvsp[-3].c, yyvsp[-1].c);
	else{
	  str = pStrOpt(0,GMSH_GET,NULL) ;
	  yyval.c = (char*)Malloc((strlen(str)+1)*sizeof(char));
	  strcpy(yyval.c, str);
	}
      }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    ;
    break;}
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#line 3173 "Gmsh.y"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
{ 
      if(!(pStrCat = Get_StringOptionCategory(yyvsp[-6].c)))
	yymsg(GERROR, "Unknown string option class '%s'", yyvsp[-6].c);
      else{
	if(!(pStrOpt = (char *(*) (int, int, char *))Get_StringOption(yyvsp[-1].c, pStrCat)))
	  yymsg(GERROR, "Unknown string option '%s[%d].%s'", yyvsp[-6].c, (int)yyvsp[-4].d, yyvsp[-1].c);
	else{
	  str = pStrOpt((int)yyvsp[-4].d,GMSH_GET,NULL) ;
	  yyval.c = (char*)Malloc((strlen(str)+1)*sizeof(char));
	  strcpy(yyval.c, str);
	}
      }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    ;
    break;}
}
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#line 705 "/usr/share/bison/bison.simple"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#if YYLSP_NEEDED
  yylsp -= yylen;
#endif
      short *yyssp1 = yyss - 1;
      YYFPRINTF (stderr, "state stack now");
      while (yyssp1 != yyssp)
	YYFPRINTF (stderr, " %d", *++yyssp1);
      YYFPRINTF (stderr, "\n");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#if YYLSP_NEEDED
  *++yylsp = yyloc;
#endif
  /* Now `shift' the result of the reduction.  Determine what state
     that goes to, based on the state we popped back to and the rule
     number reduced by.  */
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    yystate = yydefgoto[yyn - YYNTBASE];
/*------------------------------------.
| yyerrlab -- here on detecting error |
`------------------------------------*/
yyerrlab:
  /* If not already recovering from an error, report this error.  */
  if (!yyerrstatus)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

#ifdef YYERROR_VERBOSE
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if (yyn > YYFLAG && yyn < YYLAST)
	  YYSIZE_T yysize = 0;
	  char *yymsg;
	  int yyx, yycount;

	  yycount = 0;
	  /* Start YYX at -YYN if negative to avoid negative indexes in
	     YYCHECK.  */
	  for (yyx = yyn < 0 ? -yyn : 0;
	       yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	    if (yycheck[yyx + yyn] == yyx)
	      yysize += yystrlen (yytname[yyx]) + 15, yycount++;
	  yysize += yystrlen ("parse error, unexpected ") + 1;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	  yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
	  yymsg = (char *) YYSTACK_ALLOC (yysize);
	  if (yymsg != 0)
	      char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	      yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
		  yycount = 0;
		  for (yyx = yyn < 0 ? -yyn : 0;
		       yyx < (int) (sizeof (yytname) / sizeof (char *));
		       yyx++)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
		    if (yycheck[yyx + yyn] == yyx)
			const char *yyq = ! yycount ? ", expecting " : " or ";
			yyp = yystpcpy (yyp, yyq);
			yyp = yystpcpy (yyp, yytname[yyx]);
			yycount++;
	      yyerror (yymsg);
	      YYSTACK_FREE (yymsg);
	    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
/*--------------------------------------------------.
| yyerrlab1 -- error raised explicitly by an action |
`--------------------------------------------------*/
      /* 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;
      YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
		  yychar, yytname[yychar1]));
  /* 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:
#if 0
  /* This is wrong; only states that explicitly want error tokens
     should shift them.  */

  /* If its default is to accept any token, ok.  Otherwise pop it.  */
  yyn = yydefact[yystate];
  if (yyn)
    goto yydefault;
#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;
  yyvsp--;
  yystate = *--yyssp;
#if YYLSP_NEEDED
  yylsp--;
#endif
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  if (yydebug)
    {
      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

/*--------------.
| yyerrhandle.  |
`--------------*/
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;
  YYDPRINTF ((stderr, "Shifting error token, "));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#if YYLSP_NEEDED
  *++yylsp = yylloc;
#endif
/*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here.  |
`-------------------------------------*/
yyacceptlab:
  yyresult = 0;
  goto yyreturn;

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

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
/*---------------------------------------------.
| 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
#line 3188 "Gmsh.y"
  if(!Symbol_L)
    Symbol_L = List_Create(50,10,sizeof(Symbol));
  else
    List_Reset(Symbol_L);
  int i;
  for(i = 0 ; i < List_Nbr(Symbol_L) ; i++)
    List_Delete(((Symbol*)List_Pointer_Fast(Symbol_L,i))->val);
  List_Delete(Symbol_L);
}

int CompareSymbols (const void *a, const void *b){
  return(strcmp(((Symbol*)a)->Name,((Symbol*)b)->Name));
}

int PrintListOfDouble(char *format, List_T *list, char *buffer){
  int i, j, k;
  char tmp1[256], tmp2[256];

  j=0;
  while(format[j]!='%') j++;
  strncpy(buffer, format, j); 
  buffer[j]='\0'; 
  for(i = 0 ; i<List_Nbr(list) ; i++){
    k = j;
    j++;
    if(j<(int)strlen(format)){
      if(format[j]=='%'){
	strcat(buffer, "%");
	j++;
      }
      while(format[j]!='%' && j<(int)strlen(format)) j++;
      if(k != j){
	strncpy(tmp1, &(format[k]),j-k);
	tmp1[j-k]='\0';
	sprintf(tmp2, tmp1, *(double*)List_Pointer(list,i)); 
	strcat(buffer, tmp2);
      }
    }
    else{
      return List_Nbr(list)-i;
      break ;
    }
  }
  if(j != (int)strlen(format))
    return -1;
  return 0;
}
  Msg(GERROR, "'%s', line %d : %s (%s)",yyname,yylineno-1,s,yytext);
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);

  if(type == GERROR) yyerrorstate=1;