mario@181: /* mario@181: * (c) 2003 Mario de Sousa mario@181: * mario@181: * Offered to the public under the terms of the GNU General Public License mario@181: * as published by the Free Software Foundation; either version 2 of the mario@181: * License, or (at your option) any later version. mario@181: * mario@181: * This program is distributed in the hope that it will be useful, but mario@181: * WITHOUT ANY WARRANTY; without even the implied warranty of mario@181: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General mario@181: * Public License for more details. mario@181: * mario@181: * This code is made available on the understanding that it will not be mario@181: * used in safety-critical situations without a full and competent review. mario@181: */ mario@181: mario@181: /* mario@181: * An IEC 61131-3 IL and ST compiler. mario@181: * mario@181: * Based on the mario@181: * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) mario@181: * mario@181: */ mario@181: mario@181: mario@181: mario@181: /* Decomposes a variable instance name into its constituents, mario@181: * example: mario@181: * window.points[1].coordinate.x mario@181: * mario@181: * will succesfully return mario@181: * - window mario@181: * - points mario@181: * - coordinate mario@181: * - x mario@181: * on succesive calls to decompose_var_instance_name_c::next_part() mario@181: */ mario@181: mario@181: mario@181: mario@181: #include "../absyntax/visitor.hh" mario@181: mario@181: mario@181: mario@181: class decompose_var_instance_name_c: null_visitor_c { mario@181: mario@181: private: mario@181: symbol_c *variable_name; mario@181: symbol_c *next_variable_name; mario@181: symbol_c *current_recursive_variable_name; mario@181: symbol_c *previously_returned_variable_name; mario@181: mario@181: public: mario@181: decompose_var_instance_name_c(symbol_c *variable_instance_name); mario@181: mario@181: symbol_c *next_part(void); mario@181: mario@181: private: ccb@202: /*************************/ ccb@202: /* B.1 - Common elements */ ccb@202: /*************************/ ccb@202: /*******************************************/ ccb@202: /* B 1.1 - Letters, digits and identifiers */ ccb@202: /*******************************************/ ccb@202: void *visit(identifier_c *symbol); ccb@202: mario@181: /*********************/ mario@181: /* B 1.4 - Variables */ mario@181: /*********************/ mario@181: void *visit(symbolic_variable_c *symbol); ccb@202: mario@181: /********************************************/ mario@181: /* B.1.4.1 Directly Represented Variables */ mario@181: /********************************************/ mario@181: void *visit(direct_variable_c *symbol); mario@181: mario@181: /*************************************/ mario@181: /* B.1.4.2 Multi-element Variables */ mario@181: /*************************************/ mario@181: /* subscripted_variable '[' subscript_list ']' */ mario@181: // SYM_REF2(array_variable_c, subscripted_variable, subscript_list) mario@181: void *visit(array_variable_c *symbol); mario@181: mario@181: /* record_variable '.' field_selector */ mario@181: /* WARNING: input and/or output variables of function blocks mario@181: * may be accessed as fields of a tructured variable! mario@181: * Code handling a structured_variable_c must take mario@181: * this into account! mario@181: */ mario@181: //SYM_REF2(structured_variable_c, record_variable, field_selector) mario@181: void *visit(structured_variable_c *symbol); mario@181: mario@181: }; // decompose_var_instance_name_c mario@181: mario@181: mario@181: mario@181: