Skip to content
Snippets Groups Projects
Gmsh.tab.cpp 280 KiB
Newer Older
#line 3106 "Gmsh.y"
    {
      for(int i = 0; i < List_Nbr((yyvsp[0].l)); i++){
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	double d;
	List_Read((yyvsp[0].l), i, &d);
	List_Add((yyval.l), &d);
      }
      List_Delete((yyvsp[0].l));
    ;}
    break;

  case 313:
#line 3119 "Gmsh.y"
    {
      (yyval.u) = CTX.PACK_COLOR((int)(yyvsp[-7].d), (int)(yyvsp[-5].d), (int)(yyvsp[-3].d), (int)(yyvsp[-1].d));
    ;}
    break;

  case 314:
#line 3123 "Gmsh.y"
    {
      (yyval.u) = CTX.PACK_COLOR((int)(yyvsp[-5].d), (int)(yyvsp[-3].d), (int)(yyvsp[-1].d), 255);
    ;}
    break;

  case 315:
#line 3135 "Gmsh.y"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      int flag;
      (yyval.u) = Get_ColorForString(ColorString, -1, (yyvsp[0].c), &flag);
      if(flag) yymsg(GERROR, "Unknown color '%s'", (yyvsp[0].c));
      Free((yyvsp[0].c));
    ;}
    break;

  case 316:
#line 3142 "Gmsh.y"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      unsigned int (*pColOpt)(int num, int action, unsigned int value);
      StringXColor *pColCat;
      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;
	  (yyval.u) = pColOpt(0, GMSH_GET, 0);
      Free((yyvsp[-4].c)); Free((yyvsp[0].c));
    ;}
    break;

  case 317:
#line 3164 "Gmsh.y"
    {
      (yyval.l) = (yyvsp[-1].l);
    ;}
    break;

  case 318:
#line 3168 "Gmsh.y"
    {
      (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));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	for(int i = 0; i < ct->size; i++) 
	  List_Add((yyval.l), &ct->table[i]);
      Free((yyvsp[-5].c));
    ;}
    break;

  case 319:
#line 3183 "Gmsh.y"
    {
      (yyval.l) = List_Create(256, 10, sizeof(unsigned int));
      List_Add((yyval.l), &((yyvsp[0].u)));
    ;}
    break;

  case 320:
#line 3188 "Gmsh.y"
    {
      List_Add((yyval.l), &((yyvsp[0].u)));
    ;}
    break;

  case 321:
#line 3195 "Gmsh.y"
    {
      (yyval.c) = (yyvsp[0].c);
    ;}
    break;

  case 322:
#line 3199 "Gmsh.y"
    {
      (yyval.c) = (char *)Malloc(32*sizeof(char));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      time_t now;
      time(&now);
      strcpy((yyval.c), ctime(&now));
      (yyval.c)[strlen((yyval.c)) - 1] = '\0';
    ;}
    break;

  case 323:
#line 3207 "Gmsh.y"
    {
      (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));
    ;}
    break;

  case 324:
#line 3215 "Gmsh.y"
    {
      (yyval.c) = (char *)Malloc((strlen((yyvsp[-1].c))+1)*sizeof(char));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      int i;
      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';
      if(i <= 0) strcpy((yyval.c), (yyvsp[-1].c));
      Free((yyvsp[-1].c));
    ;}
    break;

  case 325:
#line 3229 "Gmsh.y"
    {
      (yyval.c) = (char *)Malloc((strlen((yyvsp[-1].c))+1)*sizeof(char));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      int i;
      for(i = strlen((yyvsp[-1].c))-1; i >= 0; i--){
	if((yyvsp[-1].c)[i] == '/' || (yyvsp[-1].c)[i] == '\\')
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	  break;
      }
      if(i <= 0)
	strcpy((yyval.c), (yyvsp[-1].c));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else
	strcpy((yyval.c), &(yyvsp[-1].c)[i+1]);
      Free((yyvsp[-1].c));
    ;}
    break;

  case 326:
#line 3243 "Gmsh.y"
    {
      (yyval.c) = (yyvsp[-1].c);
    ;}
    break;

  case 327:
#line 3247 "Gmsh.y"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      char tmpstring[1024];
      int i = PrintListOfDouble((yyvsp[-3].c), (yyvsp[-1].l), tmpstring);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if(i < 0){
	yymsg(GERROR, "Too few arguments in Sprintf");
	(yyval.c) = (yyvsp[-3].c);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(i > 0){
	yymsg(GERROR, "%d extra argument%s in Sprintf", i, (i>1)?"s":"");
	(yyval.c) = (yyvsp[-3].c);
	(yyval.c) = (char*)Malloc((strlen(tmpstring)+1)*sizeof(char));
	strcpy((yyval.c), tmpstring);
	Free((yyvsp[-3].c));
      }
      List_Delete((yyvsp[-1].l));
    ;}
    break;

  case 328:
#line 3266 "Gmsh.y"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      char* (*pStrOpt)(int num, int action, char *value);
      StringXString *pStrCat;
      if(!(pStrCat = Get_StringOptionCategory((yyvsp[-3].c)))){
	yymsg(GERROR, "Unknown string option class '%s'", (yyvsp[-3].c));
	(yyval.c) = (char*)Malloc(sizeof(char));
	(yyval.c)[0] = '\0';
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      }
	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));
	  (yyval.c) = (char*)Malloc(sizeof(char));
	  (yyval.c)[0] = '\0';
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	}
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	  char *str = pStrOpt(0, GMSH_GET, NULL);
	  (yyval.c) = (char*)Malloc((strlen(str)+1)*sizeof(char));
	  strcpy((yyval.c), str);
#line 3288 "Gmsh.y"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      char* (*pStrOpt)(int num, int action, char *value);
      StringXString *pStrCat;
      if(!(pStrCat = Get_StringOptionCategory((yyvsp[-6].c)))){
	yymsg(GERROR, "Unknown string option class '%s'", (yyvsp[-6].c));
	(yyval.c) = (char*)Malloc(sizeof(char));
	(yyval.c)[0] = '\0';
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      }
	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));
	  (yyval.c) = (char*)Malloc(sizeof(char));
	  (yyval.c)[0] = '\0';
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	}
	  char *str = pStrOpt((int)(yyvsp[-4].d), GMSH_GET, NULL);
	  (yyval.c) = (char*)Malloc((strlen(str)+1)*sizeof(char));
	  strcpy((yyval.c), str);
    ;}
    break;


    }

/* Line 1037 of yacc.c.  */
#line 7244 "Gmsh.tab.cpp"

  YY_STACK_PRINT (yyss, yyssp);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

  /* 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.  */
  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
    yystate = yydefgoto[yyn - YYNTOKENS];
/*------------------------------------.
| yyerrlab -- here on detecting error |
`------------------------------------*/
yyerrlab:
  /* If not already recovering from an error, report this error.  */
  if (!yyerrstatus)
#if YYERROR_VERBOSE
      if (YYPACT_NINF < yyn && yyn < YYLAST)
	  YYSIZE_T yysize = 0;
	  int yytype = YYTRANSLATE (yychar);
	  const char* yyprefix;
	  char *yymsg;
	  int yyx;

	  /* Start YYX at -YYN if negative to avoid negative indexes in
	     YYCHECK.  */
	  int yyxbegin = yyn < 0 ? -yyn : 0;

	  /* Stay within bounds of both yycheck and yytname.  */
	  int yychecklim = YYLAST - yyn;
	  int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
	  int yycount = 0;

	  yyprefix = ", expecting ";
	  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
	    if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
	      {
		yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
		yycount += 1;
		if (yycount == 5)
		  {
		    yysize = 0;
		    break;
		  }
	      }
	  yysize += (sizeof ("syntax error, unexpected ")
		     + yystrlen (yytname[yytype]));
	  yymsg = (char *) YYSTACK_ALLOC (yysize);
	  if (yymsg != 0)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	    {
	      char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
	      yyp = yystpcpy (yyp, yytname[yytype]);
	      if (yycount < 5)
		  yyprefix = ", expecting ";
		  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
		    if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
			yyp = yystpcpy (yyp, yyprefix);
			yyp = yystpcpy (yyp, yytname[yyx]);
			yyprefix = " or ";
	      yyerror (yymsg);
	      YYSTACK_FREE (yymsg);
	    yyerror ("syntax error; also virtual memory exhausted");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#endif /* YYERROR_VERBOSE */
	yyerror ("syntax error");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

      /* If just tried and failed to reuse look-ahead token after an
	 error, discard it.  */

      if (yychar <= YYEOF)
        {
          /* If at end of input, pop the error token,
	     then the rest of the stack, then return failure.  */
	  if (yychar == YYEOF)
	     for (;;)
	       {

		 YYPOPSTACK;
		 if (yyssp == yyss)
		   YYABORT;
		 yydestruct ("Error: popping",
                             yystos[*yyssp], yyvsp);
	       }
        }
      else
	{
	  yydestruct ("Error: discarding", yytoken, &yylval);
	  yychar = YYEMPTY;
	}
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

  /* Else will try to reuse look-ahead token after shifting the error
     token.  */
  goto yyerrlab1;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

/*---------------------------------------------------.
| yyerrorlab -- error raised explicitly by YYERROR.  |
`---------------------------------------------------*/
yyerrorlab:
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

#ifdef __GNUC__
  /* Pacify GCC when the user code never invokes YYERROR and the label
     yyerrorlab therefore never appears in user code.  */
  if (0)
     goto yyerrorlab;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

yyvsp -= yylen;
  yyssp -= yylen;
  yystate = *yyssp;
  goto yyerrlab1;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

/*-------------------------------------------------------------.
| yyerrlab1 -- common code for both syntax error and YYERROR.  |
`-------------------------------------------------------------*/
yyerrlab1:
  yyerrstatus = 3;	/* Each real token shifted decrements this.  */
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

  for (;;)
    {
      yyn = yypact[yystate];
      if (yyn != YYPACT_NINF)
	{
	  yyn += YYTERROR;
	  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
	    {
	      yyn = yytable[yyn];
	      if (0 < yyn)
		break;
	    }
	}
      /* Pop the current state because it cannot handle the error token.  */
      if (yyssp == yyss)
	YYABORT;
      yydestruct ("Error: popping", yystos[yystate], yyvsp);
      YYPOPSTACK;
      yystate = *yyssp;
      YY_STACK_PRINT (yyss, yyssp);
  *++yyvsp = yylval;


  /* Shift the error token. */
  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);

/*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here.  |
`-------------------------------------*/
yyacceptlab:
  yyresult = 0;
  goto yyreturn;

/*-----------------------------------.
| yyabortlab -- YYABORT comes here.  |
`-----------------------------------*/
yyabortlab:
  yydestruct ("Error: discarding lookahead",
              yytoken, &yylval);
  yychar = YYEMPTY;
  yyresult = 1;
  goto yyreturn;

#ifndef yyoverflow
/*----------------------------------------------.
| yyoverflowlab -- parser overflow comes here.  |
`----------------------------------------------*/
yyoverflowlab:
  yyerror ("parser stack overflow");
  yyresult = 2;
  /* Fall through.  */
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#endif
yyreturn:
#ifndef yyoverflow
  if (yyss != yyssa)
    YYSTACK_FREE (yyss);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#endif
  return yyresult;
#line 3311 "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
  buffer[j] = '\0';

  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(j < (int)strlen(format) && format[j] != '%') j++;
      if(k != j){
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	strncpy(tmp1, &(format[k]), j-k);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	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
int CheckViewErrorFlags(Post_View *v){
  if(View->adaptive) return 0; // hope for the best :-)

  char *name[8] = { "point", "line", "triangle", "quadrangle", 
		    "tetrahedron", "hexahedron", "prism", "pyramid" };
  char *type[3] = { "scalar", "vector", "tensor" };

  if(8 * 3 != VIEW_NB_ELEMENT_TYPES){
    Msg(GERROR, "Please upgrade CheckViewErrorFlags!");
    return 0;
  }
  
  for(int i = 0; i < VIEW_NB_ELEMENT_TYPES; i++)
    if(ViewErrorFlags[i])
      Msg(GERROR, "%d %s %s%s in View[%d] contain%s a wrong number of values",
	  ViewErrorFlags[i], type[i%3], name[i/3], (ViewErrorFlags[i] > 1) ? "s" : "",
	  v->Index, (ViewErrorFlags[i] > 1) ? "" : "s");
  
  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++;