Skip to content
Snippets Groups Projects
Gmsh.tab.cpp 370 KiB
Newer Older
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
{
      yyval.u = Get_ColorForString(ColorString, -1, yyvsp[0].c, &flag);
      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
case 448:
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#line 3263 "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
	  yyval.u = pColOpt(0, GMSH_GET, 0) ;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    ;
    break;}
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
case 449:
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#line 3282 "Gmsh.y"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
{
      yyval.l = yyvsp[-1].l;
    ;
    break;}
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
case 450:
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#line 3286 "Gmsh.y"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
{
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);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	for(i = 0; i < ct->size; i++) 
	  List_Add(yyval.l, &ct->table[i]);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    ;
    break;}
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
case 451:
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#line 3300 "Gmsh.y"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
{
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
case 452:
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#line 3305 "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
case 453:
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#line 3312 "Gmsh.y"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
{
      yyval.c = yyvsp[0].c;
    ;
    break;}
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
case 454:
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#line 3316 "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
case 455:
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#line 3324 "Gmsh.y"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
{
      yyval.c = (char *)Malloc((strlen(yyvsp[-1].c)+1)*sizeof(char)) ;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      for(i = strlen(yyvsp[-1].c)-1; i >= 0; i--){
	if(yyvsp[-1].c[i] == '.'){
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	  strncpy(yyval.c, yyvsp[-1].c, i);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      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
case 456:
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#line 3337 "Gmsh.y"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
{
      yyval.c = yyvsp[-1].c;
    ;
    break;}
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
case 457:
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#line 3341 "Gmsh.y"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
{
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;
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;
      }
      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
case 458:
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#line 3359 "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);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	  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
case 459:
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#line 3373 "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);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	  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;}
}
   /* the action file gets copied in in place of this dollarsign */
#line 543 "/usr/share/bison.simple"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#ifdef YYLSP_NEEDED
  yylsp -= yylen;
#endif
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#if YYDEBUG != 0
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      short *ssp1 = yyss - 1;
      fprintf (stderr, "state stack now");
      while (ssp1 != yyssp)
	fprintf (stderr, " %d", *++ssp1);
      fprintf (stderr, "\n");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#ifdef YYLSP_NEEDED
  yylsp++;
  if (yylen == 0)
    {
      yylsp->first_line = yylloc.first_line;
      yylsp->first_column = yylloc.first_column;
      yylsp->last_line = (yylsp-1)->last_line;
      yylsp->last_column = (yylsp-1)->last_column;
      yylsp->text = 0;
    }
  else
    {
      yylsp->last_line = (yylsp+yylen-1)->last_line;
      yylsp->last_column = (yylsp+yylen-1)->last_column;
    }
#endif
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.  */
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];
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
yyerrlab:   /* here on detecting error */
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  if (! yyerrstatus)
    /* If not already recovering from an error, report this error.  */
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

#ifdef YYERROR_VERBOSE
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if (yyn > YYFLAG && yyn < YYLAST)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	  int size = 0;
	  char *msg;
	  int x, count;

	  count = 0;
	  /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
	  for (x = (yyn < 0 ? -yyn : 0);
	       x < (sizeof(yytname) / sizeof(char *)); x++)
	    if (yycheck[x + yyn] == x)
	      size += strlen(yytname[x]) + 15, count++;
	  msg = (char *) malloc(size + 15);
	  if (msg != 0)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	      strcpy(msg, "parse error");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	      if (count < 5)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
		  count = 0;
		  for (x = (yyn < 0 ? -yyn : 0);
		       x < (sizeof(yytname) / sizeof(char *)); x++)
		    if (yycheck[x + yyn] == x)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
			strcat(msg, count == 0 ? ", expecting `" : " or `");
			strcat(msg, yytname[x]);
			strcat(msg, "'");
			count++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	      yyerror(msg);
	      free(msg);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	    yyerror ("parse error; also virtual memory exceeded");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#endif /* YYERROR_VERBOSE */
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	yyerror("parse error");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  goto yyerrlab1;
yyerrlab1:   /* here on error raised explicitly by an action */
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;

#if YYDEBUG != 0
      if (yydebug)
	fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
#endif
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

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. */
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#if 0
  /* This is wrong; only states that explicitly want error tokens
     should shift them.  */
  yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  if (yyn) goto yydefault;
#endif
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
yyerrpop:   /* pop the current state because it cannot handle the error token */
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  if (yyssp == yyss) YYABORT;
  yyvsp--;
  yystate = *--yyssp;
#ifdef YYLSP_NEEDED
  yylsp--;
#endif
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#if YYDEBUG != 0
  if (yydebug)
    {
      short *ssp1 = yyss - 1;
      fprintf (stderr, "Error: state stack now");
      while (ssp1 != yyssp)
	fprintf (stderr, " %d", *++ssp1);
      fprintf (stderr, "\n");
    }
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
#if YYDEBUG != 0
  if (yydebug)
    fprintf(stderr, "Shifting error token, ");
#endif
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#ifdef YYLSP_NEEDED
  *++yylsp = yylloc;
#endif
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
 yyacceptlab:
  /* YYACCEPT comes here.  */
  if (yyfree_stacks)
    {
      free (yyss);
      free (yyvs);
#ifdef YYLSP_NEEDED
      free (yyls);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#endif
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    }
  return 0;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
 yyabortlab:
  /* YYABORT comes here.  */
  if (yyfree_stacks)
    {
      free (yyss);
      free (yyvs);
#ifdef YYLSP_NEEDED
      free (yyls);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    }
  return 1;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#line 3388 "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){
  int i, j, k;
  char tmp1[256], tmp2[256];

  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(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
  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;