Merged with Edouard's modifications
authorlaurent
Mon, 16 May 2011 12:36:21 +0200
changeset 293 e53b93cd90e4
parent 292 a1d9c206409e (current diff)
parent 291 1b0686c546ab (diff)
child 294 aae14da3c296
Merged with Edouard's modifications
--- a/absyntax/absyntax.cc	Mon May 16 11:57:41 2011 +0200
+++ b/absyntax/absyntax.cc	Mon May 16 12:36:21 2011 +0200
@@ -49,24 +49,25 @@
 
 
 /* The base class of all symbols */
-symbol_c::symbol_c(void) {
-  this->first_line   = 0;
-  this->first_column = 0;
-  this->last_line    = 0;
-  this->last_column  = 0;
-}
-
-symbol_c::symbol_c(int first_line, int first_column, int last_line, int last_column) {
+symbol_c::symbol_c(
+                   int first_line, int first_column, const char *ffile, long int first_order,
+                   int last_line,  int last_column,  const char *lfile, long int last_order ) {
+  this->first_file   = ffile,
   this->first_line   = first_line;
   this->first_column = first_column;
+  this->first_order  = first_order;
+  this->last_file    = lfile,
   this->last_line    = last_line;
   this->last_column  = last_column;
-}
-
-
-
-token_c::token_c(const char *value, int fl, int fc, int ll, int lc)
-  :symbol_c(fl, fc, ll, lc) {
+  this->last_order   = last_order;
+}
+
+
+
+token_c::token_c(const char *value, 
+                 int fl, int fc, const char *ffile, long int forder,
+                 int ll, int lc, const char *lfile, long int lorder)
+  :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) {
   this->value = value;
 //  printf("New token: %s\n", value);
 }
@@ -76,14 +77,18 @@
 
 
 
-list_c::list_c(int fl, int fc, int ll, int lc)
-  :symbol_c(fl, fc, ll, lc) {
+list_c::list_c(
+               int fl, int fc, const char *ffile, long int forder,
+               int ll, int lc, const char *lfile, long int lorder)
+  :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) {
   n = 0;
   elements = NULL;
 }
 
-list_c::list_c(symbol_c *elem, int fl, int fc, int ll, int lc)
-  :symbol_c(fl, fc, ll, lc) {
+list_c::list_c(symbol_c *elem, 
+               int fl, int fc, const char *ffile, long int forder,
+               int ll, int lc, const char *lfile, long int lorder)
+  :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) {
   n = 0;
   elements = NULL;
   add_element(elem);
@@ -123,113 +128,120 @@
 
 
 
-#define SYM_LIST(class_name_c)							\
-class_name_c::class_name_c(int fl, int fc, int ll, int lc)			\
-			:list_c(fl, fc, ll, lc) {}				\
-class_name_c::class_name_c(symbol_c *elem, int fl, int fc, int ll, int lc)	\
-			:list_c(elem, fl, fc, ll, lc) {}			\
-void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
-
-#define SYM_TOKEN(class_name_c)							\
-class_name_c::class_name_c(const char *value, int fl, int fc, int ll, int lc)	\
-			:token_c(value, fl, fc, ll, lc) {}			\
-void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
-
-#define SYM_REF0(class_name_c)					\
-class_name_c::class_name_c(int fl, int fc,			\
-			   int ll, int lc			\
-			  ): symbol_c(fl, fc, ll, lc) {}	\
-void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
-
-
-#define SYM_REF1(class_name_c, ref1)			\
-class_name_c::class_name_c(symbol_c *ref1,		\
-			   int fl, int fc,		\
-			   int ll, int lc		\
-			  ): symbol_c(fl, fc, ll, lc) {	\
-  this->ref1 = ref1;					\
-}							\
-void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
-
-
-#define SYM_REF2(class_name_c, ref1, ref2)		\
-class_name_c::class_name_c(symbol_c *ref1,		\
-			   symbol_c *ref2,		\
-			   int fl, int fc,		\
-			   int ll, int lc		\
-			  ): symbol_c(fl, fc, ll, lc) {	\
-  this->ref1 = ref1;					\
-  this->ref2 = ref2;					\
-}							\
-void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
-
-
-#define SYM_REF3(class_name_c, ref1, ref2, ref3)	\
-class_name_c::class_name_c(symbol_c *ref1,		\
-			   symbol_c *ref2,		\
-			   symbol_c *ref3,		\
-			   int fl, int fc,		\
-			   int ll, int lc		\
-			  ): symbol_c(fl, fc, ll, lc) {	\
-  this->ref1 = ref1;					\
-  this->ref2 = ref2;					\
-  this->ref3 = ref3;					\
-}							\
-void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
-
-
-#define SYM_REF4(class_name_c, ref1, ref2, ref3, ref4)	\
-class_name_c::class_name_c(symbol_c *ref1,		\
-			   symbol_c *ref2,		\
-			   symbol_c *ref3,		\
-			   symbol_c *ref4,		\
-			   int fl, int fc,		\
-			   int ll, int lc		\
-			  ): symbol_c(fl, fc, ll, lc) {	\
-  this->ref1 = ref1;					\
-  this->ref2 = ref2;					\
-  this->ref3 = ref3;					\
-  this->ref4 = ref4;					\
-}							\
-void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
-
-
-#define SYM_REF5(class_name_c, ref1, ref2, ref3, ref4, ref5)		\
-class_name_c::class_name_c(symbol_c *ref1,				\
-			   symbol_c *ref2,				\
-			   symbol_c *ref3,				\
-			   symbol_c *ref4,				\
-			   symbol_c *ref5,				\
-			   int fl, int fc,				\
-			   int ll, int lc				\
-			  ): symbol_c(fl, fc, ll, lc) {			\
-  this->ref1 = ref1;							\
-  this->ref2 = ref2;							\
-  this->ref3 = ref3;							\
-  this->ref4 = ref4;							\
-  this->ref5 = ref5;							\
-}									\
-void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
-
-
-
-#define SYM_REF6(class_name_c, ref1, ref2, ref3, ref4, ref5, ref6)	\
-class_name_c::class_name_c(symbol_c *ref1,				\
-			   symbol_c *ref2,				\
-			   symbol_c *ref3,				\
-			   symbol_c *ref4,				\
-			   symbol_c *ref5,				\
-			   symbol_c *ref6,				\
-			   int fl, int fc,				\
-			   int ll, int lc				\
-			  ): symbol_c(fl, fc, ll, lc) {			\
-  this->ref1 = ref1;							\
-  this->ref2 = ref2;							\
-  this->ref3 = ref3;							\
-  this->ref4 = ref4;							\
-  this->ref5 = ref5;							\
-  this->ref6 = ref6;							\
-}									\
+#define SYM_LIST(class_name_c)									\
+class_name_c::class_name_c(									\
+                           int fl, int fc, const char *ffile, long int forder,			\
+                           int ll, int lc, const char *lfile, long int lorder)			\
+                        :list_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) {}		\
+class_name_c::class_name_c(symbol_c *elem, 							\
+                           int fl, int fc, const char *ffile, long int forder,			\
+                           int ll, int lc, const char *lfile, long int lorder)			\
+			:list_c(elem, fl, fc, ffile, forder, ll, lc, lfile, lorder) {}		\
+void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
+
+#define SYM_TOKEN(class_name_c)									\
+class_name_c::class_name_c(const char *value, 							\
+                           int fl, int fc, const char *ffile, long int forder,			\
+                           int ll, int lc, const char *lfile, long int lorder)			\
+			:token_c(value, fl, fc, ffile, forder, ll, lc, lfile, lorder) {}	\
+void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
+
+#define SYM_REF0(class_name_c)									\
+class_name_c::class_name_c(									\
+                           int fl, int fc, const char *ffile, long int forder,			\
+                           int ll, int lc, const char *lfile, long int lorder)			\
+			  :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) {}		\
+void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
+
+
+#define SYM_REF1(class_name_c, ref1)								\
+class_name_c::class_name_c(symbol_c *ref1,							\
+                           int fl, int fc, const char *ffile, long int forder,			\
+                           int ll, int lc, const char *lfile, long int lorder)			\
+			  :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) {		\
+  this->ref1 = ref1;										\
+}												\
+void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
+
+
+#define SYM_REF2(class_name_c, ref1, ref2)							\
+class_name_c::class_name_c(symbol_c *ref1,							\
+			   symbol_c *ref2,							\
+                           int fl, int fc, const char *ffile, long int forder,			\
+                           int ll, int lc, const char *lfile, long int lorder)			\
+			  :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) {		\
+  this->ref1 = ref1;										\
+  this->ref2 = ref2;										\
+}												\
+void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
+
+
+#define SYM_REF3(class_name_c, ref1, ref2, ref3)						\
+class_name_c::class_name_c(symbol_c *ref1,							\
+			   symbol_c *ref2,							\
+			   symbol_c *ref3,							\
+                           int fl, int fc, const char *ffile, long int forder,			\
+                           int ll, int lc, const char *lfile, long int lorder)			\
+			  :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) {		\
+  this->ref1 = ref1;										\
+  this->ref2 = ref2;										\
+  this->ref3 = ref3;										\
+}												\
+void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
+
+
+#define SYM_REF4(class_name_c, ref1, ref2, ref3, ref4)						\
+class_name_c::class_name_c(symbol_c *ref1,							\
+			   symbol_c *ref2,							\
+			   symbol_c *ref3,							\
+			   symbol_c *ref4,							\
+                           int fl, int fc, const char *ffile, long int forder,			\
+                           int ll, int lc, const char *lfile, long int lorder)			\
+			  :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) {		\
+  this->ref1 = ref1;										\
+  this->ref2 = ref2;										\
+  this->ref3 = ref3;										\
+  this->ref4 = ref4;										\
+}												\
+void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
+
+
+#define SYM_REF5(class_name_c, ref1, ref2, ref3, ref4, ref5)					\
+class_name_c::class_name_c(symbol_c *ref1,							\
+			   symbol_c *ref2,							\
+			   symbol_c *ref3,							\
+			   symbol_c *ref4,							\
+			   symbol_c *ref5,							\
+                           int fl, int fc, const char *ffile, long int forder,			\
+                           int ll, int lc, const char *lfile, long int lorder)			\
+			  :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) {		\
+  this->ref1 = ref1;										\
+  this->ref2 = ref2;										\
+  this->ref3 = ref3;										\
+  this->ref4 = ref4;										\
+  this->ref5 = ref5;										\
+}												\
+void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
+
+
+
+#define SYM_REF6(class_name_c, ref1, ref2, ref3, ref4, ref5, ref6)				\
+class_name_c::class_name_c(symbol_c *ref1,							\
+			   symbol_c *ref2,							\
+			   symbol_c *ref3,							\
+			   symbol_c *ref4,							\
+			   symbol_c *ref5,							\
+			   symbol_c *ref6,							\
+                           int fl, int fc, const char *ffile, long int forder,			\
+                           int ll, int lc, const char *lfile, long int lorder)			\
+			  :symbol_c(fl, fc, ffile, forder, ll, lc, lfile, lorder) {		\
+  this->ref1 = ref1;										\
+  this->ref2 = ref2;										\
+  this->ref3 = ref3;										\
+  this->ref4 = ref4;										\
+  this->ref5 = ref5;										\
+  this->ref6 = ref6;										\
+}												\
 void *class_name_c::accept(visitor_c &visitor) {return visitor.visit(this);}
 
 
--- a/absyntax/absyntax.hh	Mon May 16 11:57:41 2011 +0200
+++ b/absyntax/absyntax.hh	Mon May 16 12:36:21 2011 +0200
@@ -70,16 +70,17 @@
      */
     int first_line;
     int first_column;
+    const char *first_file;  /* filename referenced by first line/column */
+    long int first_order;    /* relative order in which it is read by lexcial analyser */
     int last_line;
     int last_column;
+    const char *last_file;  /* filename referenced by last line/column */
+    long int last_order;    /* relative order in which it is read by lexcial analyser */
 
   public:
     /* default constructor */
-    symbol_c(void);
-    symbol_c(int fl     /* first_line   */, 
-             int fc     /* first_column */,
-             int ll = 0 /* last_line    */,
-             int lc = 0 /* last_column  */
+    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 */
+             int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0  /* order in which it is read by lexcial analyser */
             );
 
     /* default destructor */
@@ -96,7 +97,10 @@
     const char *value;
 
   public:
-    token_c(const char *value, int fl = 0, int fc = 0, int ll = 0, int lc = 0);
+    token_c(const char *value, 
+            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 */
+           );
 };
 
 
@@ -107,8 +111,14 @@
     symbol_c **elements;
 
   public:
-    list_c(int fl = 0, int fc = 0, int ll = 0, int lc = 0);
-    list_c(symbol_c *elem, int fl = 0, int fc = 0, int ll = 0, int lc = 0);
+    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 */
+           int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0  /* order in which it is read by lexcial analyser */
+          );
+
+    list_c(symbol_c *elem, 
+           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 */
     virtual void add_element(symbol_c *elem);
 };
@@ -116,131 +126,138 @@
 
 
 
-#define SYM_LIST(class_name_c)								\
-class class_name_c:	public list_c {							\
-  public:										\
-    class_name_c(int fl = 0, int fc = 0, int ll = 0, int lc = 0);			\
-    class_name_c(symbol_c *elem, int fl = 0, int fc = 0, int ll = 0, int lc = 0);	\
-    virtual void *accept(visitor_c &visitor);						\
-};
-
-
-#define SYM_TOKEN(class_name_c)								\
-class class_name_c: 	public token_c {						\
-  public:										\
-    class_name_c(const char *value, int fl = 0, int fc = 0, int ll = 0, int lc = 0);	\
-    virtual void *accept(visitor_c &visitor);						\
-};
-
-
-#define SYM_REF0(class_name_c)			\
-class class_name_c: public symbol_c {		\
-  public:					\
-    class_name_c(int fl = 0, int fc = 0, 	\
-		 int ll = 0, int lc = 0);	\
-    virtual void *accept(visitor_c &visitor);	\
-};
-
-
-#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, 		\
-		 int ll = 0, int lc = 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;					\
-  public:						\
-    class_name_c(symbol_c *ref1,			\
-		 symbol_c *ref2 = NULL,			\
-		 int fl = 0, int fc = 0, 		\
-		 int ll = 0, int lc = 0);		\
-    virtual void *accept(visitor_c &visitor);		\
-};
-
-
-#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, 		\
-		 int ll = 0, int lc = 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;					\
-  public:						\
-    class_name_c(symbol_c *ref1,			\
-		 symbol_c *ref2,			\
-		 symbol_c *ref3,			\
-		 symbol_c *ref4 = NULL,			\
-		 int fl = 0, int fc = 0, 		\
-		 int ll = 0, int lc = 0);		\
-    virtual void *accept(visitor_c &visitor);		\
-};
-
-
-#define SYM_REF5(class_name_c, ref1, ref2, ref3, ref4, ref5)		\
-class class_name_c: public symbol_c {					\
-  public:								\
-    symbol_c *ref1;							\
-    symbol_c *ref2;							\
-    symbol_c *ref3;							\
-    symbol_c *ref4;							\
-    symbol_c *ref5;							\
-  public:								\
-    class_name_c(symbol_c *ref1,					\
-		 symbol_c *ref2,					\
-		 symbol_c *ref3,					\
-		 symbol_c *ref4,					\
-		 symbol_c *ref5,					\
-		 int fl = 0, int fc = 0, 				\
-		 int ll = 0, int lc = 0);				\
-    virtual void *accept(visitor_c &visitor);				\
-};
-
-
-#define SYM_REF6(class_name_c, ref1, ref2, ref3, ref4, ref5, ref6)	\
-class class_name_c: public symbol_c {					\
-  public:								\
-    symbol_c *ref1;							\
-    symbol_c *ref2;							\
-    symbol_c *ref3;							\
-    symbol_c *ref4;							\
-    symbol_c *ref5;							\
-    symbol_c *ref6;							\
-  public:								\
-    class_name_c(symbol_c *ref1,					\
-		 symbol_c *ref2,					\
-		 symbol_c *ref3,					\
-		 symbol_c *ref4,					\
-		 symbol_c *ref5,					\
-		 symbol_c *ref6 = NULL,					\
-		 int fl = 0, int fc = 0, 				\
-		 int ll = 0, int lc = 0);				\
-    virtual void *accept(visitor_c &visitor);				\
+#define SYM_LIST(class_name_c)												\
+class class_name_c:	public list_c {											\
+  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);			\
+    class_name_c(symbol_c *elem, 											\
+                 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_TOKEN(class_name_c)												\
+class class_name_c: 	public token_c {										\
+  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);			\
+    virtual void *accept(visitor_c &visitor);										\
+};
+
+
+#define SYM_REF0(class_name_c)												\
+class class_name_c: public symbol_c {											\
+  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);			\
+    virtual void *accept(visitor_c &visitor);										\
+};
+
+
+#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;													\
+  public:														\
+    class_name_c(symbol_c *ref1,											\
+		 symbol_c *ref2 = NULL,											\
+                 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_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)									\
+class class_name_c: public symbol_c {											\
+  public:														\
+    symbol_c *ref1;													\
+    symbol_c *ref2;													\
+    symbol_c *ref3;													\
+    symbol_c *ref4;													\
+  public:														\
+    class_name_c(symbol_c *ref1,											\
+		 symbol_c *ref2,											\
+		 symbol_c *ref3,											\
+		 symbol_c *ref4 = NULL,											\
+                 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_REF5(class_name_c, ref1, ref2, ref3, ref4, ref5)								\
+class class_name_c: public symbol_c {											\
+  public:														\
+    symbol_c *ref1;													\
+    symbol_c *ref2;													\
+    symbol_c *ref3;													\
+    symbol_c *ref4;													\
+    symbol_c *ref5;													\
+  public:														\
+    class_name_c(symbol_c *ref1,											\
+		 symbol_c *ref2,											\
+		 symbol_c *ref3,											\
+		 symbol_c *ref4,											\
+		 symbol_c *ref5,											\
+                 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_REF6(class_name_c, ref1, ref2, ref3, ref4, ref5, ref6)							\
+class class_name_c: public symbol_c {											\
+  public:														\
+    symbol_c *ref1;													\
+    symbol_c *ref2;													\
+    symbol_c *ref3;													\
+    symbol_c *ref4;													\
+    symbol_c *ref5;													\
+    symbol_c *ref6;													\
+  public:														\
+    class_name_c(symbol_c *ref1,											\
+		 symbol_c *ref2,											\
+		 symbol_c *ref3,											\
+		 symbol_c *ref4,											\
+		 symbol_c *ref5,											\
+		 symbol_c *ref6 = NULL,											\
+                 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);										\
 };
 
 
--- a/lib/counter.txt	Mon May 16 11:57:41 2011 +0200
+++ b/lib/counter.txt	Mon May 16 12:36:21 2011 +0200
@@ -25,6 +25,7 @@
 (*                *)
 (******************)
 
+
 FUNCTION_BLOCK CTU
   VAR_INPUT
     CU : BOOL;
@@ -35,8 +36,13 @@
     Q : BOOL;
     CV : INT;
   END_VAR
-  IF R THEN CV := 0 ;
-  ELSIF CU AND (CV < PV)
+  VAR
+    CU_T: R_TRIG;
+  END_VAR
+
+  CU_T(CU);
+  IF R THEN CV := 0 ;
+  ELSIF CU_T.Q AND (CV < PV)
        THEN CV := CV+1;
   END_IF ;
   Q := (CV >= PV) ;
@@ -53,8 +59,13 @@
     Q : BOOL;
     CV : DINT;
   END_VAR
-  IF R THEN CV := 0 ;
-  ELSIF CU AND (CV < PV)
+  VAR
+    CU_T: R_TRIG;
+  END_VAR
+
+  CU_T(CU);
+  IF R THEN CV := 0 ;
+  ELSIF CU_T.Q AND (CV < PV)
        THEN CV := CV+1;
   END_IF ;
   Q := (CV >= PV) ;
@@ -71,8 +82,13 @@
     Q : BOOL;
     CV : LINT;
   END_VAR
-  IF R THEN CV := 0 ;
-  ELSIF CU AND (CV < PV)
+  VAR
+    CU_T: R_TRIG;
+  END_VAR
+
+  CU_T(CU);
+  IF R THEN CV := 0 ;
+  ELSIF CU_T.Q AND (CV < PV)
        THEN CV := CV+1;
   END_IF ;
   Q := (CV >= PV) ;
@@ -89,8 +105,13 @@
     Q : BOOL;
     CV : UDINT;
   END_VAR
-  IF R THEN CV := 0 ;
-  ELSIF CU AND (CV < PV)
+  VAR
+    CU_T: R_TRIG;
+  END_VAR
+
+  CU_T(CU);
+  IF R THEN CV := 0 ;
+  ELSIF CU_T.Q AND (CV < PV)
        THEN CV := CV+1;
   END_IF ;
   Q := (CV >= PV) ;
@@ -107,8 +128,13 @@
     Q : BOOL;
     CV : ULINT;
   END_VAR
-  IF R THEN CV := 0 ;
-  ELSIF CU AND (CV < PV)
+  VAR
+    CU_T: R_TRIG;
+  END_VAR
+
+  CU_T(CU);
+  IF R THEN CV := 0 ;
+  ELSIF CU_T.Q AND (CV < PV)
        THEN CV := CV+1;
   END_IF ;
   Q := (CV >= PV) ;
@@ -137,8 +163,13 @@
     Q : BOOL;
     CV : INT;
   END_VAR
+  VAR
+    CD_T: R_TRIG;
+  END_VAR
+
+  CD_T(CD);
   IF LD THEN CV := PV ;
-  ELSIF CD AND (CV > 0)
+  ELSIF CD_T.Q AND (CV > 0)
       THEN CV := CV-1;
   END_IF ;
   Q := (CV <= 0) ;
@@ -155,8 +186,13 @@
     Q : BOOL;
     CV : DINT;
   END_VAR
+  VAR
+    CD_T: R_TRIG;
+  END_VAR
+
+  CD_T(CD);
   IF LD THEN CV := PV ;
-  ELSIF CD AND (CV > 0)
+  ELSIF CD_T.Q AND (CV > 0)
       THEN CV := CV-1;
   END_IF ;
   Q := (CV <= 0) ;
@@ -173,8 +209,13 @@
     Q : BOOL;
     CV : LINT;
   END_VAR
+  VAR
+    CD_T: R_TRIG;
+  END_VAR
+
+  CD_T(CD);
   IF LD THEN CV := PV ;
-  ELSIF CD AND (CV > 0)
+  ELSIF CD_T.Q AND (CV > 0)
       THEN CV := CV-1;
   END_IF ;
   Q := (CV <= 0) ;
@@ -191,8 +232,13 @@
     Q : BOOL;
     CV : UDINT;
   END_VAR
+  VAR
+    CD_T: R_TRIG;
+  END_VAR
+
+  CD_T(CD);
   IF LD THEN CV := PV ;
-  ELSIF CD AND (CV > 0)
+  ELSIF CD_T.Q AND (CV > 0)
       THEN CV := CV-1;
   END_IF ;
   Q := (CV <= 0) ;
@@ -209,8 +255,13 @@
     Q : BOOL;
     CV : ULINT;
   END_VAR
+  VAR
+    CD_T: R_TRIG;
+  END_VAR
+
+  CD_T(CD);
   IF LD THEN CV := PV ;
-  ELSIF CD AND (CV > 0)
+  ELSIF CD_T.Q AND (CV > 0)
       THEN CV := CV-1;
   END_IF ;
   Q := (CV <= 0) ;
@@ -237,13 +288,21 @@
     QD : BOOL;
     CV : INT;
   END_VAR
+  VAR
+    CD_T: R_TRIG;
+    CU_T: R_TRIG;
+  END_VAR
+
+  CD_T(CD);
+  CU_T(CU);
+
   IF R THEN CV := 0 ;
   ELSIF LD THEN CV := PV ;
   ELSE
-    IF NOT (CU AND CD) THEN
-      IF CU AND (CV < PV)
+    IF NOT (CU_T.Q AND CD_T.Q) THEN
+      IF CU_T.Q AND (CV < PV)
       THEN CV := CV+1;
-      ELSIF CD AND (CV > 0)
+      ELSIF CD_T.Q AND (CV > 0)
       THEN CV := CV-1;
       END_IF;
     END_IF;
@@ -266,13 +325,21 @@
     QD : BOOL;
     CV : DINT;
   END_VAR
+  VAR
+    CD_T: R_TRIG;
+    CU_T: R_TRIG;
+  END_VAR
+
+  CD_T(CD);
+  CU_T(CU);
+
   IF R THEN CV := 0 ;
   ELSIF LD THEN CV := PV ;
   ELSE
-    IF NOT (CU AND CD) THEN
-      IF CU AND (CV < PV)
+    IF NOT (CU_T.Q AND CD_T.Q) THEN
+      IF CU_T.Q AND (CV < PV)
       THEN CV := CV+1;
-      ELSIF CD AND (CV > 0)
+      ELSIF CD_T.Q AND (CV > 0)
       THEN CV := CV-1;
       END_IF;
     END_IF;
@@ -295,13 +362,21 @@
     QD : BOOL;
     CV : LINT;
   END_VAR
+  VAR
+    CD_T: R_TRIG;
+    CU_T: R_TRIG;
+  END_VAR
+
+  CD_T(CD);
+  CU_T(CU);
+
   IF R THEN CV := 0 ;
   ELSIF LD THEN CV := PV ;
   ELSE
-    IF NOT (CU AND CD) THEN
-      IF CU AND (CV < PV)
+    IF NOT (CU_T.Q AND CD_T.Q) THEN
+      IF CU_T.Q AND (CV < PV)
       THEN CV := CV+1;
-      ELSIF CD AND (CV > 0)
+      ELSIF CD_T.Q AND (CV > 0)
       THEN CV := CV-1;
       END_IF;
     END_IF;
@@ -324,13 +399,21 @@
     QD : BOOL;
     CV : UDINT;
   END_VAR
+  VAR
+    CD_T: R_TRIG;
+    CU_T: R_TRIG;
+  END_VAR
+
+  CD_T(CD);
+  CU_T(CU);
+
   IF R THEN CV := 0 ;
   ELSIF LD THEN CV := PV ;
   ELSE
-    IF NOT (CU AND CD) THEN
-      IF CU AND (CV < PV)
+    IF NOT (CU_T.Q AND CD_T.Q) THEN
+      IF CU_T.Q AND (CV < PV)
       THEN CV := CV+1;
-      ELSIF CD AND (CV > 0)
+      ELSIF CD_T.Q AND (CV > 0)
       THEN CV := CV-1;
       END_IF;
     END_IF;
@@ -353,13 +436,21 @@
     QD : BOOL;
     CV : ULINT;
   END_VAR
+  VAR
+    CD_T: R_TRIG;
+    CU_T: R_TRIG;
+  END_VAR
+
+  CD_T(CD);
+  CU_T(CU);
+
   IF R THEN CV := 0 ;
   ELSIF LD THEN CV := PV ;
   ELSE
-    IF NOT (CU AND CD) THEN
-      IF CU AND (CV < PV)
+    IF NOT (CU_T.Q AND CD_T.Q) THEN
+      IF CU_T.Q AND (CV < PV)
       THEN CV := CV+1;
-      ELSIF CD AND (CV > 0)
+      ELSIF CD_T.Q AND (CV > 0)
       THEN CV := CV-1;
       END_IF;
     END_IF;
--- a/lib/iec_std_lib.h	Mon May 16 11:57:41 2011 +0200
+++ b/lib/iec_std_lib.h	Mon May 16 12:36:21 2011 +0200
@@ -1307,33 +1307,3 @@
 
 __compare_string(__ne_, != )
 
-
-/* Get string representation of variable referenced by a void pointer
- * where type is given as its number */
-/*#define __decl_str_case(cat,TYPENAME) \
-    case TYPENAME##_ENUM:\
-        return __##cat##_to_string(*(TYPENAME*)p);
-#define __decl_str_case_bit(TYPENAME) __decl_str_case(bit,TYPENAME)
-#define __decl_str_case_real(TYPENAME) __decl_str_case(real,TYPENAME)
-#define __decl_str_case_sint(TYPENAME) __decl_str_case(sint,TYPENAME)
-#define __decl_str_case_uint(TYPENAME) __decl_str_case(uint,TYPENAME)
-static inline STRING __get_type_enum_str(__IEC_types_enum t, void* p){
- switch(t){
-  __decl_str_case(bool,BOOL)
-  ANY_NBIT(__decl_str_case_bit)
-  ANY_REAL(__decl_str_case_real)
-  ANY_SINT(__decl_str_case_sint)
-  ANY_UINT(__decl_str_case_uint)
-  __decl_str_case(time,TIME)
-  __decl_str_case(date,DATE)
-  __decl_str_case(tod,TOD)
-  __decl_str_case(dt, DT)
- }
-}
-*/
-
-
-
-
-
-
--- a/stage1_2/iec.flex	Mon May 16 11:57:41 2011 +0200
+++ b/stage1_2/iec.flex	Mon May 16 12:36:21 2011 +0200
@@ -179,16 +179,33 @@
       result = YY_NULL;\
     }
 
+
+/* A counter to track the order by which each token is processed.
+ * NOTE: This counter is not exactly linear (i.e., it does not get incremented by 1 for each token).
+ *       i.e.. it may get incremented by more than one between two consecutive tokens.
+ *       This is due to the fact that the counter gets incremented every 'user action' in flex,
+ *       however not every user action will result in a token being passed to bison.
+ *       Nevertheless this is still OK, as we are only interested in the relative
+ *       ordering of tokens...
+ */
+static long int current_order = 0;
+
+
 /* Macro that is executed for every action.
  * We use it to pass the location of the token
  * back to the bison parser...
  */
 #define YY_USER_ACTION {\
-	  yylloc.first_line = current_tracking->lineNumber;\
-  	yylloc.first_column = current_tracking->currentTokenStart;\
-  	yylloc.last_line = current_tracking->lineNumber;\
-  	yylloc.last_column = current_tracking->currentChar - 1;\
-  	current_tracking->currentTokenStart = current_tracking->currentChar;\
+	yylloc.first_line = current_tracking->lineNumber;			\
+	yylloc.first_column = current_tracking->currentTokenStart;		\
+	yylloc.first_file = current_filename;					\
+	yylloc.first_order = current_order;					\
+	yylloc.last_line = current_tracking->lineNumber;			\
+	yylloc.last_column = current_tracking->currentChar - 1;			\
+	yylloc.last_file = current_filename;					\
+	yylloc.last_order = current_order;					\
+	current_tracking->currentTokenStart = current_tracking->currentChar;	\
+	current_order++;							\
 	}
 
 
@@ -858,7 +875,13 @@
 			       * the first one (i.e. the one that gets stored in include_stack[0],
 			       * which is never free'd!
 			       */
-			    free((char *)current_filename);
+			    /* NOTE: We do __NOT__ free the malloc()'d memory since 
+			     *       pointers to this filename will be kept by many objects
+			     *       in the abstract syntax tree.
+			     *       This will later be used to provide correct error
+			     *       messages during semantic analysis (stage 3)
+			     */
+			    /* free((char *)current_filename); */
 			    current_filename = include_stack[include_stack_ptr].filename;
 			    yy_push_state(include_end);
 			  }
--- a/stage1_2/iec.y	Mon May 16 11:57:41 2011 +0200
+++ b/stage1_2/iec.y	Mon May 16 12:36:21 2011 +0200
@@ -116,10 +116,36 @@
 /* Macros used to pass the line and column locations when
  * creating a new object for the abstract syntax tree.
  */
-#define locloc(foo) foo.first_line, foo.first_column, foo.last_line, foo.last_column
-#define   locf(foo) foo.first_line, foo.first_column
-#define   locl(foo) foo.last_line,  foo.last_column
-
+#define locloc(foo) foo.first_line, foo.first_column, foo.first_file, foo.first_order, foo.last_line, foo.last_column, foo.last_file, foo.last_order
+#define   locf(foo) foo.first_line, foo.first_column, foo.first_file, foo.first_order
+#define   locl(foo) foo.last_line,  foo.last_column,  foo.last_file,  foo.last_order
+
+/* Redefine the default action to take for each rule, so that the filenames are correctly processed... */
+# define YYLLOC_DEFAULT(Current, Rhs, N)                                \
+         do                                                                  \
+           if (N)                                                            \
+             {                                                               \
+               (Current).first_line   = YYRHSLOC(Rhs, 1).first_line;         \
+               (Current).first_column = YYRHSLOC(Rhs, 1).first_column;       \
+               (Current).first_file   = YYRHSLOC(Rhs, 1).first_file;         \
+               (Current).first_order  = YYRHSLOC(Rhs, 1).first_order;        \
+               (Current).last_line    = YYRHSLOC(Rhs, N).last_line;          \
+               (Current).last_column  = YYRHSLOC(Rhs, N).last_column;        \
+               (Current).last_file    = YYRHSLOC(Rhs, 1).last_file;          \
+               (Current).last_order   = YYRHSLOC(Rhs, 1).last_order;         \
+             }                                                               \
+           else                                                              \
+             {                                                               \
+               (Current).first_line   = (Current).last_line   =              \
+                 YYRHSLOC(Rhs, 0).last_line;                                 \
+               (Current).first_column = (Current).last_column =              \
+                 YYRHSLOC(Rhs, 0).last_column;                               \
+               (Current).first_file   = (Current).last_file   =              \
+                 YYRHSLOC(Rhs, 0).last_file;                                 \
+               (Current).first_order  = (Current).last_order  =              \
+                 YYRHSLOC(Rhs, 0).last_order;                                \
+             }                                                               \
+         while (0)
 
 
 /* A macro for printing out internal parser errors... */
@@ -182,8 +208,12 @@
 /* print an error message */
 void print_err_msg(int first_line,
                    int first_column,
+                   const char *first_filename,
+                   long int first_order,
                    int last_line,
                    int last_column,
+                   const char *last_filename,
+                   long int last_order,
                    const char *additional_error_msg);
 %}
 
@@ -194,6 +224,46 @@
 // %expect-rr 1
 
 
+/* The following definitions need to be inside a '%code requires' 
+ * so that they are also included in the header files. If this were not the case,
+ * YYLTYPE would be delcared as something in the iec.cc file, and another thing
+ * (actually the default value of YYLTYPE) in the iec.y.hh heder file.
+ */
+%code requires {
+/* define a new data type to store the locations, so we can also store
+ * the filename in which the token is expressed.
+ */
+/* NOTE: since this code will be placed in the iec.y.hh header file,
+ * as well as the iec.cc file that also includes the iec.y.hh header file,
+ * declaring the typedef struct yyltype__local here would result in a 
+ * compilation error when compiling iec.cc, as this struct would be
+ * declared twice.
+ * We therefore use the #if !defined YYLTYPE ...
+ * to make sure only the first declaration is parsed by the C++ compiler.
+ *
+ * At first glance it seems that what we really should do is delcare the
+ * YYLTYPE directly as an anonymous struct, thus:
+ * #define YYLTYPE struct{ ...}
+ * however, this also results in compilation errors.
+ *
+ * I (Mario) think this is kind of a hack. If you know how to
+ * do this re-declaration of YYLTYPE properly, please let me know!
+ */
+#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
+  typedef struct {
+    int         first_line;
+    int         first_column;
+    const char *first_file;
+    long int    first_order;
+    int         last_line;
+    int         last_column;
+    const char *last_file;
+    long int    last_order;
+  } yyltype__local;
+  #define YYLTYPE yyltype__local
+#endif
+}
+
 
 
 %union {
@@ -7829,13 +7899,26 @@
 
 void print_err_msg(int first_line,
                    int first_column,
+                   const char *first_filename,
+                   long int first_order,
                    int last_line,
                    int last_column,
+                   const char *last_filename,
+                   long int last_order,
                    const char *additional_error_msg) {
-  if (full_token_loc)
-  	fprintf(stderr, "%s:%d-%d..%d-%d: error : %s\n", current_filename, first_line, first_column, last_line, last_column, additional_error_msg);
-  else
-  	fprintf(stderr, "%s:%d: error : %s\n", current_filename, first_line, additional_error_msg);
+
+  const char *unknown_file = "<unknown_file>";
+  if (first_filename == NULL) first_filename = unknown_file;
+  if ( last_filename == NULL)  last_filename = unknown_file;
+
+  if (full_token_loc) {
+    if (first_filename == last_filename)
+      fprintf(stderr, "%s:%d-%d..%d-%d: error : %s\n", first_filename, first_line, first_column, last_line, last_column, additional_error_msg);
+    else
+      fprintf(stderr, "%s:%d-%d..%s:%d-%d: error : %s\n", first_filename, first_line, first_column, last_filename, last_line, last_column, additional_error_msg);
+  } else {
+      fprintf(stderr, "%s:%d: error : %s\n", first_filename, first_line, additional_error_msg);
+  }
   //fprintf(stderr, "error %d: %s\n", yynerrs /* a global variable */, additional_error_msg);
   print_include_stack();
   //fprintf(stderr, "%s(%d-%d): %s\n", current_filename, first_line, last_line, current_error_msg);
@@ -7926,8 +8009,12 @@
   res = new identifier_c(strdup(name), 
                          il_operator->first_line,
                          il_operator->first_column,
+                         il_operator->first_file,
+                         il_operator->first_order,
                          il_operator->last_line,
-                         il_operator->last_column
+                         il_operator->last_column,
+                         il_operator->last_file,
+                         il_operator->last_order
                         );
   free(il_operator);
   return res;
--- a/stage3/visit_expression_type.cc	Mon May 16 11:57:41 2011 +0200
+++ b/stage3/visit_expression_type.cc	Mon May 16 12:36:21 2011 +0200
@@ -44,23 +44,13 @@
 #include <strings.h>
 
 
-
-#define FIRST_(symbol1, symbol2) (((symbol1)->first_line   < (symbol2)->first_line)   ? (symbol1) :    \
-                                  ((symbol1)->first_line   > (symbol2)->first_line)   ? (symbol2) :    \
-                                  ((symbol1)->first_column < (symbol2)->first_column) ? (symbol1) :    \
-                                  ((symbol1)->first_column > (symbol2)->first_column) ? (symbol2) :    \
-                                  (symbol1))
-
-#define  LAST_(symbol1, symbol2) (((symbol1)->last_line    < (symbol2)->last_line)    ? (symbol2) :    \
-                                  ((symbol1)->last_line    > (symbol2)->last_line)    ? (symbol1) :    \
-                                  ((symbol1)->last_column  < (symbol2)->last_column)  ? (symbol2) :    \
-                                  ((symbol1)->last_column  > (symbol2)->last_column)  ? (symbol1) :    \
-                                  (symbol1))
+#define FIRST_(symbol1, symbol2) (((symbol1)->first_order < (symbol2)->first_order)   ? (symbol1) : (symbol2))
+#define  LAST_(symbol1, symbol2) (((symbol1)->last_order  > (symbol2)->last_order)    ? (symbol1) : (symbol2))
 
 #define STAGE3_ERROR(symbol1, symbol2, msg) {                                          \
-    fprintf(stderr, "plc.st:%d-%d..%d-%d: error : %s\n",                \
-           FIRST_(symbol1,symbol2)->first_line, FIRST_(symbol1,symbol2)->first_column, \
-           LAST_(symbol1,symbol2) ->last_line,  LAST_(symbol1,symbol2) ->last_column,  \
+    fprintf(stderr, "%s:%d-%d..%d-%d: error : %s\n",                                   \
+           FIRST_(symbol1,symbol2)->first_file, FIRST_(symbol1,symbol2)->first_line, FIRST_(symbol1,symbol2)->first_column, \
+                                                LAST_(symbol1,symbol2) ->last_line,  LAST_(symbol1,symbol2) ->last_column,  \
            msg);                                                                       \
     il_error = true;                                                                   \
     error_found = true;                                                                \
--- a/stage4/generate_c/generate_c.cc	Mon May 16 11:57:41 2011 +0200
+++ b/stage4/generate_c/generate_c.cc	Mon May 16 12:36:21 2011 +0200
@@ -136,6 +136,10 @@
 #define TEMP_VAR VAR_LEADER "TMP_"
 #define SOURCE_VAR VAR_LEADER "SRC_"
 
+/* please see the comment before the RET_operator_c visitor for details... */
+#define END_LABEL VAR_LEADER "end"
+
+
 /***********************************************************************/
 /***********************************************************************/
 /***********************************************************************/
@@ -426,6 +430,43 @@
     };
     virtual ~generate_c_pous_c(void) {}
 
+  private:
+    void print_end_of_block_label(void) {
+      /* Print and __end label for return statements!
+       * If label is not used by at least one goto, compiler will generate a warning.
+       * To work around this we introduce the useless goto.
+       */
+      s4o.print("\n");
+      s4o.print(s4o.indent_spaces);
+      s4o.print("/* to humour the compiler, we insert a goto */\n");
+      s4o.print(s4o.indent_spaces);
+      s4o.print("goto ");
+      s4o.print(END_LABEL);
+      s4o.print(";\n");
+      s4o.indent_left();
+
+      /* write the label marking the end of the code block */
+      /* please see the comment before the RET_operator_c visitor for details... */
+      /* also needed for return_statement_c */
+      s4o.print("\n");
+      s4o.print(s4o.indent_spaces);
+      s4o.print(END_LABEL);
+      s4o.print(":\n");
+      s4o.indent_right();
+
+      /* since every label must be followed by at least one statement, and
+       * only the functions will introduce the return statement after this label,
+       * function blocks written in IL would result in invalid C++ code.
+       * To work around this we introduce the equivalent of a 'nop' operation
+       * to humour the compiler...
+       */
+      s4o.print(s4o.indent_spaces);
+      s4o.print("/* to humour the compiler, we insert a nop */\n");
+      s4o.print(s4o.indent_spaces);
+      s4o.print("if (0);\n\n");
+    }
+  
+
 
   public:
 /********************/
@@ -593,6 +634,8 @@
   generate_c_SFC_IL_ST_c generate_c_code(&s4o, symbol->derived_function_name, symbol);
   symbol->function_body->accept(generate_c_code);
   
+  print_end_of_block_label();
+  
   vardecl = new generate_c_vardecl_c(&s4o,
                 generate_c_vardecl_c::foutputassign_vf,
                 generate_c_vardecl_c::output_vt   |
@@ -776,6 +819,7 @@
   /* (C.5) Function code */
   generate_c_SFC_IL_ST_c generate_c_code(&s4o, symbol->fblock_name, symbol, FB_FUNCTION_PARAM"->");
   symbol->fblock_body->accept(generate_c_code);
+  print_end_of_block_label();
   s4o.indent_left();
   s4o.print(s4o.indent_spaces + "} // ");
   symbol->fblock_name->accept(*this);
@@ -936,6 +980,7 @@
   /* (C.5) Function code */
   generate_c_SFC_IL_ST_c generate_c_code(&s4o, symbol->program_type_name, symbol, FB_FUNCTION_PARAM"->");
   symbol->function_block_body->accept(generate_c_code);
+  print_end_of_block_label();
   s4o.indent_left();
   s4o.print(s4o.indent_spaces + "} // ");
   symbol->program_type_name->accept(*this);
--- a/stage4/generate_c/generate_c_il.cc	Mon May 16 11:57:41 2011 +0200
+++ b/stage4/generate_c/generate_c_il.cc	Mon May 16 12:36:21 2011 +0200
@@ -719,9 +719,6 @@
 /* B 2.1 Instructions and Operands */
 /***********************************/
 
-/* please see the comment before the RET_operator_c visitor for details... */
-#define END_LABEL VAR_LEADER "end"
-
 /*| instruction_list il_instruction */
 void *visit(instruction_list_c *symbol) {
   
@@ -742,40 +739,6 @@
 
   print_list(symbol, s4o.indent_spaces, ";\n" + s4o.indent_spaces, ";\n");
 
-  /* label not used by at least one goto result in a warning.
-   * To work around this we introduce the useless goto
-   * to humour the compiler...
-   */
-  s4o.print("\n");
-  s4o.print(s4o.indent_spaces);
-  s4o.print("/* to humour the compiler, we insert a goto */\n");
-  s4o.print(s4o.indent_spaces);
-  s4o.print("goto ");
-  s4o.print(END_LABEL);
-  s4o.print(";\n");
-
-  /* write the label marking the end of the code block */
-  /* please see the comment before the RET_operator_c visitor for details... */
-  s4o.print("\n");
-  s4o.print(s4o.indent_spaces);
-  s4o.print(END_LABEL);
-  s4o.print(":\n");
-  s4o.indent_right();
-  /* since every label must be followed by at least one statement, and
-   * only the functions will introduce the return statement after this label,
-   * function blocks written in IL would result in invalid C++ code.
-   * To work around this we introduce the equivalent of a 'nop' operation
-   * to humour the compiler...
-   */
-  s4o.print(s4o.indent_spaces);
-  s4o.print("/* to humour the compiler, we insert a nop */\n");
-  s4o.print(s4o.indent_spaces);
-  this->default_variable_name.accept(*this);
-  s4o.print(" = ");
-  this->default_variable_name.accept(*this);
-  s4o.print(";\n");
-  s4o.indent_left();
-
   return NULL;
 }
 
--- a/stage4/generate_c/generate_c_st.cc	Mon May 16 11:57:41 2011 +0200
+++ b/stage4/generate_c/generate_c_st.cc	Mon May 16 12:36:21 2011 +0200
@@ -796,6 +796,12 @@
 /* B 3.2.2 Subprogram Control Statements */
 /*****************************************/
 
+void *visit(return_statement_c *symbol) {
+  s4o.print("goto "); s4o.print(END_LABEL);
+  return NULL;
+}
+
+
 /* fb_name '(' [param_assignment_list] ')' */
 /* param_assignment_list -> may be NULL ! */
 //SYM_REF2(fb_invocation_c, fb_name, param_assignment_list)
@@ -1067,7 +1073,7 @@
   return NULL;
 }
 void *visit(exit_statement_c *symbol) {
-  s4o.print("exit(0)");
+  s4o.print("break");
   return NULL;
 }