Add support for non standard REF_TO ANY (equivalent to void *)
authormjsousa
Sat, 09 Aug 2014 09:20:03 +0100
changeset 923 0ad7843d3790
parent 922 1ba7a814098d
child 924 9e824bb0c3d4
Add support for non standard REF_TO ANY (equivalent to void *)
stage1_2/iec_bison.yy
stage4/generate_c/generate_c_base.cc
--- a/stage1_2/iec_bison.yy	Fri Aug 08 10:45:54 2014 +0100
+++ b/stage1_2/iec_bison.yy	Sat Aug 09 09:20:03 2014 +0100
@@ -3215,12 +3215,15 @@
 /* NOTE: in IEC 61131-3 v3, the formal syntax definition does not define non_generic_type_name to include FB type names.
  *       However, in section "6.3.4.10 References", example 4 includes a  REF_TO a FB type!
  *       We have therefore explicitly added the "REF_TO function_block_type_name" to this rule!
+ * NOTE: the REF_TO ANY is a non-standard extension to the standard. This is basically equivalent to a (void *)
  */
 ref_spec: /* defined in IEC 61131-3 v3 */
   REF_TO non_generic_type_name
 	{$$ = new ref_spec_c($2, locloc(@$));}
 | REF_TO function_block_type_name
 	{$$ = new ref_spec_c($2, locloc(@$));}
+| REF_TO ANY
+	{$$ = new ref_spec_c(new generic_type_any_c(locloc(@2)), locloc(@$));}
 /* The following line is actually not included in IEC 61131-3, but we add it anyway otherwise it will not be possible to
  * define a REF_TO datatype as an alias to an already previously declared REF_TO datatype.
  * For example:
--- a/stage4/generate_c/generate_c_base.cc	Fri Aug 08 10:45:54 2014 +0100
+++ b/stage4/generate_c/generate_c_base.cc	Sat Aug 09 09:20:03 2014 +0100
@@ -590,7 +590,8 @@
 /********************************/
 /* B.1.3.2 - Generic data types */
 /********************************/
-  /* originally empty... */
+    /* Currently only used in REF_TO ANY, which is mapped onto (void *) */
+    void *visit(generic_type_any_c *symbol)      {s4o.print("void");    return NULL;}
 
 /********************************/
 /* B 1.3.3 - Derived data types */