# HG changeset patch # User mjsousa # Date 1407572403 -3600 # Node ID 0ad7843d3790690da83f5956000483e1a27f8136 # Parent 1ba7a814098d7d4ff6c992e75a4b2cf02bbaa099 Add support for non standard REF_TO ANY (equivalent to void *) diff -r 1ba7a814098d -r 0ad7843d3790 stage1_2/iec_bison.yy --- 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: diff -r 1ba7a814098d -r 0ad7843d3790 stage4/generate_c/generate_c_base.cc --- 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 */