absyntax/absyntax.hh
changeset 350 2c3c4dc34979
parent 287 9df7fcb9bde5
child 417 d48f53715f77
equal deleted inserted replaced
341:ba80c3ceb6fb 350:2c3c4dc34979
   117 
   117 
   118     list_c(symbol_c *elem, 
   118     list_c(symbol_c *elem, 
   119            int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0, /* order in which it is read by lexcial analyser */
   119            int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0, /* order in which it is read by lexcial analyser */
   120            int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0  /* order in which it is read by lexcial analyser */
   120            int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0  /* order in which it is read by lexcial analyser */
   121           );
   121           );
   122      /* insert a new element */
   122      /* append a new element to the end of the list */
   123     virtual void add_element(symbol_c *elem);
   123     virtual void add_element(symbol_c *elem);
   124 };
   124      /* insert a new element before position pos. */
   125 
   125      /* To insert into the begining of list, call with pos=0  */
   126 
   126      /* To insert into the end of list, call with pos=list->n */
   127 
   127     virtual void insert_element(symbol_c *elem, int pos = 0);
   128 
   128 };
   129 #define SYM_LIST(class_name_c)												\
   129 
       
   130 
       
   131 
       
   132 
       
   133 #define SYM_LIST(class_name_c, ...)												\
   130 class class_name_c:	public list_c {											\
   134 class class_name_c:	public list_c {											\
   131   public:														\
   135   public:														\
       
   136     __VA_ARGS__														\
       
   137   public:														\
   132     class_name_c(													\
   138     class_name_c(													\
   133                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   139                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   134                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   140                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   135     class_name_c(symbol_c *elem, 											\
   141     class_name_c(symbol_c *elem, 											\
   136                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   142                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   137                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   143                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   138     virtual void *accept(visitor_c &visitor);										\
   144     virtual void *accept(visitor_c &visitor);										\
   139 };
   145 };
   140 
   146 
   141 
   147 
   142 #define SYM_TOKEN(class_name_c)												\
   148 #define SYM_TOKEN(class_name_c, ...)												\
   143 class class_name_c: 	public token_c {										\
   149 class class_name_c: 	public token_c {										\
   144   public:														\
   150   public:														\
       
   151     __VA_ARGS__														\
       
   152   public:														\
   145     class_name_c(const char *value, 											\
   153     class_name_c(const char *value, 											\
   146                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   154                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   147                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   155                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   148     virtual void *accept(visitor_c &visitor);										\
   156     virtual void *accept(visitor_c &visitor);										\
   149 };
   157 };
   150 
   158 
   151 
   159 
   152 #define SYM_REF0(class_name_c)												\
   160 #define SYM_REF0(class_name_c, ...)												\
   153 class class_name_c: public symbol_c {											\
   161 class class_name_c: public symbol_c {											\
       
   162   public:														\
       
   163     __VA_ARGS__														\
   154   public:														\
   164   public:														\
   155     class_name_c(		 											\
   165     class_name_c(		 											\
   156                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   166                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   157                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   167                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   158     virtual void *accept(visitor_c &visitor);										\
   168     virtual void *accept(visitor_c &visitor);										\
   159 };
   169 };
   160 
   170 
   161 
   171 
   162 #define SYM_REF1(class_name_c, ref1)											\
   172 #define SYM_REF1(class_name_c, ref1, ...)										\
   163 class class_name_c: public symbol_c {											\
   173 class class_name_c: public symbol_c {											\
   164   public:														\
   174   public:														\
   165     symbol_c *ref1;													\
   175     symbol_c *ref1;													\
   166   public:														\
   176     __VA_ARGS__														\
   167     class_name_c(symbol_c *ref1,											\
   177   public:														\
   168                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   178     class_name_c(symbol_c *ref1,											\
   169                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   179                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   170     virtual void *accept(visitor_c &visitor);										\
   180                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   171 };
   181     virtual void *accept(visitor_c &visitor);										\
   172 
   182 };
   173 
   183 
   174 #define SYM_REF2(class_name_c, ref1, ref2)										\
   184 
   175 class class_name_c: public symbol_c {											\
   185 #define SYM_REF2(class_name_c, ref1, ref2, ...)										\
   176   public:														\
   186 class class_name_c: public symbol_c {											\
   177     symbol_c *ref1;													\
   187   public:														\
   178     symbol_c *ref2;													\
   188     symbol_c *ref1;													\
       
   189     symbol_c *ref2;													\
       
   190     __VA_ARGS__														\
   179   public:														\
   191   public:														\
   180     class_name_c(symbol_c *ref1,											\
   192     class_name_c(symbol_c *ref1,											\
   181 		 symbol_c *ref2 = NULL,											\
   193 		 symbol_c *ref2 = NULL,											\
   182                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   194                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   183                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   195                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   184     virtual void *accept(visitor_c &visitor);										\
   196     virtual void *accept(visitor_c &visitor);										\
   185 };
   197 };
   186 
   198 
   187 
   199 
   188 #define SYM_REF3(class_name_c, ref1, ref2, ref3)									\
   200 #define SYM_REF3(class_name_c, ref1, ref2, ref3, ...)									\
   189 class class_name_c: public symbol_c {											\
   201 class class_name_c: public symbol_c {											\
   190   public:														\
   202   public:														\
   191     symbol_c *ref1;													\
   203     symbol_c *ref1;													\
   192     symbol_c *ref2;													\
   204     symbol_c *ref2;													\
   193     symbol_c *ref3;													\
   205     symbol_c *ref3;													\
   194   public:														\
   206     __VA_ARGS__														\
   195     class_name_c(symbol_c *ref1,											\
   207   public:														\
   196 		 symbol_c *ref2,											\
   208     class_name_c(symbol_c *ref1,											\
   197 		 symbol_c *ref3,											\
   209 		 symbol_c *ref2,											\
   198                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   210 		 symbol_c *ref3,											\
   199                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   211                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   200     virtual void *accept(visitor_c &visitor);										\
   212                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   201 };
   213     virtual void *accept(visitor_c &visitor);										\
   202 
   214 };
   203 
   215 
   204 #define SYM_REF4(class_name_c, ref1, ref2, ref3, ref4)									\
   216 
       
   217 #define SYM_REF4(class_name_c, ref1, ref2, ref3, ref4, ...)								\
   205 class class_name_c: public symbol_c {											\
   218 class class_name_c: public symbol_c {											\
   206   public:														\
   219   public:														\
   207     symbol_c *ref1;													\
   220     symbol_c *ref1;													\
   208     symbol_c *ref2;													\
   221     symbol_c *ref2;													\
   209     symbol_c *ref3;													\
   222     symbol_c *ref3;													\
   210     symbol_c *ref4;													\
   223     symbol_c *ref4;													\
       
   224     __VA_ARGS__														\
   211   public:														\
   225   public:														\
   212     class_name_c(symbol_c *ref1,											\
   226     class_name_c(symbol_c *ref1,											\
   213 		 symbol_c *ref2,											\
   227 		 symbol_c *ref2,											\
   214 		 symbol_c *ref3,											\
   228 		 symbol_c *ref3,											\
   215 		 symbol_c *ref4 = NULL,											\
   229 		 symbol_c *ref4 = NULL,											\
   217                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   231                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   218     virtual void *accept(visitor_c &visitor);										\
   232     virtual void *accept(visitor_c &visitor);										\
   219 };
   233 };
   220 
   234 
   221 
   235 
   222 #define SYM_REF5(class_name_c, ref1, ref2, ref3, ref4, ref5)								\
   236 #define SYM_REF5(class_name_c, ref1, ref2, ref3, ref4, ref5, ...)								\
   223 class class_name_c: public symbol_c {											\
   237 class class_name_c: public symbol_c {											\
   224   public:														\
   238   public:														\
   225     symbol_c *ref1;													\
   239     symbol_c *ref1;													\
   226     symbol_c *ref2;													\
   240     symbol_c *ref2;													\
   227     symbol_c *ref3;													\
   241     symbol_c *ref3;													\
   228     symbol_c *ref4;													\
   242     symbol_c *ref4;													\
   229     symbol_c *ref5;													\
   243     symbol_c *ref5;													\
       
   244     __VA_ARGS__														\
   230   public:														\
   245   public:														\
   231     class_name_c(symbol_c *ref1,											\
   246     class_name_c(symbol_c *ref1,											\
   232 		 symbol_c *ref2,											\
   247 		 symbol_c *ref2,											\
   233 		 symbol_c *ref3,											\
   248 		 symbol_c *ref3,											\
   234 		 symbol_c *ref4,											\
   249 		 symbol_c *ref4,											\
   237                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   252                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   238     virtual void *accept(visitor_c &visitor);										\
   253     virtual void *accept(visitor_c &visitor);										\
   239 };
   254 };
   240 
   255 
   241 
   256 
   242 #define SYM_REF6(class_name_c, ref1, ref2, ref3, ref4, ref5, ref6)							\
   257 #define SYM_REF6(class_name_c, ref1, ref2, ref3, ref4, ref5, ref6, ...)							\
   243 class class_name_c: public symbol_c {											\
   258 class class_name_c: public symbol_c {											\
   244   public:														\
   259   public:														\
   245     symbol_c *ref1;													\
   260     symbol_c *ref1;													\
   246     symbol_c *ref2;													\
   261     symbol_c *ref2;													\
   247     symbol_c *ref3;													\
   262     symbol_c *ref3;													\
   248     symbol_c *ref4;													\
   263     symbol_c *ref4;													\
   249     symbol_c *ref5;													\
   264     symbol_c *ref5;													\
   250     symbol_c *ref6;													\
   265     symbol_c *ref6;													\
       
   266     __VA_ARGS__														\
   251   public:														\
   267   public:														\
   252     class_name_c(symbol_c *ref1,											\
   268     class_name_c(symbol_c *ref1,											\
   253 		 symbol_c *ref2,											\
   269 		 symbol_c *ref2,											\
   254 		 symbol_c *ref3,											\
   270 		 symbol_c *ref3,											\
   255 		 symbol_c *ref4,											\
   271 		 symbol_c *ref4,											\