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: /* Determine the data type of a specific constant or variable. mario@181: * A reference to the relevant type definition is returned. mario@181: * mario@181: * For example: mario@181: * 22 -> returns reference to a int_type_name_c object. mario@181: * 22.2 -> returns reference to a real_type_name_c object. mario@181: * LREAL#22.2 -> returns reference to a lreal_type_name_c object. mario@181: * etc... mario@181: */ mario@181: mario@181: mario@181: #include "../absyntax/visitor.hh" mario@181: mario@181: mario@181: class search_constant_type_c: public search_visitor_c { mario@181: mario@181: public: mario@181: /**********************/ mario@181: /* B.1.3 - Data types */ mario@181: /**********************/ mario@181: /***********************************/ mario@181: /* B 1.3.1 - Elementary Data Types */ mario@181: /***********************************/ mario@181: static real_type_name_c real_type_name; mario@181: static sint_type_name_c sint_type_name; mario@181: static lint_type_name_c lint_type_name; mario@181: static dint_type_name_c dint_type_name; mario@181: static date_type_name_c date_type_name; mario@181: static dword_type_name_c dword_type_name; mario@181: static dt_type_name_c dt_type_name; mario@181: static tod_type_name_c tod_type_name; mario@181: static udint_type_name_c udint_type_name; mario@181: static word_type_name_c word_type_name; mario@181: static wstring_type_name_c wstring_type_name; mario@181: static string_type_name_c string_type_name; mario@181: static lword_type_name_c lword_type_name; mario@181: static uint_type_name_c uint_type_name; mario@181: static lreal_type_name_c lreal_type_name; mario@181: static byte_type_name_c byte_type_name; mario@181: static usint_type_name_c usint_type_name; mario@181: static ulint_type_name_c ulint_type_name; mario@181: static bool_type_name_c bool_type_name; mario@181: static time_type_name_c time_type_name; mario@181: static int_type_name_c int_type_name; mario@181: mario@181: static constant_real_type_name_c constant_real_type_name; mario@181: static constant_int_type_name_c constant_int_type_name; mario@181: static direct_variable_type_name_c direct_variable_type_name; mario@181: mario@181: /******************************************************/ mario@181: /* Extensions to the base standard as defined in */ mario@181: /* "Safety Software Technical Specification, */ mario@181: /* Part 1: Concepts and Function Blocks, */ mario@181: /* Version 1.0 – Official Release" */ mario@181: /* by PLCopen - Technical Committee 5 - 2006-01-31 */ mario@181: /******************************************************/ mario@181: static safebool_type_name_c safebool_type_name; mario@181: mario@181: mario@181: public: mario@181: symbol_c *get_type(symbol_c *constant); mario@181: mario@181: mario@181: private: mario@181: /*********************/ mario@181: /* B 1.2 - Constants */ mario@181: /*********************/ mario@181: mario@181: /******************************/ mario@181: /* B 1.2.1 - Numeric Literals */ mario@181: /******************************/ mario@181: void *visit(real_c *symbol); mario@181: void *visit(integer_c *symbol); mario@181: void *visit(binary_integer_c *symbol); mario@181: void *visit(octal_integer_c *symbol); mario@181: void *visit(hex_integer_c *symbol); mario@181: mario@181: void *visit(numeric_literal_c *symbol); mario@181: void *visit(integer_literal_c *symbol); mario@181: void *visit(real_literal_c *symbol); mario@181: void *visit(bit_string_literal_c *symbol); mario@181: void *visit(boolean_literal_c *symbol); mario@181: mario@181: /*******************************/ mario@181: /* B.1.2.2 Character Strings */ mario@181: /*******************************/ mario@181: void *visit(double_byte_character_string_c *symbol); mario@181: void *visit(single_byte_character_string_c *symbol); mario@181: mario@181: /***************************/ mario@181: /* B 1.2.3 - Time Literals */ mario@181: /***************************/ mario@181: /************************/ mario@181: /* B 1.2.3.1 - Duration */ mario@181: /************************/ mario@181: void *visit(neg_time_c *symbol); mario@181: void *visit(duration_c *symbol); mario@181: void *visit(fixed_point_c *symbol); mario@181: void *visit(days_c *symbol); mario@181: void *visit(hours_c *symbol); mario@181: void *visit(minutes_c *symbol); mario@181: void *visit(seconds_c *symbol); mario@181: void *visit(milliseconds_c *symbol); mario@181: mario@181: /************************************/ mario@181: /* B 1.2.3.2 - Time of day and Date */ mario@181: /************************************/ mario@181: void *visit(time_of_day_c *symbol); mario@181: void *visit(daytime_c *symbol); mario@181: void *visit(date_c *symbol); mario@181: void *visit(date_literal_c *symbol); mario@181: void *visit(date_and_time_c *symbol); mario@181: }; // search_constant_type_c mario@181: mario@181: mario@181: