absyntax/absyntax.cc
changeset 287 9df7fcb9bde5
parent 286 a4f4990d5c66
child 350 2c3c4dc34979
equal deleted inserted replaced
286:a4f4990d5c66 287:9df7fcb9bde5
    48 
    48 
    49 
    49 
    50 
    50 
    51 /* The base class of all symbols */
    51 /* The base class of all symbols */
    52 symbol_c::symbol_c(
    52 symbol_c::symbol_c(
    53                    int first_line, int first_column, const char *ffile,
    53                    int first_line, int first_column, const char *ffile, long int first_order,
    54                    int last_line,  int last_column,  const char *lfile) {
    54                    int last_line,  int last_column,  const char *lfile, long int last_order ) {
    55   this->first_file   = ffile,
    55   this->first_file   = ffile,
    56   this->first_line   = first_line;
    56   this->first_line   = first_line;
    57   this->first_column = first_column;
    57   this->first_column = first_column;
       
    58   this->first_order  = first_order;
    58   this->last_file    = lfile,
    59   this->last_file    = lfile,
    59   this->last_line    = last_line;
    60   this->last_line    = last_line;
    60   this->last_column  = last_column;
    61   this->last_column  = last_column;
       
    62   this->last_order   = last_order;
    61 }
    63 }
    62 
    64 
    63 
    65 
    64 
    66 
    65 token_c::token_c(const char *value, 
    67 token_c::token_c(const char *value, 
    66                  int fl, int fc, const char *ffile,
    68                  int fl, int fc, const char *ffile, long int forder,
    67                  int ll, int lc, const char *lfile)
    69                  int ll, int lc, const char *lfile, long int lorder)
    68   :symbol_c(fl, fc, ffile, ll, lc, lfile) {
    70   :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) {
    69   this->value = value;
    71   this->value = value;
    70 //  printf("New token: %s\n", value);
    72 //  printf("New token: %s\n", value);
    71 }
    73 }
    72 
    74 
    73 
    75 
    74 
    76 
    75 
    77 
    76 
    78 
    77 
    79 
    78 list_c::list_c(
    80 list_c::list_c(
    79                int fl, int fc, const char *ffile,
    81                int fl, int fc, const char *ffile, long int forder,
    80                int ll, int lc, const char *lfile)
    82                int ll, int lc, const char *lfile, long int lorder)
    81   :symbol_c(fl, fc, ffile, ll, lc, lfile) {
    83   :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) {
    82   n = 0;
    84   n = 0;
    83   elements = NULL;
    85   elements = NULL;
    84 }
    86 }
    85 
    87 
    86 list_c::list_c(symbol_c *elem, 
    88 list_c::list_c(symbol_c *elem, 
    87                int fl, int fc, const char *ffile,
    89                int fl, int fc, const char *ffile, long int forder,
    88                int ll, int lc, const char *lfile)
    90                int ll, int lc, const char *lfile, long int lorder)
    89   :symbol_c(fl, fc, ffile, ll, lc, lfile) {
    91   :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) {
    90   n = 0;
    92   n = 0;
    91   elements = NULL;
    93   elements = NULL;
    92   add_element(elem);
    94   add_element(elem);
    93 }
    95 }
    94 
    96 
   126 
   128 
   127 
   129 
   128 
   130 
   129 #define SYM_LIST(class_name_c)									\
   131 #define SYM_LIST(class_name_c)									\
   130 class_name_c::class_name_c(									\
   132 class_name_c::class_name_c(									\
   131                            int fl, int fc, const char *ffile,					\
   133                            int fl, int fc, const char *ffile, long int forder,			\
   132                            int ll, int lc, const char *lfile)					\
   134                            int ll, int lc, const char *lfile, long int lorder)			\
   133                         :list_c(fl, fc, ffile, ll, lc, lfile) {}				\
   135                         :list_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) {}		\
   134 class_name_c::class_name_c(symbol_c *elem, 							\
   136 class_name_c::class_name_c(symbol_c *elem, 							\
   135                            int fl, int fc, const char *ffile,					\
   137                            int fl, int fc, const char *ffile, long int forder,			\
   136                            int ll, int lc, const char *lfile)					\
   138                            int ll, int lc, const char *lfile, long int lorder)			\
   137 			:list_c(elem, fl, fc, ffile, ll, lc, lfile) {}				\
   139 			:list_c(elem, fl, fc, ffile, forder, ll, lc, lfile, lorder) {}		\
   138 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
   140 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
   139 
   141 
   140 #define SYM_TOKEN(class_name_c)									\
   142 #define SYM_TOKEN(class_name_c)									\
   141 class_name_c::class_name_c(const char *value, 							\
   143 class_name_c::class_name_c(const char *value, 							\
   142                            int fl, int fc, const char *ffile,					\
   144                            int fl, int fc, const char *ffile, long int forder,			\
   143                            int ll, int lc, const char *lfile)					\
   145                            int ll, int lc, const char *lfile, long int lorder)			\
   144 			:token_c(value, fl, fc, ffile, ll, lc, lfile) {}			\
   146 			:token_c(value, fl, fc, ffile, forder, ll, lc, lfile, lorder) {}	\
   145 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
   147 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
   146 
   148 
   147 #define SYM_REF0(class_name_c)									\
   149 #define SYM_REF0(class_name_c)									\
   148 class_name_c::class_name_c(									\
   150 class_name_c::class_name_c(									\
   149                            int fl, int fc, const char *ffile,					\
   151                            int fl, int fc, const char *ffile, long int forder,			\
   150                            int ll, int lc, const char *lfile)					\
   152                            int ll, int lc, const char *lfile, long int lorder)			\
   151 			  :symbol_c(fl, fc, ffile, ll, lc, lfile) {}				\
   153 			  :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) {}		\
   152 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
   154 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
   153 
   155 
   154 
   156 
   155 #define SYM_REF1(class_name_c, ref1)								\
   157 #define SYM_REF1(class_name_c, ref1)								\
   156 class_name_c::class_name_c(symbol_c *ref1,							\
   158 class_name_c::class_name_c(symbol_c *ref1,							\
   157                            int fl, int fc, const char *ffile,					\
   159                            int fl, int fc, const char *ffile, long int forder,			\
   158                            int ll, int lc, const char *lfile)					\
   160                            int ll, int lc, const char *lfile, long int lorder)			\
   159 			  :symbol_c(fl, fc, ffile, ll, lc, lfile) {				\
   161 			  :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) {		\
   160   this->ref1 = ref1;										\
   162   this->ref1 = ref1;										\
   161 }												\
   163 }												\
   162 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
   164 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
   163 
   165 
   164 
   166 
   165 #define SYM_REF2(class_name_c, ref1, ref2)							\
   167 #define SYM_REF2(class_name_c, ref1, ref2)							\
   166 class_name_c::class_name_c(symbol_c *ref1,							\
   168 class_name_c::class_name_c(symbol_c *ref1,							\
   167 			   symbol_c *ref2,							\
   169 			   symbol_c *ref2,							\
   168                            int fl, int fc, const char *ffile,					\
   170                            int fl, int fc, const char *ffile, long int forder,			\
   169                            int ll, int lc, const char *lfile)					\
   171                            int ll, int lc, const char *lfile, long int lorder)			\
   170 			  :symbol_c(fl, fc, ffile, ll, lc, lfile) {				\
   172 			  :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) {		\
   171   this->ref1 = ref1;										\
   173   this->ref1 = ref1;										\
   172   this->ref2 = ref2;										\
   174   this->ref2 = ref2;										\
   173 }												\
   175 }												\
   174 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
   176 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
   175 
   177 
   176 
   178 
   177 #define SYM_REF3(class_name_c, ref1, ref2, ref3)						\
   179 #define SYM_REF3(class_name_c, ref1, ref2, ref3)						\
   178 class_name_c::class_name_c(symbol_c *ref1,							\
   180 class_name_c::class_name_c(symbol_c *ref1,							\
   179 			   symbol_c *ref2,							\
   181 			   symbol_c *ref2,							\
   180 			   symbol_c *ref3,							\
   182 			   symbol_c *ref3,							\
   181                            int fl, int fc, const char *ffile,					\
   183                            int fl, int fc, const char *ffile, long int forder,			\
   182                            int ll, int lc, const char *lfile)					\
   184                            int ll, int lc, const char *lfile, long int lorder)			\
   183 			  :symbol_c(fl, fc, ffile, ll, lc, lfile) {				\
   185 			  :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) {		\
   184   this->ref1 = ref1;										\
   186   this->ref1 = ref1;										\
   185   this->ref2 = ref2;										\
   187   this->ref2 = ref2;										\
   186   this->ref3 = ref3;										\
   188   this->ref3 = ref3;										\
   187 }												\
   189 }												\
   188 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
   190 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
   191 #define SYM_REF4(class_name_c, ref1, ref2, ref3, ref4)						\
   193 #define SYM_REF4(class_name_c, ref1, ref2, ref3, ref4)						\
   192 class_name_c::class_name_c(symbol_c *ref1,							\
   194 class_name_c::class_name_c(symbol_c *ref1,							\
   193 			   symbol_c *ref2,							\
   195 			   symbol_c *ref2,							\
   194 			   symbol_c *ref3,							\
   196 			   symbol_c *ref3,							\
   195 			   symbol_c *ref4,							\
   197 			   symbol_c *ref4,							\
   196                            int fl, int fc, const char *ffile,					\
   198                            int fl, int fc, const char *ffile, long int forder,			\
   197                            int ll, int lc, const char *lfile)					\
   199                            int ll, int lc, const char *lfile, long int lorder)			\
   198 			  :symbol_c(fl, fc, ffile, ll, lc, lfile) {				\
   200 			  :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) {		\
   199   this->ref1 = ref1;										\
   201   this->ref1 = ref1;										\
   200   this->ref2 = ref2;										\
   202   this->ref2 = ref2;										\
   201   this->ref3 = ref3;										\
   203   this->ref3 = ref3;										\
   202   this->ref4 = ref4;										\
   204   this->ref4 = ref4;										\
   203 }												\
   205 }												\
   208 class_name_c::class_name_c(symbol_c *ref1,							\
   210 class_name_c::class_name_c(symbol_c *ref1,							\
   209 			   symbol_c *ref2,							\
   211 			   symbol_c *ref2,							\
   210 			   symbol_c *ref3,							\
   212 			   symbol_c *ref3,							\
   211 			   symbol_c *ref4,							\
   213 			   symbol_c *ref4,							\
   212 			   symbol_c *ref5,							\
   214 			   symbol_c *ref5,							\
   213                            int fl, int fc, const char *ffile,					\
   215                            int fl, int fc, const char *ffile, long int forder,			\
   214                            int ll, int lc, const char *lfile)					\
   216                            int ll, int lc, const char *lfile, long int lorder)			\
   215 			  :symbol_c(fl, fc, ffile, ll, lc, lfile) {				\
   217 			  :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) {		\
   216   this->ref1 = ref1;										\
   218   this->ref1 = ref1;										\
   217   this->ref2 = ref2;										\
   219   this->ref2 = ref2;										\
   218   this->ref3 = ref3;										\
   220   this->ref3 = ref3;										\
   219   this->ref4 = ref4;										\
   221   this->ref4 = ref4;										\
   220   this->ref5 = ref5;										\
   222   this->ref5 = ref5;										\
   228 			   symbol_c *ref2,							\
   230 			   symbol_c *ref2,							\
   229 			   symbol_c *ref3,							\
   231 			   symbol_c *ref3,							\
   230 			   symbol_c *ref4,							\
   232 			   symbol_c *ref4,							\
   231 			   symbol_c *ref5,							\
   233 			   symbol_c *ref5,							\
   232 			   symbol_c *ref6,							\
   234 			   symbol_c *ref6,							\
   233                            int fl, int fc, const char *ffile,					\
   235                            int fl, int fc, const char *ffile, long int forder,			\
   234                            int ll, int lc, const char *lfile)					\
   236                            int ll, int lc, const char *lfile, long int lorder)			\
   235 			  :symbol_c(fl, fc, ffile, ll, lc, lfile) {				\
   237 			  :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) {		\
   236   this->ref1 = ref1;										\
   238   this->ref1 = ref1;										\
   237   this->ref2 = ref2;										\
   239   this->ref2 = ref2;										\
   238   this->ref3 = ref3;										\
   240   this->ref3 = ref3;										\
   239   this->ref4 = ref4;										\
   241   this->ref4 = ref4;										\
   240   this->ref5 = ref5;										\
   242   this->ref5 = ref5;										\