k-dot-p 0.1

makestruct.c++ File Reference

#include <stdio.h>
#include <stdlib.h>
#include <glib.h>
#include <gio/gio.h>
#include <libmodelxx/matdb.h++>
#include <libmodelxx/matdb-dotcode.h++>
#include <libmodelxx/continuous_structure.h++>
#include <libmodelxx/generic_structure.h++>
#include <libmodelxx/function_specification.h++>
#include "makestruct_argprocess.h++"
Include dependency graph for makestruct.c++:

Go to the source code of this file.

Functions

void yyparse ()
int yylex ()
int main (int argc, char *argv[])

Variables

struct continuous_structurethe_structure
GFileInputStream * instream

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 40 of file makestruct.c++.

References makestruct_args::files, kdotp::libmodelxx::structure::generic_structure_dump(), kdotp::libmodelxx::structure::generic_structure_free(), instream, makestruct_args::matdb, kdotp::libmodelxx::postprocessing::new_symbol_table(), parse_makestruct_args(), kdotp::libmodelxx::continuous_structure::postprocess_structure(), kdotp::libmodelxx::structure::read_matdb_dotcode(), the_structure, and yyparse().

                                 {
  g_type_init();
  /*
  int val;
  while((val=yylex()) != 0) {
    printf("Got token %d\n", val);
  }
  */
  struct makestruct_args args;
  int err;
  err = parse_makestruct_args(argc, argv, &args);
  if(err != 0) exit(1);
  GString *mdb_file = g_string_new(args.matdb);
  struct matdb* mdb = read_matdb_dotcode(mdb_file, &err);
  if(mdb == NULL) {fprintf(stderr, "ERROR reading in the materials database %s: %d\n", args.matdb, err); return 1;}

  GList* l;
  GError* gerr= NULL;
  GHashTable *gst = new_symbol_table();
  for(l=(args.files); l != NULL; l=l->next) {
    gerr = NULL;
    instream = g_file_read((GFile*)(l->data), NULL, &gerr);
    if(gerr != NULL) {
      fprintf(stderr, "makestruct: ERROR reading in structure file (%s): %s\n", g_file_get_uri((GFile*)(l->data)), gerr->message);
      continue;
    }
    yyparse();
    if(the_structure == NULL) {
      fprintf(stderr, "the_structure was NULL!\n");
      exit(1);
    }
    struct generic_structure *s = postprocess_structure(the_structure, mdb, gst, &gerr);
    *s = *s;
    fprintf(stderr, "got structure!\n");

    /*Dump the file.*/
    GFile* file = g_file_new_for_commandline_arg("teststruct.structdump");
    gerr = generic_structure_dump(s, file);
    if(gerr != NULL){
      fprintf(stderr, "unable to dump structure: %s\n", gerr->message);
      return 1;
    }

    generic_structure_free(s);
  }
  return 0;
}

Here is the call graph for this function:

int yylex ( )
void yyparse ( )

Definition at line 1416 of file structspec_parser.c++.

Referenced by main().

{


    int yystate;
    /* Number of tokens to shift before error messages enabled.  */
    int yyerrstatus;

    /* The stacks and their tools:
       `yyss': related to states.
       `yyvs': related to semantic values.
       `yyls': related to locations.

       Refer to the stacks thru separate pointers, to allow yyoverflow
       to reallocate them elsewhere.  */

    /* The state stack.  */
    yytype_int16 yyssa[YYINITDEPTH];
    yytype_int16 *yyss;
    yytype_int16 *yyssp;

    /* The semantic value stack.  */
    YYSTYPE yyvsa[YYINITDEPTH];
    YYSTYPE *yyvs;
    YYSTYPE *yyvsp;

    /* The location stack.  */
    YYLTYPE yylsa[YYINITDEPTH];
    YYLTYPE *yyls;
    YYLTYPE *yylsp;

    /* The locations where the error started and ended.  */
    YYLTYPE yyerror_range[2];

    YYSIZE_T yystacksize;

  int yyn;
  int yyresult;
  /* Lookahead token as an internal (translated) token number.  */
  int yytoken;
  /* The variables used to return semantic value and location from the
     action routines.  */
  YYSTYPE yyval;
  YYLTYPE yyloc;

#if YYERROR_VERBOSE
  /* Buffer for error messages, and its allocated size.  */
  char yymsgbuf[128];
  char *yymsg = yymsgbuf;
  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
#endif

#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N), yylsp -= (N))

  /* The number of symbols on the RHS of the reduced rule.
     Keep to zero when no symbol should be popped.  */
  int yylen = 0;

  yytoken = 0;
  yyss = yyssa;
  yyvs = yyvsa;
  yyls = yylsa;
  yystacksize = YYINITDEPTH;

  YYDPRINTF ((stderr, "Starting parse\n"));

  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = YYEMPTY; /* Cause a token to be read.  */

  /* Initialize stack pointers.
     Waste one element of value and location stack
     so that they stay on the same level as the state stack.
     The wasted elements are never initialized.  */
  yyssp = yyss;
  yyvsp = yyvs;
  yylsp = yyls;

#if YYLTYPE_IS_TRIVIAL
  /* Initialize the default location before parsing starts.  */
  yylloc.first_line   = yylloc.last_line   = 1;
  yylloc.first_column = yylloc.last_column = 1;
#endif

  goto yysetstate;

/*------------------------------------------------------------.
| yynewstate -- Push a new state, which is found in yystate.  |
`------------------------------------------------------------*/
 yynewstate:
  /* In all cases, when you get here, the value and location stacks
     have just been pushed.  So pushing a state here evens the stacks.  */
  yyssp++;

 yysetstate:
  *yyssp = yystate;

  if (yyss + yystacksize - 1 <= yyssp)
    {
      /* Get the current used size of the three stacks, in elements.  */
      YYSIZE_T yysize = yyssp - yyss + 1;

#ifdef yyoverflow
      {
  /* Give user a chance to reallocate the stack.  Use copies of
     these so that the &'s don't force the real ones into
     memory.  */
  YYSTYPE *yyvs1 = yyvs;
  yytype_int16 *yyss1 = yyss;
  YYLTYPE *yyls1 = yyls;

  /* Each stack pointer address is followed by the size of the
     data in use in that stack, in bytes.  This used to be a
     conditional around just the two extra args, but that might
     be undefined if yyoverflow is a macro.  */
  yyoverflow (YY_("memory exhausted"),
        &yyss1, yysize * sizeof (*yyssp),
        &yyvs1, yysize * sizeof (*yyvsp),
        &yyls1, yysize * sizeof (*yylsp),
        &yystacksize);

  yyls = yyls1;
  yyss = yyss1;
  yyvs = yyvs1;
      }
#else /* no yyoverflow */
# ifndef YYSTACK_RELOCATE
      goto yyexhaustedlab;
# else
      /* Extend the stack our own way.  */
      if (YYMAXDEPTH <= yystacksize)
  goto yyexhaustedlab;
      yystacksize *= 2;
      if (YYMAXDEPTH < yystacksize)
  yystacksize = YYMAXDEPTH;

      {
  yytype_int16 *yyss1 = yyss;
  union yyalloc *yyptr =
    (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
  if (! yyptr)
    goto yyexhaustedlab;
  YYSTACK_RELOCATE (yyss_alloc, yyss);
  YYSTACK_RELOCATE (yyvs_alloc, yyvs);
  YYSTACK_RELOCATE (yyls_alloc, yyls);
#  undef YYSTACK_RELOCATE
  if (yyss1 != yyssa)
    YYSTACK_FREE (yyss1);
      }
# endif
#endif /* no yyoverflow */

      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;
      yylsp = yyls + yysize - 1;

      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
      (unsigned long int) yystacksize));

      if (yyss + yystacksize - 1 <= yyssp)
  YYABORT;
    }

  YYDPRINTF ((stderr, "Entering state %d\n", yystate));

  if (yystate == YYFINAL)
    YYACCEPT;

  goto yybackup;

/*-----------.
| yybackup.  |
`-----------*/
yybackup:

  /* Do appropriate processing given the current state.  Read a
     lookahead token if we need one and don't already have one.  */

  /* First try to decide what to do without reference to lookahead token.  */
  yyn = yypact[yystate];
  if (yyn == YYPACT_NINF)
    goto yydefault;

  /* Not known => get a lookahead token if don't already have one.  */

  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
  if (yychar == YYEMPTY)
    {
      YYDPRINTF ((stderr, "Reading a token: "));
      yychar = YYLEX;
    }

  if (yychar <= YYEOF)
    {
      yychar = yytoken = YYEOF;
      YYDPRINTF ((stderr, "Now at end of input.\n"));
    }
  else
    {
      yytoken = YYTRANSLATE (yychar);
      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
    }

  /* If the proper action on seeing token YYTOKEN is to reduce or to
     detect an error, take that action.  */
  yyn += yytoken;
  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (yyn == 0 || yyn == YYTABLE_NINF)
  goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }

  /* Count tokens shifted since error; after three, turn off error
     status.  */
  if (yyerrstatus)
    yyerrstatus--;

  /* Shift the lookahead token.  */
  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);

  /* Discard the shifted token.  */
  yychar = YYEMPTY;

  yystate = yyn;
  *++yyvsp = yylval;
  *++yylsp = yylloc;
  goto yynewstate;


/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state.  |
`-----------------------------------------------------------*/
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;


/*-----------------------------.
| yyreduce -- Do a reduction.  |
`-----------------------------*/
yyreduce:
  /* yyn is the number of a rule to reduce with.  */
  yylen = yyr2[yyn];

  /* If YYLEN is nonzero, implement the default value of the action:
     `$$ = $1'.

     Otherwise, the following line sets YYVAL to garbage.
     This behavior is undocumented and Bison
     users should not rely upon it.  Assigning to YYVAL
     unconditionally makes the parser a bit smaller, and it avoids a
     GCC warning that YYVAL may be used uninitialized.  */
  yyval = yyvsp[1-yylen];

  /* Default location.  */
  YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
  YY_REDUCE_PRINT (yyn);
  switch (yyn)
    {
        case 2:

/* Line 1455 of yacc.c  */
#line 184 "structspec_parser.y++"
    {
  /*Note that grid info was stored in the structure when it was all read in*/
  the_structure = (yyvsp[(2) - (2)].s);
}
    break;

  case 3:

/* Line 1455 of yacc.c  */
#line 189 "structspec_parser.y++"
    {
  g = (struct grid*)malloc(sizeof(struct grid));
  g->t = (yyvsp[(3) - (13)].gt);
  g->dimensions = (yyvsp[(5) - (13)].ival);
  g->box_size = (yyvsp[(7) - (13)].list);
  g->site_length = (yyvsp[(9) - (13)].list);
  g->key_values = (yyvsp[(12) - (13)].list); 
  (yyval.g) = g;
}
    break;

  case 4:

/* Line 1455 of yacc.c  */
#line 199 "structspec_parser.y++"
    {
  struct continuous_structure *s = (struct continuous_structure*)malloc(sizeof(struct continuous_structure));
  s->key_values = (yyvsp[(3) - (7)].list);
  s->regions = (yyvsp[(4) - (7)].list);
  s->dopings = (yyvsp[(5) - (7)].list);
  s->potential = (yyvsp[(6) - (7)].list);
  s->g = g;
  (yyval.s) = s;
}
    break;

  case 5:

/* Line 1455 of yacc.c  */
#line 209 "structspec_parser.y++"
    {(yyval.list) = NULL;}
    break;

  case 6:

/* Line 1455 of yacc.c  */
#line 210 "structspec_parser.y++"
    {
  (yyval.list) = g_list_append((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].potential));
}
    break;

  case 7:

/* Line 1455 of yacc.c  */
#line 214 "structspec_parser.y++"
    {(yyval.list) = NULL;}
    break;

  case 8:

/* Line 1455 of yacc.c  */
#line 215 "structspec_parser.y++"
    {
  (yyval.list) = g_list_append((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].doping));
}
    break;

  case 9:

/* Line 1455 of yacc.c  */
#line 219 "structspec_parser.y++"
    {
  ((yyvsp[(3) - (9)].doping))->key_values = (yyvsp[(8) - (9)].list);
  ((yyvsp[(3) - (9)].doping))->st = (yyvsp[(5) - (9)].stree);
  (yyval.doping) = (yyvsp[(3) - (9)].doping);
}
    break;

  case 10:

/* Line 1455 of yacc.c  */
#line 225 "structspec_parser.y++"
    {(yyval.list) = NULL;}
    break;

  case 11:

/* Line 1455 of yacc.c  */
#line 226 "structspec_parser.y++"
    {
  (yyval.list) = g_list_append((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].region));
}
    break;

  case 12:

/* Line 1455 of yacc.c  */
#line 230 "structspec_parser.y++"
    {
  ((yyvsp[(3) - (9)].region))->key_values = (yyvsp[(8) - (9)].list);
  ((yyvsp[(3) - (9)].region))->st = (yyvsp[(5) - (9)].stree);
  (yyval.region) = (yyvsp[(3) - (9)].region);
}
    break;

  case 13:

/* Line 1455 of yacc.c  */
#line 237 "structspec_parser.y++"
    {
  struct region *r = (struct region*)malloc(sizeof(struct region));
  r->mat1 = (yyvsp[(1) - (1)].str);
  r->mat2 = NULL;
  r->x = 1.0;
  r->f = NULL;
  (yyval.region) = r;
}
    break;

  case 14:

/* Line 1455 of yacc.c  */
#line 245 "structspec_parser.y++"
    {
  struct region *r = (struct region*)malloc(sizeof(struct region));
  r->mat1 = (yyvsp[(1) - (5)].str);
  r->mat2 = (yyvsp[(5) - (5)].str);
  r->f = (yyvsp[(3) - (5)].exp);
  /*Check if this is just a const; if it is, do it instead of a full-on function evaluation (much faster).*/
  if((yyvsp[(3) - (5)].exp)->op == kdotp::libmodelxx::postprocessing::CONST) {
    /*Make sure this is a scalar.*/
    if(((struct function_const*)r->f)->t == 1) {
      r->x = ((struct function_const*)r->f)->value[0];
    free(r->f);
    /*Flag this as not being in use.*/
    r->f = NULL;
    if(((r->x) < 0.0) || ((r->x) > 1.0)) {fprintf(stderr, "ERROR: material specification %s(%f)%s is invalid; %f is not in range [0,1]\n", (yyvsp[(1) - (5)].str), r->x, (yyvsp[(5) - (5)].str), r->x);}
    }
  }
  (yyval.region) = r;
}
    break;

  case 15:

/* Line 1455 of yacc.c  */
#line 280 "structspec_parser.y++"
    {(yyval.list) = NULL;}
    break;

  case 16:

/* Line 1455 of yacc.c  */
#line 281 "structspec_parser.y++"
    {(yyval.list) = g_list_append((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].kvu));}
    break;

  case 17:

/* Line 1455 of yacc.c  */
#line 290 "structspec_parser.y++"
    {(yyval.list) = NULL;}
    break;

  case 18:

/* Line 1455 of yacc.c  */
#line 291 "structspec_parser.y++"
    {(yyval.list) = (yyvsp[(1) - (1)].list);}
    break;

  case 19:

/* Line 1455 of yacc.c  */
#line 293 "structspec_parser.y++"
    {
    (yyval.list) = g_list_append((yyvsp[(1) - (3)].list), (yyvsp[(3) - (3)].exp));
    GString *s = g_string_new("");
    function_print_tree((yyvsp[(3) - (3)].exp), &s, 1);
    fprintf(stderr, "***appending to fx_list: \n%s***\n", s->str);
    g_string_free(s, TRUE);
}
    break;

  case 20:

/* Line 1455 of yacc.c  */
#line 300 "structspec_parser.y++"
    {
  (yyval.list) = g_list_append(NULL, (yyvsp[(1) - (1)].exp));
  GString *s = g_string_new("");
  function_print_tree((yyvsp[(1) - (1)].exp), &s, 1);
  fprintf(stderr, "***creating new fx_list: \n%s***\n", s->str);
  g_string_free(s, TRUE);
}
    break;

  case 21:

/* Line 1455 of yacc.c  */
#line 308 "structspec_parser.y++"
    {((yyvsp[(3) - (4)].kvu))->key = ((yyvsp[(1) - (4)].str)); (yyval.kvu)=(yyvsp[(3) - (4)].kvu);}
    break;

  case 22:

/* Line 1455 of yacc.c  */
#line 309 "structspec_parser.y++"
    {kv=(struct key_value*)malloc(sizeof(struct key_value)); kv->key = NULL; kv->value.s = (yyvsp[(1) - (1)].str);  kv->t = STRING; (yyval.kvu)=kv;}
    break;

  case 23:

/* Line 1455 of yacc.c  */
#line 310 "structspec_parser.y++"
    {kv=(struct key_value*)malloc(sizeof(struct key_value)); kv->key = NULL; kv->value.s = (yyvsp[(1) - (1)].str); kv->t = STRING; (yyval.kvu)=kv;}
    break;

  case 24:

/* Line 1455 of yacc.c  */
#line 311 "structspec_parser.y++"
    {kv=(struct key_value*)malloc(sizeof(struct key_value)); kv->key =NULL; kv->value.d = (yyvsp[(1) - (1)].fval);  kv->t = FLOAT; (yyval.kvu)=kv;}
    break;

  case 25:

/* Line 1455 of yacc.c  */
#line 312 "structspec_parser.y++"
    {kv=(struct key_value*)malloc(sizeof(struct key_value)); kv->key = NULL; kv->value.l = (yyvsp[(1) - (1)].list);  kv->t = VECTOR; (yyval.kvu)=kv;}
    break;

  case 26:

/* Line 1455 of yacc.c  */
#line 313 "structspec_parser.y++"
    {kv=(struct key_value*)malloc(sizeof(struct key_value)); kv->key = NULL; kv->value.l = (yyvsp[(1) - (1)].list);  kv->t = VECTOR_SET; (yyval.kvu)=kv;}
    break;

  case 27:

/* Line 1455 of yacc.c  */
#line 315 "structspec_parser.y++"
    {
  struct shape_tree *st = (struct shape_tree*) malloc(sizeof(struct shape_tree));
  st->l = (yyvsp[(1) - (3)].stree);
  st->r = (yyvsp[(3) - (3)].stree);
  st->op = ::kdotp::libmodelxx::grid::AND;
  (yyval.stree) = st;
}
    break;

  case 28:

/* Line 1455 of yacc.c  */
#line 322 "structspec_parser.y++"
    {
  struct shape_tree* st = (struct shape_tree*) malloc(sizeof(struct shape_tree));
  st->l = (yyvsp[(1) - (3)].stree);
  st->r = (yyvsp[(3) - (3)].stree);
  st->op = ::kdotp::libmodelxx::grid::OR;
  (yyval.stree) = st;
}
    break;

  case 29:

/* Line 1455 of yacc.c  */
#line 329 "structspec_parser.y++"
    {
  struct shape_tree* st = (struct shape_tree*) malloc(sizeof(struct shape_tree));
  st->l = (yyvsp[(2) - (2)].stree);
  st->r = NULL;
  st->op = ::kdotp::libmodelxx::grid::NOT;
  (yyval.stree) = st;
}
    break;

  case 30:

/* Line 1455 of yacc.c  */
#line 336 "structspec_parser.y++"
    {
  struct shape_tree* st = (struct shape_tree*) malloc(sizeof(struct shape_tree));
  st->l = (yyvsp[(1) - (3)].stree);
  st->r = (yyvsp[(3) - (3)].stree);
  st->op = ::kdotp::libmodelxx::grid::XOR;
  (yyval.stree) = st;
}
    break;

  case 31:

/* Line 1455 of yacc.c  */
#line 343 "structspec_parser.y++"
    {(yyval.stree) = (yyvsp[(2) - (3)].stree);}
    break;

  case 32:

/* Line 1455 of yacc.c  */
#line 344 "structspec_parser.y++"
    {
  struct shape *s = (struct shape*)malloc(sizeof(struct shape));
  s->type = get_shape_from_identifier((yyvsp[(1) - (4)].str));
  s->op = kdotp::libmodelxx::grid::LEAF;
  if(s->type == ::kdotp::libmodelxx::grid::INVALID) {
    fprintf(stderr, "ERROR: shape identifier (%s) is invalid!\n", ((yyvsp[(1) - (4)].str)));
    exit(5);
  }        
  char* c = NULL;
  get_string_from_shape_type(&c, s->type);
  fprintf(stderr, "A: Got shape type %s\n", c);
  g_free(c);
  s->descriptor = (yyvsp[(3) - (4)].list);
  s->generic = true;
  (yyval.stree) = (struct shape_tree*)s;
}
    break;

  case 33:

/* Line 1455 of yacc.c  */
#line 360 "structspec_parser.y++"
    {
  struct shape *s = (struct shape*)malloc(sizeof(struct shape));
  s->op = kdotp::libmodelxx::grid::LEAF;
  s->type = get_shape_from_identifier((yyvsp[(1) - (1)].str));
  if(s->type == ::kdotp::libmodelxx::grid::INVALID) {
    fprintf(stderr, "ERROR: shape identifier (%s) is invalid!\n", ((yyvsp[(1) - (1)].str)));
    exit(5);
  }        
  if(s->type != ::kdotp::libmodelxx::grid::GLOBAL) {
    fprintf(stderr, "ERROR: shape (%s) is invalid (only the global shape does not need an argument)\n", ((yyvsp[(1) - (1)].str)));
    exit(5);
  }        
  char* c = NULL;
  get_string_from_shape_type(&c, s->type);
  fprintf(stderr, "B: Got shape type %s\n", c);
  g_free(c);
  s->descriptor = NULL; 
  s->generic = true;
  (yyval.stree) = (struct shape_tree*)s;
}
    break;

  case 34:

/* Line 1455 of yacc.c  */
#line 380 "structspec_parser.y++"
    {(yyval.list) = (yyvsp[(2) - (3)].list);}
    break;

  case 35:

/* Line 1455 of yacc.c  */
#line 382 "structspec_parser.y++"
    {(yyval.list) = g_list_append((yyvsp[(1) - (3)].list), (yyvsp[(3) - (3)].list));}
    break;

  case 36:

/* Line 1455 of yacc.c  */
#line 383 "structspec_parser.y++"
    {(yyval.list) = g_list_append(NULL, (yyvsp[(1) - (1)].list));}
    break;

  case 37:

/* Line 1455 of yacc.c  */
#line 385 "structspec_parser.y++"
    {(yyval.list) = (yyvsp[(2) - (3)].list);}
    break;

  case 38:

/* Line 1455 of yacc.c  */
#line 387 "structspec_parser.y++"
    {(yyval.list) = NULL;}
    break;

  case 39:

/* Line 1455 of yacc.c  */
#line 388 "structspec_parser.y++"
    {(yyval.list) = g_list_append((yyvsp[(1) - (3)].list), new_double((yyvsp[(3) - (3)].fval)));}
    break;

  case 40:

/* Line 1455 of yacc.c  */
#line 389 "structspec_parser.y++"
    {(yyval.list) = g_list_append(NULL, new_double((yyvsp[(1) - (1)].fval)));}
    break;

  case 41:

/* Line 1455 of yacc.c  */
#line 391 "structspec_parser.y++"
    {
  (yyval.list) = (yyvsp[(2) - (3)].list);
}
    break;

  case 42:

/* Line 1455 of yacc.c  */
#line 395 "structspec_parser.y++"
    {(yyval.list) = NULL;}
    break;

  case 43:

/* Line 1455 of yacc.c  */
#line 396 "structspec_parser.y++"
    {(yyval.list) = g_list_append((yyvsp[(1) - (3)].list), new_int((yyvsp[(3) - (3)].ival)));}
    break;

  case 44:

/* Line 1455 of yacc.c  */
#line 397 "structspec_parser.y++"
    {(yyval.list) = g_list_append(NULL, new_int((yyvsp[(1) - (1)].ival)));}
    break;

  case 45:

/* Line 1455 of yacc.c  */
#line 399 "structspec_parser.y++"
    {(yyval.fval) = convert_length_to_nm((yyvsp[(1) - (2)].fval), (yyvsp[(2) - (2)].len));}
    break;

  case 46:

/* Line 1455 of yacc.c  */
#line 400 "structspec_parser.y++"
    {(yyval.fval) = convert_energy_to_hartree((yyvsp[(1) - (2)].fval), (yyvsp[(2) - (2)].energy));}
    break;

  case 47:

/* Line 1455 of yacc.c  */
#line 401 "structspec_parser.y++"
    {fprintf(stderr, "structspec PARSER WARNING: float %g presented without units where a float with units is expected; you should specify your units!\n", (yyvsp[(1) - (1)].fval)); (yyval.fval) = (yyvsp[(1) - (1)].fval);}
    break;

  case 48:

/* Line 1455 of yacc.c  */
#line 402 "structspec_parser.y++"
    {(yyval.fval) = convert_length_to_nm((double)(yyvsp[(1) - (2)].ival), (yyvsp[(2) - (2)].len));}
    break;

  case 49:

/* Line 1455 of yacc.c  */
#line 403 "structspec_parser.y++"
    {(yyval.fval) = convert_energy_to_hartree((double)(yyvsp[(1) - (2)].ival), (yyvsp[(2) - (2)].energy));}
    break;

  case 50:

/* Line 1455 of yacc.c  */
#line 404 "structspec_parser.y++"
    {fprintf(stderr, "structspec PARSER WARNING: integer %d presented without units where a float with units is expected; you should specify your units!\n", (yyvsp[(1) - (1)].ival)); (yyval.fval) = (double)(yyvsp[(1) - (1)].ival);}
    break;

  case 51:

/* Line 1455 of yacc.c  */
#line 406 "structspec_parser.y++"
    {
  struct doping* doping = (struct doping*)malloc(sizeof(struct doping));
  g_assert(doping != NULL);
  doping->f = (yyvsp[(1) - (1)].exp);
  doping->st = NULL;
  doping->key_values = NULL;
  (yyval.doping) = doping;
}
    break;

  case 52:

/* Line 1455 of yacc.c  */
#line 415 "structspec_parser.y++"
    {(yyval.potential) = NULL;}
    break;

  case 53:

/* Line 1455 of yacc.c  */
#line 416 "structspec_parser.y++"
    {
  struct potential *pot = (struct potential*)malloc(sizeof(struct potential));
  g_assert(pot != NULL);
  pot->Evec = (yyvsp[(2) - (2)].list);
  pot->E = NULL;
  pot->function = NULL;
  (yyval.potential) = pot;
}
    break;

  case 54:

/* Line 1455 of yacc.c  */
#line 425 "structspec_parser.y++"
    {(yyval.exp) = new_fx_const_single((yyvsp[(1) - (1)].fval));}
    break;

  case 55:

/* Line 1455 of yacc.c  */
#line 426 "structspec_parser.y++"
    {(yyval.exp) = new_fx_const_single((yyvsp[(2) - (2)].fval));}
    break;

  case 56:

/* Line 1455 of yacc.c  */
#line 428 "structspec_parser.y++"
    {(yyval.exp) = new_fx_const_single((yyvsp[(1) - (1)].ival));}
    break;

  case 57:

/* Line 1455 of yacc.c  */
#line 429 "structspec_parser.y++"
    {(yyval.exp) = new_fx_const_single((yyvsp[(2) - (2)].ival));}
    break;

  case 58:

/* Line 1455 of yacc.c  */
#line 431 "structspec_parser.y++"
    {(yyval.exp) = new_fx_const(g_list_length((yyvsp[(1) - (1)].list)), (yyvsp[(1) - (1)].list));}
    break;

  case 59:

/* Line 1455 of yacc.c  */
#line 432 "structspec_parser.y++"
    {(yyval.exp) = new_fx(kdotp::libmodelxx::postprocessing::PLUS, (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));}
    break;

  case 60:

/* Line 1455 of yacc.c  */
#line 433 "structspec_parser.y++"
    {(yyval.exp) = new_fx(kdotp::libmodelxx::postprocessing::MINUS, (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));}
    break;

  case 61:

/* Line 1455 of yacc.c  */
#line 434 "structspec_parser.y++"
    {(yyval.exp) = new_fx(kdotp::libmodelxx::postprocessing::MUL, (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));}
    break;

  case 62:

/* Line 1455 of yacc.c  */
#line 435 "structspec_parser.y++"
    {(yyval.exp) = new_fx(kdotp::libmodelxx::postprocessing::DIV, (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));}
    break;

  case 63:

/* Line 1455 of yacc.c  */
#line 436 "structspec_parser.y++"
    {(yyval.exp) = new_fx(kdotp::libmodelxx::postprocessing::CROSS, (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));}
    break;

  case 64:

/* Line 1455 of yacc.c  */
#line 437 "structspec_parser.y++"
    {(yyval.exp) = new_fx(kdotp::libmodelxx::postprocessing::DOT, (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));}
    break;

  case 65:

/* Line 1455 of yacc.c  */
#line 438 "structspec_parser.y++"
    {(yyval.exp) = (yyvsp[(2) - (3)].exp);}
    break;

  case 66:

/* Line 1455 of yacc.c  */
#line 439 "structspec_parser.y++"
    {(yyval.exp) = new_fx(kdotp::libmodelxx::postprocessing::NEG, NULL, (yyvsp[(2) - (2)].exp));}
    break;

  case 67:

/* Line 1455 of yacc.c  */
#line 440 "structspec_parser.y++"
    {(yyval.exp) = new_fx_func((yyvsp[(1) - (4)].str), (yyvsp[(3) - (4)].exp));}
    break;

  case 68:

/* Line 1455 of yacc.c  */
#line 441 "structspec_parser.y++"
    {(yyval.exp) = new_fx_symbol((yyvsp[(1) - (1)].str));}
    break;

  case 69:

/* Line 1455 of yacc.c  */
#line 443 "structspec_parser.y++"
    {(yyval.fval) = (yyvsp[(1) - (1)].fval);}
    break;

  case 70:

/* Line 1455 of yacc.c  */
#line 444 "structspec_parser.y++"
    {(yyval.fval) = -(yyvsp[(2) - (2)].fval);}
    break;

  case 71:

/* Line 1455 of yacc.c  */
#line 445 "structspec_parser.y++"
    {(yyval.fval) = (yyvsp[(2) - (2)].fval);}
    break;

  case 72:

/* Line 1455 of yacc.c  */
#line 447 "structspec_parser.y++"
    {(yyval.ival) = (yyvsp[(1) - (1)].ival);}
    break;

  case 73:

/* Line 1455 of yacc.c  */
#line 448 "structspec_parser.y++"
    {(yyval.ival) = -(yyvsp[(2) - (2)].ival);}
    break;

  case 74:

/* Line 1455 of yacc.c  */
#line 449 "structspec_parser.y++"
    {(yyval.ival) = (yyvsp[(2) - (2)].ival);}
    break;



/* Line 1455 of yacc.c  */
#line 2344 "kdotp/structspec_parser.c++"
      default: break;
    }
  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);

  YYPOPSTACK (yylen);
  yylen = 0;
  YY_STACK_PRINT (yyss, yyssp);

  *++yyvsp = yyval;
  *++yylsp = yyloc;

  /* 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.  */

  yyn = yyr1[yyn];

  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
    yystate = yytable[yystate];
  else
    yystate = yydefgoto[yyn - YYNTOKENS];

  goto yynewstate;


/*------------------------------------.
| yyerrlab -- here on detecting error |
`------------------------------------*/
yyerrlab:
  /* If not already recovering from an error, report this error.  */
  if (!yyerrstatus)
    {
      ++yynerrs;
#if ! YYERROR_VERBOSE
      yyerror (YY_("syntax error"));
#else
      {
  YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
  if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
    {
      YYSIZE_T yyalloc = 2 * yysize;
      if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
        yyalloc = YYSTACK_ALLOC_MAXIMUM;
      if (yymsg != yymsgbuf)
        YYSTACK_FREE (yymsg);
      yymsg = (char *) YYSTACK_ALLOC (yyalloc);
      if (yymsg)
        yymsg_alloc = yyalloc;
      else
        {
    yymsg = yymsgbuf;
    yymsg_alloc = sizeof yymsgbuf;
        }
    }

  if (0 < yysize && yysize <= yymsg_alloc)
    {
      (void) yysyntax_error (yymsg, yystate, yychar);
      yyerror (yymsg);
    }
  else
    {
      yyerror (YY_("syntax error"));
      if (yysize != 0)
        goto yyexhaustedlab;
    }
      }
#endif
    }

  yyerror_range[0] = yylloc;

  if (yyerrstatus == 3)
    {
      /* If just tried and failed to reuse lookahead token after an
   error, discard it.  */

      if (yychar <= YYEOF)
  {
    /* Return failure if at end of input.  */
    if (yychar == YYEOF)
      YYABORT;
  }
      else
  {
    yydestruct ("Error: discarding",
          yytoken, &yylval, &yylloc);
    yychar = YYEMPTY;
  }
    }

  /* Else will try to reuse lookahead token after shifting the error
     token.  */
  goto yyerrlab1;


/*---------------------------------------------------.
| yyerrorlab -- error raised explicitly by YYERROR.  |
`---------------------------------------------------*/
yyerrorlab:

  /* Pacify compilers like GCC when the user code never invokes
     YYERROR and the label yyerrorlab therefore never appears in user
     code.  */
  if (/*CONSTCOND*/ 0)
     goto yyerrorlab;

  yyerror_range[0] = yylsp[1-yylen];
  /* Do not reclaim the symbols of the rule which action triggered
     this YYERROR.  */
  YYPOPSTACK (yylen);
  yylen = 0;
  YY_STACK_PRINT (yyss, yyssp);
  yystate = *yyssp;
  goto yyerrlab1;


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

  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;

      yyerror_range[0] = *yylsp;
      yydestruct ("Error: popping",
      yystos[yystate], yyvsp, yylsp);
      YYPOPSTACK (1);
      yystate = *yyssp;
      YY_STACK_PRINT (yyss, yyssp);
    }

  *++yyvsp = yylval;

  yyerror_range[1] = yylloc;
  /* Using YYLLOC is tempting, but would change the location of
     the lookahead.  YYLOC is available though.  */
  YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
  *++yylsp = yyloc;

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

  yystate = yyn;
  goto yynewstate;


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

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

#if !defined(yyoverflow) || YYERROR_VERBOSE
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here.  |
`-------------------------------------------------*/
yyexhaustedlab:
  yyerror (YY_("memory exhausted"));
  yyresult = 2;
  /* Fall through.  */
#endif

yyreturn:
  if (yychar != YYEMPTY)
     yydestruct ("Cleanup: discarding lookahead",
     yytoken, &yylval, &yylloc);
  /* Do not reclaim the symbols of the rule which action triggered
     this YYABORT or YYACCEPT.  */
  YYPOPSTACK (yylen);
  YY_STACK_PRINT (yyss, yyssp);
  while (yyssp != yyss)
    {
      yydestruct ("Cleanup: popping",
      yystos[*yyssp], yyvsp, yylsp);
      YYPOPSTACK (1);
    }
#ifndef yyoverflow
  if (yyss != yyssa)
    YYSTACK_FREE (yyss);
#endif
#if YYERROR_VERBOSE
  if (yymsg != yymsgbuf)
    YYSTACK_FREE (yymsg);
#endif
  /* Make sure YYID is used.  */
  return YYID (yyresult);
}

Here is the caller graph for this function:


Variable Documentation

GFileInputStream* instream

Definition at line 580 of file structspec_lexer.c++.

Referenced by main(), and process_args().

Definition at line 205 of file structspec_parser.c++.

Referenced by main(), and yyparse().

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines