absyntax/absyntax.hh
changeset 350 2c3c4dc34979
parent 287 9df7fcb9bde5
child 417 d48f53715f77
--- a/absyntax/absyntax.hh	Mon Jul 11 09:47:27 2011 +0100
+++ b/absyntax/absyntax.hh	Fri Jul 29 16:03:28 2011 +0100
@@ -119,16 +119,22 @@
            int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0, /* order in which it is read by lexcial analyser */
            int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0  /* order in which it is read by lexcial analyser */
           );
-     /* insert a new element */
+     /* append a new element to the end of the list */
     virtual void add_element(symbol_c *elem);
-};
-
-
-
-
-#define SYM_LIST(class_name_c)												\
+     /* insert a new element before position pos. */
+     /* To insert into the begining of list, call with pos=0  */
+     /* To insert into the end of list, call with pos=list->n */
+    virtual void insert_element(symbol_c *elem, int pos = 0);
+};
+
+
+
+
+#define SYM_LIST(class_name_c, ...)												\
 class class_name_c:	public list_c {											\
   public:														\
+    __VA_ARGS__														\
+  public:														\
     class_name_c(													\
                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
@@ -139,9 +145,11 @@
 };
 
 
-#define SYM_TOKEN(class_name_c)												\
+#define SYM_TOKEN(class_name_c, ...)												\
 class class_name_c: 	public token_c {										\
   public:														\
+    __VA_ARGS__														\
+  public:														\
     class_name_c(const char *value, 											\
                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
                  int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
@@ -149,8 +157,10 @@
 };
 
 
-#define SYM_REF0(class_name_c)												\
-class class_name_c: public symbol_c {											\
+#define SYM_REF0(class_name_c, ...)												\
+class class_name_c: public symbol_c {											\
+  public:														\
+    __VA_ARGS__														\
   public:														\
     class_name_c(		 											\
                  int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
@@ -159,23 +169,25 @@
 };
 
 
-#define SYM_REF1(class_name_c, ref1)											\
-class class_name_c: public symbol_c {											\
-  public:														\
-    symbol_c *ref1;													\
-  public:														\
-    class_name_c(symbol_c *ref1,											\
-                 int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
-                 int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
-    virtual void *accept(visitor_c &visitor);										\
-};
-
-
-#define SYM_REF2(class_name_c, ref1, ref2)										\
-class class_name_c: public symbol_c {											\
-  public:														\
-    symbol_c *ref1;													\
-    symbol_c *ref2;													\
+#define SYM_REF1(class_name_c, ref1, ...)										\
+class class_name_c: public symbol_c {											\
+  public:														\
+    symbol_c *ref1;													\
+    __VA_ARGS__														\
+  public:														\
+    class_name_c(symbol_c *ref1,											\
+                 int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
+                 int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
+    virtual void *accept(visitor_c &visitor);										\
+};
+
+
+#define SYM_REF2(class_name_c, ref1, ref2, ...)										\
+class class_name_c: public symbol_c {											\
+  public:														\
+    symbol_c *ref1;													\
+    symbol_c *ref2;													\
+    __VA_ARGS__														\
   public:														\
     class_name_c(symbol_c *ref1,											\
 		 symbol_c *ref2 = NULL,											\
@@ -185,29 +197,31 @@
 };
 
 
-#define SYM_REF3(class_name_c, ref1, ref2, ref3)									\
-class class_name_c: public symbol_c {											\
-  public:														\
-    symbol_c *ref1;													\
-    symbol_c *ref2;													\
-    symbol_c *ref3;													\
-  public:														\
-    class_name_c(symbol_c *ref1,											\
-		 symbol_c *ref2,											\
-		 symbol_c *ref3,											\
-                 int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
-                 int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
-    virtual void *accept(visitor_c &visitor);										\
-};
-
-
-#define SYM_REF4(class_name_c, ref1, ref2, ref3, ref4)									\
+#define SYM_REF3(class_name_c, ref1, ref2, ref3, ...)									\
+class class_name_c: public symbol_c {											\
+  public:														\
+    symbol_c *ref1;													\
+    symbol_c *ref2;													\
+    symbol_c *ref3;													\
+    __VA_ARGS__														\
+  public:														\
+    class_name_c(symbol_c *ref1,											\
+		 symbol_c *ref2,											\
+		 symbol_c *ref3,											\
+                 int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
+                 int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
+    virtual void *accept(visitor_c &visitor);										\
+};
+
+
+#define SYM_REF4(class_name_c, ref1, ref2, ref3, ref4, ...)								\
 class class_name_c: public symbol_c {											\
   public:														\
     symbol_c *ref1;													\
     symbol_c *ref2;													\
     symbol_c *ref3;													\
     symbol_c *ref4;													\
+    __VA_ARGS__														\
   public:														\
     class_name_c(symbol_c *ref1,											\
 		 symbol_c *ref2,											\
@@ -219,7 +233,7 @@
 };
 
 
-#define SYM_REF5(class_name_c, ref1, ref2, ref3, ref4, ref5)								\
+#define SYM_REF5(class_name_c, ref1, ref2, ref3, ref4, ref5, ...)								\
 class class_name_c: public symbol_c {											\
   public:														\
     symbol_c *ref1;													\
@@ -227,6 +241,7 @@
     symbol_c *ref3;													\
     symbol_c *ref4;													\
     symbol_c *ref5;													\
+    __VA_ARGS__														\
   public:														\
     class_name_c(symbol_c *ref1,											\
 		 symbol_c *ref2,											\
@@ -239,7 +254,7 @@
 };
 
 
-#define SYM_REF6(class_name_c, ref1, ref2, ref3, ref4, ref5, ref6)							\
+#define SYM_REF6(class_name_c, ref1, ref2, ref3, ref4, ref5, ref6, ...)							\
 class class_name_c: public symbol_c {											\
   public:														\
     symbol_c *ref1;													\
@@ -248,6 +263,7 @@
     symbol_c *ref4;													\
     symbol_c *ref5;													\
     symbol_c *ref6;													\
+    __VA_ARGS__														\
   public:														\
     class_name_c(symbol_c *ref1,											\
 		 symbol_c *ref2,											\