absyntax/visitor.cc
changeset 350 2c3c4dc34979
parent 279 c0453b7f99df
child 417 d48f53715f77
equal deleted inserted replaced
341:ba80c3ceb6fb 350:2c3c4dc34979
    80   void *null_visitor_c::visit(class_name_c *symbol) {return NULL;}
    80   void *null_visitor_c::visit(class_name_c *symbol) {return NULL;}
    81 
    81 
    82 #define SYM_REF1(class_name_c, ref1)	\
    82 #define SYM_REF1(class_name_c, ref1)	\
    83   void *null_visitor_c::visit(class_name_c *symbol) {return NULL;}
    83   void *null_visitor_c::visit(class_name_c *symbol) {return NULL;}
    84 
    84 
    85 #define SYM_REF2(class_name_c, ref1, ref2)	\
    85 #define SYM_REF2(class_name_c, ref1, ref2, ...)	\
    86   void *null_visitor_c::visit(class_name_c *symbol) {return NULL;}
    86   void *null_visitor_c::visit(class_name_c *symbol) {return NULL;}
    87 
    87 
    88 #define SYM_REF3(class_name_c, ref1, ref2, ref3)	\
    88 #define SYM_REF3(class_name_c, ref1, ref2, ref3, ...)	\
    89   void *null_visitor_c::visit(class_name_c *symbol) {return NULL;}
    89   void *null_visitor_c::visit(class_name_c *symbol) {return NULL;}
    90 
    90 
    91 #define SYM_REF4(class_name_c, ref1, ref2, ref3, ref4)	\
    91 #define SYM_REF4(class_name_c, ref1, ref2, ref3, ref4, ...)	\
    92   void *null_visitor_c::visit(class_name_c *symbol) {return NULL;}
    92   void *null_visitor_c::visit(class_name_c *symbol) {return NULL;}
    93 
    93 
    94 #define SYM_REF5(class_name_c, ref1, ref2, ref3, ref4, ref5)	\
    94 #define SYM_REF5(class_name_c, ref1, ref2, ref3, ref4, ref5, ...)	\
    95   void *null_visitor_c::visit(class_name_c *symbol) {return NULL;}
    95   void *null_visitor_c::visit(class_name_c *symbol) {return NULL;}
    96 
    96 
    97 #define SYM_REF6(class_name_c, ref1, ref2, ref3, ref4, ref5, ref6)	\
    97 #define SYM_REF6(class_name_c, ref1, ref2, ref3, ref4, ref5, ref6, ...)	\
    98   void *null_visitor_c::visit(class_name_c *symbol) {return NULL;}
    98   void *null_visitor_c::visit(class_name_c *symbol) {return NULL;}
    99 
    99 
   100 
   100 
   101 #include "absyntax.def"
   101 #include "absyntax.def"
   102 
   102 
   146 void *iterator_visitor_c::visit(class_name_c *symbol) {	\
   146 void *iterator_visitor_c::visit(class_name_c *symbol) {	\
   147   if (symbol->ref1!=NULL) symbol->ref1->accept(*this);	\
   147   if (symbol->ref1!=NULL) symbol->ref1->accept(*this);	\
   148   return NULL;						\
   148   return NULL;						\
   149 }
   149 }
   150 
   150 
   151 #define SYM_REF2(class_name_c, ref1, ref2)		\
   151 #define SYM_REF2(class_name_c, ref1, ref2, ...)		\
   152 void *iterator_visitor_c::visit(class_name_c *symbol) {	\
   152 void *iterator_visitor_c::visit(class_name_c *symbol) {	\
   153   if (symbol->ref1!=NULL) symbol->ref1->accept(*this);	\
   153   if (symbol->ref1!=NULL) symbol->ref1->accept(*this);	\
   154   if (symbol->ref2!=NULL) symbol->ref2->accept(*this);	\
   154   if (symbol->ref2!=NULL) symbol->ref2->accept(*this);	\
   155   return NULL;						\
   155   return NULL;						\
   156 }
   156 }
   157 
   157 
   158 #define SYM_REF3(class_name_c, ref1, ref2, ref3)	\
   158 #define SYM_REF3(class_name_c, ref1, ref2, ref3, ...)			\
   159 void *iterator_visitor_c::visit(class_name_c *symbol) {	\
   159 void *iterator_visitor_c::visit(class_name_c *symbol) {			\
   160   if (symbol->ref1) symbol->ref1->accept(*this);	\
   160   if (symbol->ref1) symbol->ref1->accept(*this);			\
   161   if (symbol->ref2) symbol->ref2->accept(*this);	\
   161   if (symbol->ref2) symbol->ref2->accept(*this);			\
   162   if (symbol->ref3) symbol->ref3->accept(*this);	\
   162   if (symbol->ref3) symbol->ref3->accept(*this);			\
   163   return NULL;						\
   163   return NULL;								\
   164 }
   164 }
   165 
   165 
   166 #define SYM_REF4(class_name_c, ref1, ref2, ref3, ref4)	\
   166 #define SYM_REF4(class_name_c, ref1, ref2, ref3, ref4, ...)		\
   167 void *iterator_visitor_c::visit(class_name_c *symbol) {	\
   167 void *iterator_visitor_c::visit(class_name_c *symbol) {			\
   168   if (symbol->ref1) symbol->ref1->accept(*this);	\
   168   if (symbol->ref1) symbol->ref1->accept(*this);			\
   169   if (symbol->ref2) symbol->ref2->accept(*this);	\
   169   if (symbol->ref2) symbol->ref2->accept(*this);			\
   170   if (symbol->ref3) symbol->ref3->accept(*this);	\
   170   if (symbol->ref3) symbol->ref3->accept(*this);			\
   171   if (symbol->ref4) symbol->ref4->accept(*this);	\
   171   if (symbol->ref4) symbol->ref4->accept(*this);			\
   172   return NULL;						\
   172   return NULL;								\
   173 }
   173 }
   174 
   174 
   175 #define SYM_REF5(class_name_c, ref1, ref2, ref3, ref4, ref5)		\
   175 #define SYM_REF5(class_name_c, ref1, ref2, ref3, ref4, ref5, ...)	\
   176 void *iterator_visitor_c::visit(class_name_c *symbol) {			\
   176 void *iterator_visitor_c::visit(class_name_c *symbol) {			\
   177   if (symbol->ref1) symbol->ref1->accept(*this);			\
   177   if (symbol->ref1) symbol->ref1->accept(*this);			\
   178   if (symbol->ref2) symbol->ref2->accept(*this);			\
   178   if (symbol->ref2) symbol->ref2->accept(*this);			\
   179   if (symbol->ref3) symbol->ref3->accept(*this);			\
   179   if (symbol->ref3) symbol->ref3->accept(*this);			\
   180   if (symbol->ref4) symbol->ref4->accept(*this);			\
   180   if (symbol->ref4) symbol->ref4->accept(*this);			\
   181   if (symbol->ref5) symbol->ref5->accept(*this);			\
   181   if (symbol->ref5) symbol->ref5->accept(*this);			\
   182   return NULL;								\
   182   return NULL;								\
   183 }
   183 }
   184 
   184 
   185 #define SYM_REF6(class_name_c, ref1, ref2, ref3, ref4, ref5, ref6)	\
   185 #define SYM_REF6(class_name_c, ref1, ref2, ref3, ref4, ref5, ref6, ...)	\
   186 void *iterator_visitor_c::visit(class_name_c *symbol) {			\
   186 void *iterator_visitor_c::visit(class_name_c *symbol) {			\
   187   if (symbol->ref1) symbol->ref1->accept(*this);			\
   187   if (symbol->ref1) symbol->ref1->accept(*this);			\
   188   if (symbol->ref2) symbol->ref2->accept(*this);			\
   188   if (symbol->ref2) symbol->ref2->accept(*this);			\
   189   if (symbol->ref3) symbol->ref3->accept(*this);			\
   189   if (symbol->ref3) symbol->ref3->accept(*this);			\
   190   if (symbol->ref4) symbol->ref4->accept(*this);			\
   190   if (symbol->ref4) symbol->ref4->accept(*this);			\
   248 void *search_visitor_c::visit(class_name_c *symbol) {		\
   248 void *search_visitor_c::visit(class_name_c *symbol) {		\
   249   if (symbol->ref1) return symbol->ref1->accept(*this);		\
   249   if (symbol->ref1) return symbol->ref1->accept(*this);		\
   250   return NULL;							\
   250   return NULL;							\
   251 }
   251 }
   252 
   252 
   253 #define SYM_REF2(class_name_c, ref1, ref2)			\
   253 #define SYM_REF2(class_name_c, ref1, ref2, ...)			\
   254 void *search_visitor_c::visit(class_name_c *symbol) {		\
   254 void *search_visitor_c::visit(class_name_c *symbol) {		\
   255   void *res = NULL;						\
   255   void *res = NULL;						\
   256   if (symbol->ref1) res =  symbol->ref1->accept(*this);		\
   256   if (symbol->ref1) res =  symbol->ref1->accept(*this);		\
   257   if (res != NULL)  return res;					\
   257   if (res != NULL)  return res;					\
   258   if (symbol->ref2) return symbol->ref2->accept(*this);		\
   258   if (symbol->ref2) return symbol->ref2->accept(*this);		\
   259   return NULL;							\
   259   return NULL;							\
   260 }
   260 }
   261 
   261 
   262 #define SYM_REF3(class_name_c, ref1, ref2, ref3)		\
   262 #define SYM_REF3(class_name_c, ref1, ref2, ref3, ...)		\
   263 void *search_visitor_c::visit(class_name_c *symbol) {		\
   263 void *search_visitor_c::visit(class_name_c *symbol) {		\
   264   void *res = NULL;						\
   264   void *res = NULL;						\
   265   if (symbol->ref1) res =  symbol->ref1->accept(*this);		\
   265   if (symbol->ref1) res =  symbol->ref1->accept(*this);		\
   266   if (res != NULL)  return res;					\
   266   if (res != NULL)  return res;					\
   267   if (symbol->ref2) res =  symbol->ref2->accept(*this);		\
   267   if (symbol->ref2) res =  symbol->ref2->accept(*this);		\
   268   if (res != NULL)  return res;					\
   268   if (res != NULL)  return res;					\
   269   if (symbol->ref3) return symbol->ref3->accept(*this);		\
   269   if (symbol->ref3) return symbol->ref3->accept(*this);		\
   270   return NULL;							\
   270   return NULL;							\
   271 }
   271 }
   272 
   272 
   273 #define SYM_REF4(class_name_c, ref1, ref2, ref3, ref4)		\
   273 #define SYM_REF4(class_name_c, ref1, ref2, ref3, ref4, ...)		\
   274 void *search_visitor_c::visit(class_name_c *symbol) {		\
   274 void *search_visitor_c::visit(class_name_c *symbol) {		\
   275   void *res = NULL;						\
   275   void *res = NULL;						\
   276   if (symbol->ref1) res =  symbol->ref1->accept(*this);		\
   276   if (symbol->ref1) res =  symbol->ref1->accept(*this);		\
   277   if (res != NULL)  return res;					\
   277   if (res != NULL)  return res;					\
   278   if (symbol->ref2) res =  symbol->ref2->accept(*this);		\
   278   if (symbol->ref2) res =  symbol->ref2->accept(*this);		\
   281   if (res != NULL)  return res;					\
   281   if (res != NULL)  return res;					\
   282   if (symbol->ref4) return symbol->ref4->accept(*this);		\
   282   if (symbol->ref4) return symbol->ref4->accept(*this);		\
   283   return NULL;							\
   283   return NULL;							\
   284 }
   284 }
   285 
   285 
   286 #define SYM_REF5(class_name_c, ref1, ref2, ref3, ref4, ref5)		\
   286 #define SYM_REF5(class_name_c, ref1, ref2, ref3, ref4, ref5, ...)		\
   287 void *search_visitor_c::visit(class_name_c *symbol) {			\
   287 void *search_visitor_c::visit(class_name_c *symbol) {			\
   288   void *res = NULL;							\
   288   void *res = NULL;							\
   289   if (symbol->ref1) res =  symbol->ref1->accept(*this);			\
   289   if (symbol->ref1) res =  symbol->ref1->accept(*this);			\
   290   if (res != NULL)  return res;						\
   290   if (res != NULL)  return res;						\
   291   if (symbol->ref2) res =  symbol->ref2->accept(*this);			\
   291   if (symbol->ref2) res =  symbol->ref2->accept(*this);			\
   296   if (res != NULL)  return res;						\
   296   if (res != NULL)  return res;						\
   297   if (symbol->ref5) return symbol->ref5->accept(*this);			\
   297   if (symbol->ref5) return symbol->ref5->accept(*this);			\
   298   return NULL;								\
   298   return NULL;								\
   299 }
   299 }
   300 
   300 
   301 #define SYM_REF6(class_name_c, ref1, ref2, ref3, ref4, ref5, ref6)	\
   301 #define SYM_REF6(class_name_c, ref1, ref2, ref3, ref4, ref5, ref6, ...)	\
   302 void *search_visitor_c::visit(class_name_c *symbol) {			\
   302 void *search_visitor_c::visit(class_name_c *symbol) {			\
   303   void *res = NULL;							\
   303   void *res = NULL;							\
   304   if (symbol->ref1) res =  symbol->ref1->accept(*this);			\
   304   if (symbol->ref1) res =  symbol->ref1->accept(*this);			\
   305   if (res != NULL)  return res;						\
   305   if (res != NULL)  return res;						\
   306   if (symbol->ref2) res =  symbol->ref2->accept(*this);			\
   306   if (symbol->ref2) res =  symbol->ref2->accept(*this);			\