absyntax/absyntax.hh
changeset 659 165aa7b87e0d
parent 655 a77514dd0040
child 738 e47cc8c954db
equal deleted inserted replaced
658:fe5e1f01a49e 659:165aa7b87e0d
    78 
    78 
    79 /* The base class of all symbols */
    79 /* The base class of all symbols */
    80 class symbol_c {
    80 class symbol_c {
    81 
    81 
    82   public:
    82   public:
       
    83     /* WARNING: only use this method for debugging purposes!! */
       
    84     virtual const char *absyntax_cname(void) {return "symbol_c";};
       
    85 
    83     /*
    86     /*
    84      * Line number for the purposes of error checking.
    87      * Line number for the purposes of error checking.
    85      * Annotated (inserted) by stage1_2
    88      * Annotated (inserted) by stage1_2
    86      */
    89      */
    87     int first_line;
    90     int first_line;
   150 };
   153 };
   151 
   154 
   152 
   155 
   153 class token_c: public symbol_c {
   156 class token_c: public symbol_c {
   154   public:
   157   public:
       
   158     /* WARNING: only use this method for debugging purposes!! */
       
   159     virtual const char *absyntax_cname(void) {return "token_c";};
       
   160 
   155     /* the value of the symbol. */
   161     /* the value of the symbol. */
   156     const char *value;
   162     const char *value;
   157 
   163 
   158   public:
   164   public:
   159     token_c(const char *value, 
   165     token_c(const char *value, 
   164 
   170 
   165 
   171 
   166  /* a list of symbols... */
   172  /* a list of symbols... */
   167 class list_c: public symbol_c {
   173 class list_c: public symbol_c {
   168   public:
   174   public:
       
   175     /* WARNING: only use this method for debugging purposes!! */
       
   176     virtual const char *absyntax_cname(void) {return "list_c";};
       
   177 
   169     int c,n; /* c: current capacity of list (malloc'd memory);  n: current number of elements in list */
   178     int c,n; /* c: current capacity of list (malloc'd memory);  n: current number of elements in list */
   170     symbol_c **elements;
   179     symbol_c **elements;
   171 
   180 
   172   public:
   181   public:
   173     list_c(int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0, /* order in which it is read by lexcial analyser */
   182     list_c(int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0, /* order in which it is read by lexcial analyser */
   201                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   210                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   202     class_name_c(symbol_c *elem, 											\
   211     class_name_c(symbol_c *elem, 											\
   203                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   212                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   204                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   213                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   205     virtual void *accept(visitor_c &visitor);										\
   214     virtual void *accept(visitor_c &visitor);										\
       
   215     /* WARNING: only use this method for debugging purposes!! */							\
       
   216     virtual const char *absyntax_cname(void) {return #class_name_c;};							\
   206 };
   217 };
   207 
   218 
   208 
   219 
   209 #define SYM_TOKEN(class_name_c, ...)											\
   220 #define SYM_TOKEN(class_name_c, ...)											\
   210 class class_name_c: 	public token_c {										\
   221 class class_name_c: 	public token_c {										\
   213   public:														\
   224   public:														\
   214     class_name_c(const char *value, 											\
   225     class_name_c(const char *value, 											\
   215                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   226                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   216                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   227                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   217     virtual void *accept(visitor_c &visitor);										\
   228     virtual void *accept(visitor_c &visitor);										\
       
   229     /* WARNING: only use this method for debugging purposes!! */							\
       
   230     virtual const char *absyntax_cname(void) {return #class_name_c;};							\
   218 };
   231 };
   219 
   232 
   220 
   233 
   221 #define SYM_REF0(class_name_c, ...)											\
   234 #define SYM_REF0(class_name_c, ...)											\
   222 class class_name_c: public symbol_c {											\
   235 class class_name_c: public symbol_c {											\
   225   public:														\
   238   public:														\
   226     class_name_c(		 											\
   239     class_name_c(		 											\
   227                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   240                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   228                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   241                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   229     virtual void *accept(visitor_c &visitor);										\
   242     virtual void *accept(visitor_c &visitor);										\
       
   243     /* WARNING: only use this method for debugging purposes!! */							\
       
   244     virtual const char *absyntax_cname(void) {return #class_name_c;};							\
   230 };
   245 };
   231 
   246 
   232 
   247 
   233 #define SYM_REF1(class_name_c, ref1, ...)										\
   248 #define SYM_REF1(class_name_c, ref1, ...)										\
   234 class class_name_c: public symbol_c {											\
   249 class class_name_c: public symbol_c {											\
   238   public:														\
   253   public:														\
   239     class_name_c(symbol_c *ref1,											\
   254     class_name_c(symbol_c *ref1,											\
   240                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   255                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   241                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   256                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   242     virtual void *accept(visitor_c &visitor);										\
   257     virtual void *accept(visitor_c &visitor);										\
       
   258     /* WARNING: only use this method for debugging purposes!! */							\
       
   259     virtual const char *absyntax_cname(void) {return #class_name_c;};							\
   243 };
   260 };
   244 
   261 
   245 
   262 
   246 #define SYM_REF2(class_name_c, ref1, ref2, ...)										\
   263 #define SYM_REF2(class_name_c, ref1, ref2, ...)										\
   247 class class_name_c: public symbol_c {											\
   264 class class_name_c: public symbol_c {											\
   253     class_name_c(symbol_c *ref1,											\
   270     class_name_c(symbol_c *ref1,											\
   254 		 symbol_c *ref2 = NULL,											\
   271 		 symbol_c *ref2 = NULL,											\
   255                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   272                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   256                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   273                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   257     virtual void *accept(visitor_c &visitor);										\
   274     virtual void *accept(visitor_c &visitor);										\
       
   275     /* WARNING: only use this method for debugging purposes!! */							\
       
   276     virtual const char *absyntax_cname(void) {return #class_name_c;};							\
   258 };
   277 };
   259 
   278 
   260 
   279 
   261 #define SYM_REF3(class_name_c, ref1, ref2, ref3, ...)									\
   280 #define SYM_REF3(class_name_c, ref1, ref2, ref3, ...)									\
   262 class class_name_c: public symbol_c {											\
   281 class class_name_c: public symbol_c {											\
   270 		 symbol_c *ref2,											\
   289 		 symbol_c *ref2,											\
   271 		 symbol_c *ref3,											\
   290 		 symbol_c *ref3,											\
   272                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   291                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   273                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   292                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   274     virtual void *accept(visitor_c &visitor);										\
   293     virtual void *accept(visitor_c &visitor);										\
       
   294     /* WARNING: only use this method for debugging purposes!! */							\
       
   295     virtual const char *absyntax_cname(void) {return #class_name_c;};							\
   275 };
   296 };
   276 
   297 
   277 
   298 
   278 #define SYM_REF4(class_name_c, ref1, ref2, ref3, ref4, ...)								\
   299 #define SYM_REF4(class_name_c, ref1, ref2, ref3, ref4, ...)								\
   279 class class_name_c: public symbol_c {											\
   300 class class_name_c: public symbol_c {											\
   289 		 symbol_c *ref3,											\
   310 		 symbol_c *ref3,											\
   290 		 symbol_c *ref4 = NULL,											\
   311 		 symbol_c *ref4 = NULL,											\
   291                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   312                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   292                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   313                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   293     virtual void *accept(visitor_c &visitor);										\
   314     virtual void *accept(visitor_c &visitor);										\
       
   315     /* WARNING: only use this method for debugging purposes!! */							\
       
   316     virtual const char *absyntax_cname(void) {return #class_name_c;};							\
   294 };
   317 };
   295 
   318 
   296 
   319 
   297 #define SYM_REF5(class_name_c, ref1, ref2, ref3, ref4, ref5, ...)							\
   320 #define SYM_REF5(class_name_c, ref1, ref2, ref3, ref4, ref5, ...)							\
   298 class class_name_c: public symbol_c {											\
   321 class class_name_c: public symbol_c {											\
   310 		 symbol_c *ref4,											\
   333 		 symbol_c *ref4,											\
   311 		 symbol_c *ref5,											\
   334 		 symbol_c *ref5,											\
   312                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   335                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   313                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   336                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   314     virtual void *accept(visitor_c &visitor);										\
   337     virtual void *accept(visitor_c &visitor);										\
       
   338     /* WARNING: only use this method for debugging purposes!! */							\
       
   339     virtual const char *absyntax_cname(void) {return #class_name_c;};							\
   315 };
   340 };
   316 
   341 
   317 
   342 
   318 #define SYM_REF6(class_name_c, ref1, ref2, ref3, ref4, ref5, ref6, ...)							\
   343 #define SYM_REF6(class_name_c, ref1, ref2, ref3, ref4, ref5, ref6, ...)							\
   319 class class_name_c: public symbol_c {											\
   344 class class_name_c: public symbol_c {											\
   333 		 symbol_c *ref5,											\
   358 		 symbol_c *ref5,											\
   334 		 symbol_c *ref6 = NULL,											\
   359 		 symbol_c *ref6 = NULL,											\
   335                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   360                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   336                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   361                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   337     virtual void *accept(visitor_c &visitor);										\
   362     virtual void *accept(visitor_c &visitor);										\
       
   363     /* WARNING: only use this method for debugging purposes!! */							\
       
   364     virtual const char *absyntax_cname(void) {return #class_name_c;};							\
   338 };
   365 };
   339 
   366 
   340 
   367 
   341 #include "absyntax.def"
   368 #include "absyntax.def"
   342 
   369