absyntax/absyntax.hh
changeset 293 e53b93cd90e4
parent 287 9df7fcb9bde5
child 350 2c3c4dc34979
equal deleted inserted replaced
292:a1d9c206409e 293:e53b93cd90e4
    68     /*
    68     /*
    69      * Line number for the purposes of error checking
    69      * Line number for the purposes of error checking
    70      */
    70      */
    71     int first_line;
    71     int first_line;
    72     int first_column;
    72     int first_column;
       
    73     const char *first_file;  /* filename referenced by first line/column */
       
    74     long int first_order;    /* relative order in which it is read by lexcial analyser */
    73     int last_line;
    75     int last_line;
    74     int last_column;
    76     int last_column;
       
    77     const char *last_file;  /* filename referenced by last line/column */
       
    78     long int last_order;    /* relative order in which it is read by lexcial analyser */
    75 
    79 
    76   public:
    80   public:
    77     /* default constructor */
    81     /* default constructor */
    78     symbol_c(void);
    82     symbol_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 */
    79     symbol_c(int fl     /* first_line   */, 
    83              int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0  /* order in which it is read by lexcial analyser */
    80              int fc     /* first_column */,
       
    81              int ll = 0 /* last_line    */,
       
    82              int lc = 0 /* last_column  */
       
    83             );
    84             );
    84 
    85 
    85     /* default destructor */
    86     /* default destructor */
    86     /* must be virtual so compiler does not complain... */ 
    87     /* must be virtual so compiler does not complain... */ 
    87     virtual ~symbol_c(void) {return;};
    88     virtual ~symbol_c(void) {return;};
    94   public:
    95   public:
    95     /* the value of the symbol. */
    96     /* the value of the symbol. */
    96     const char *value;
    97     const char *value;
    97 
    98 
    98   public:
    99   public:
    99     token_c(const char *value, int fl = 0, int fc = 0, int ll = 0, int lc = 0);
   100     token_c(const char *value, 
       
   101             int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0, /* order in which it is read by lexcial analyser */
       
   102             int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0  /* order in which it is read by lexcial analyser */
       
   103            );
   100 };
   104 };
   101 
   105 
   102 
   106 
   103  /* a list of symbols... */
   107  /* a list of symbols... */
   104 class list_c: public symbol_c {
   108 class list_c: public symbol_c {
   105   public:
   109   public:
   106     int n;
   110     int n;
   107     symbol_c **elements;
   111     symbol_c **elements;
   108 
   112 
   109   public:
   113   public:
   110     list_c(int fl = 0, int fc = 0, int ll = 0, int lc = 0);
   114     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 */
   111     list_c(symbol_c *elem, int fl = 0, int fc = 0, int ll = 0, int lc = 0);
   115            int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0  /* order in which it is read by lexcial analyser */
       
   116           );
       
   117 
       
   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 */
       
   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           );
   112      /* insert a new element */
   122      /* insert a new element */
   113     virtual void add_element(symbol_c *elem);
   123     virtual void add_element(symbol_c *elem);
   114 };
   124 };
   115 
   125 
   116 
   126 
   117 
   127 
   118 
   128 
   119 #define SYM_LIST(class_name_c)								\
   129 #define SYM_LIST(class_name_c)												\
   120 class class_name_c:	public list_c {							\
   130 class class_name_c:	public list_c {											\
   121   public:										\
   131   public:														\
   122     class_name_c(int fl = 0, int fc = 0, int ll = 0, int lc = 0);			\
   132     class_name_c(													\
   123     class_name_c(symbol_c *elem, int fl = 0, int fc = 0, int ll = 0, int lc = 0);	\
   133                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   124     virtual void *accept(visitor_c &visitor);						\
   134                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   125 };
   135     class_name_c(symbol_c *elem, 											\
   126 
   136                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   127 
   137                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   128 #define SYM_TOKEN(class_name_c)								\
   138     virtual void *accept(visitor_c &visitor);										\
   129 class class_name_c: 	public token_c {						\
   139 };
   130   public:										\
   140 
   131     class_name_c(const char *value, int fl = 0, int fc = 0, int ll = 0, int lc = 0);	\
   141 
   132     virtual void *accept(visitor_c &visitor);						\
   142 #define SYM_TOKEN(class_name_c)												\
   133 };
   143 class class_name_c: 	public token_c {										\
   134 
   144   public:														\
   135 
   145     class_name_c(const char *value, 											\
   136 #define SYM_REF0(class_name_c)			\
   146                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   137 class class_name_c: public symbol_c {		\
   147                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   138   public:					\
   148     virtual void *accept(visitor_c &visitor);										\
   139     class_name_c(int fl = 0, int fc = 0, 	\
   149 };
   140 		 int ll = 0, int lc = 0);	\
   150 
   141     virtual void *accept(visitor_c &visitor);	\
   151 
   142 };
   152 #define SYM_REF0(class_name_c)												\
   143 
   153 class class_name_c: public symbol_c {											\
   144 
   154   public:														\
   145 #define SYM_REF1(class_name_c, ref1)			\
   155     class_name_c(		 											\
   146 class class_name_c: public symbol_c {			\
   156                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   147   public:						\
   157                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   148     symbol_c *ref1;					\
   158     virtual void *accept(visitor_c &visitor);										\
   149   public:						\
   159 };
   150     class_name_c(symbol_c *ref1,			\
   160 
   151 		 int fl = 0, int fc = 0, 		\
   161 
   152 		 int ll = 0, int lc = 0);		\
   162 #define SYM_REF1(class_name_c, ref1)											\
   153     virtual void *accept(visitor_c &visitor);		\
   163 class class_name_c: public symbol_c {											\
   154 };
   164   public:														\
   155 
   165     symbol_c *ref1;													\
   156 
   166   public:														\
   157 #define SYM_REF2(class_name_c, ref1, ref2)		\
   167     class_name_c(symbol_c *ref1,											\
   158 class class_name_c: public symbol_c {			\
   168                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   159   public:						\
   169                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   160     symbol_c *ref1;					\
   170     virtual void *accept(visitor_c &visitor);										\
   161     symbol_c *ref2;					\
   171 };
   162   public:						\
   172 
   163     class_name_c(symbol_c *ref1,			\
   173 
   164 		 symbol_c *ref2 = NULL,			\
   174 #define SYM_REF2(class_name_c, ref1, ref2)										\
   165 		 int fl = 0, int fc = 0, 		\
   175 class class_name_c: public symbol_c {											\
   166 		 int ll = 0, int lc = 0);		\
   176   public:														\
   167     virtual void *accept(visitor_c &visitor);		\
   177     symbol_c *ref1;													\
   168 };
   178     symbol_c *ref2;													\
   169 
   179   public:														\
   170 
   180     class_name_c(symbol_c *ref1,											\
   171 #define SYM_REF3(class_name_c, ref1, ref2, ref3)	\
   181 		 symbol_c *ref2 = NULL,											\
   172 class class_name_c: public symbol_c {			\
   182                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   173   public:						\
   183                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   174     symbol_c *ref1;					\
   184     virtual void *accept(visitor_c &visitor);										\
   175     symbol_c *ref2;					\
   185 };
   176     symbol_c *ref3;					\
   186 
   177   public:						\
   187 
   178     class_name_c(symbol_c *ref1,			\
   188 #define SYM_REF3(class_name_c, ref1, ref2, ref3)									\
   179 		 symbol_c *ref2,			\
   189 class class_name_c: public symbol_c {											\
   180 		 symbol_c *ref3,			\
   190   public:														\
   181 		 int fl = 0, int fc = 0, 		\
   191     symbol_c *ref1;													\
   182 		 int ll = 0, int lc = 0);		\
   192     symbol_c *ref2;													\
   183     virtual void *accept(visitor_c &visitor);		\
   193     symbol_c *ref3;													\
   184 };
   194   public:														\
   185 
   195     class_name_c(symbol_c *ref1,											\
   186 
   196 		 symbol_c *ref2,											\
   187 #define SYM_REF4(class_name_c, ref1, ref2, ref3, ref4)	\
   197 		 symbol_c *ref3,											\
   188 class class_name_c: public symbol_c {			\
   198                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   189   public:						\
   199                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   190     symbol_c *ref1;					\
   200     virtual void *accept(visitor_c &visitor);										\
   191     symbol_c *ref2;					\
   201 };
   192     symbol_c *ref3;					\
   202 
   193     symbol_c *ref4;					\
   203 
   194   public:						\
   204 #define SYM_REF4(class_name_c, ref1, ref2, ref3, ref4)									\
   195     class_name_c(symbol_c *ref1,			\
   205 class class_name_c: public symbol_c {											\
   196 		 symbol_c *ref2,			\
   206   public:														\
   197 		 symbol_c *ref3,			\
   207     symbol_c *ref1;													\
   198 		 symbol_c *ref4 = NULL,			\
   208     symbol_c *ref2;													\
   199 		 int fl = 0, int fc = 0, 		\
   209     symbol_c *ref3;													\
   200 		 int ll = 0, int lc = 0);		\
   210     symbol_c *ref4;													\
   201     virtual void *accept(visitor_c &visitor);		\
   211   public:														\
   202 };
   212     class_name_c(symbol_c *ref1,											\
   203 
   213 		 symbol_c *ref2,											\
   204 
   214 		 symbol_c *ref3,											\
   205 #define SYM_REF5(class_name_c, ref1, ref2, ref3, ref4, ref5)		\
   215 		 symbol_c *ref4 = NULL,											\
   206 class class_name_c: public symbol_c {					\
   216                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   207   public:								\
   217                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   208     symbol_c *ref1;							\
   218     virtual void *accept(visitor_c &visitor);										\
   209     symbol_c *ref2;							\
   219 };
   210     symbol_c *ref3;							\
   220 
   211     symbol_c *ref4;							\
   221 
   212     symbol_c *ref5;							\
   222 #define SYM_REF5(class_name_c, ref1, ref2, ref3, ref4, ref5)								\
   213   public:								\
   223 class class_name_c: public symbol_c {											\
   214     class_name_c(symbol_c *ref1,					\
   224   public:														\
   215 		 symbol_c *ref2,					\
   225     symbol_c *ref1;													\
   216 		 symbol_c *ref3,					\
   226     symbol_c *ref2;													\
   217 		 symbol_c *ref4,					\
   227     symbol_c *ref3;													\
   218 		 symbol_c *ref5,					\
   228     symbol_c *ref4;													\
   219 		 int fl = 0, int fc = 0, 				\
   229     symbol_c *ref5;													\
   220 		 int ll = 0, int lc = 0);				\
   230   public:														\
   221     virtual void *accept(visitor_c &visitor);				\
   231     class_name_c(symbol_c *ref1,											\
   222 };
   232 		 symbol_c *ref2,											\
   223 
   233 		 symbol_c *ref3,											\
   224 
   234 		 symbol_c *ref4,											\
   225 #define SYM_REF6(class_name_c, ref1, ref2, ref3, ref4, ref5, ref6)	\
   235 		 symbol_c *ref5,											\
   226 class class_name_c: public symbol_c {					\
   236                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
   227   public:								\
   237                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
   228     symbol_c *ref1;							\
   238     virtual void *accept(visitor_c &visitor);										\
   229     symbol_c *ref2;							\
   239 };
   230     symbol_c *ref3;							\
   240 
   231     symbol_c *ref4;							\
   241 
   232     symbol_c *ref5;							\
   242 #define SYM_REF6(class_name_c, ref1, ref2, ref3, ref4, ref5, ref6)							\
   233     symbol_c *ref6;							\
   243 class class_name_c: public symbol_c {											\
   234   public:								\
   244   public:														\
   235     class_name_c(symbol_c *ref1,					\
   245     symbol_c *ref1;													\
   236 		 symbol_c *ref2,					\
   246     symbol_c *ref2;													\
   237 		 symbol_c *ref3,					\
   247     symbol_c *ref3;													\
   238 		 symbol_c *ref4,					\
   248     symbol_c *ref4;													\
   239 		 symbol_c *ref5,					\
   249     symbol_c *ref5;													\
   240 		 symbol_c *ref6 = NULL,					\
   250     symbol_c *ref6;													\
   241 		 int fl = 0, int fc = 0, 				\
   251   public:														\
   242 		 int ll = 0, int lc = 0);				\
   252     class_name_c(symbol_c *ref1,											\
   243     virtual void *accept(visitor_c &visitor);				\
   253 		 symbol_c *ref2,											\
       
   254 		 symbol_c *ref3,											\
       
   255 		 symbol_c *ref4,											\
       
   256 		 symbol_c *ref5,											\
       
   257 		 symbol_c *ref6 = NULL,											\
       
   258                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
       
   259                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
       
   260     virtual void *accept(visitor_c &visitor);										\
   244 };
   261 };
   245 
   262 
   246 
   263 
   247 #include "absyntax.def"
   264 #include "absyntax.def"
   248 
   265