absyntax/absyntax.cc
changeset 596 4efb11e44065
parent 569 0d1ab9e78574
child 612 c062ff18d04f
equal deleted inserted replaced
595:c41975a290ce 596:4efb11e44065
    38 #include <string.h>
    38 #include <string.h>
    39 
    39 
    40 #include "absyntax.hh"
    40 #include "absyntax.hh"
    41 //#include "../stage1_2/iec.hh" /* required for BOGUS_TOKEN_ID, etc... */
    41 //#include "../stage1_2/iec.hh" /* required for BOGUS_TOKEN_ID, etc... */
    42 #include "visitor.hh"
    42 #include "visitor.hh"
    43 
    43 #include "../main.hh" // required for ERROR() and ERROR_MSG() macros.
    44 #define ERROR error_exit(__FILE__,__LINE__)
       
    45 /* function defined in main.cc */
       
    46 extern void error_exit(const char *file_name, int line_no);
       
    47 
       
    48 #define ABORT(str) {printf("ERROR: %s\n", str); ERROR;}
       
    49 
    44 
    50 
    45 
    51 
    46 
    52 /* The base class of all symbols */
    47 /* The base class of all symbols */
    53 symbol_c::symbol_c(
    48 symbol_c::symbol_c(
   104 void list_c::add_element(symbol_c *elem) {
    99 void list_c::add_element(symbol_c *elem) {
   105 //printf("list_c::add_element()\n");
   100 //printf("list_c::add_element()\n");
   106   n++;
   101   n++;
   107   elements = (symbol_c **)realloc(elements, n * sizeof(symbol_c *));
   102   elements = (symbol_c **)realloc(elements, n * sizeof(symbol_c *));
   108   if (elements == NULL)
   103   if (elements == NULL)
   109     ABORT("Out of memory");
   104     ERROR_MSG("Out of memory");
   110   elements[n - 1] = elem;
   105   elements[n - 1] = elem;
   111  
   106  
   112   if (elem == NULL)
   107   if (elem == NULL)
   113     return;
   108     return;
   114 
   109