msousa@666: /* msousa@666: * matiec - a compiler for the programming languages defined in IEC 61131-3 msousa@666: * msousa@666: * Copyright (C) 2003-2012 Mario de Sousa (msousa@fe.up.pt) msousa@666: * msousa@666: * This program is free software: you can redistribute it and/or modify msousa@666: * it under the terms of the GNU General Public License as published by msousa@666: * the Free Software Foundation, either version 3 of the License, or msousa@666: * (at your option) any later version. msousa@666: * msousa@666: * This program is distributed in the hope that it will be useful, msousa@666: * but WITHOUT ANY WARRANTY; without even the implied warranty of msousa@666: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the msousa@666: * GNU General Public License for more details. msousa@666: * msousa@666: * You should have received a copy of the GNU General Public License msousa@666: * along with this program. If not, see . msousa@666: * msousa@666: * msousa@666: * This code is made available on the understanding that it will not be msousa@666: * used in safety-critical situations without a full and competent review. msousa@666: */ msousa@666: msousa@666: /* msousa@666: * An IEC 61131-3 compiler. msousa@666: * msousa@666: * Based on the msousa@666: * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) msousa@666: * msousa@666: */ msousa@666: msousa@666: /* Determine the characteristics of a specific data type msousa@666: * e.g., is it an enumeration, is it an array, is it ANY_INT, etc... msousa@666: * msousa@666: * The methods of this class may be passed either: msousa@666: * - a data type declaration symbol_c, msousa@666: * OR msousa@666: * - the name of a data type (identifier_c) msousa@666: * In this case, we shall first serach for the basetype declaration using search_base_type_c, and then msousa@666: * run the normal process. msousa@666: */ msousa@666: #include "absyntax_utils.hh" msousa@666: msousa@666: #include "../main.hh" // required for ERROR() and ERROR_MSG() macros. msousa@666: msousa@666: msousa@666: msousa@666: msousa@666: msousa@666: msousa@666: class get_datatype_info_c { msousa@666: msousa@666: msousa@666: private: // this is a purely static class. No need for constructors! msousa@666: get_datatype_info_c(void) {}; msousa@666: ~get_datatype_info_c(void) {}; msousa@666: msousa@666: msousa@666: public: msousa@668: static bool is_ANY_REAL_literal(symbol_c *type_symbol); /* Can't we do away with this?? */ msousa@668: static bool is_ANY_INT_literal (symbol_c *type_symbol); /* Can't we do away with this?? */ msousa@668: msousa@666: static bool is_sfc_initstep (symbol_c *type_symbol); msousa@666: static bool is_sfc_step (symbol_c *type_symbol); msousa@666: static bool is_function_block (symbol_c *type_symbol); msousa@666: static bool is_subrange (symbol_c *type_symbol); msousa@666: static bool is_enumerated (symbol_c *type_symbol); msousa@666: static bool is_array (symbol_c *type_symbol); msousa@666: static bool is_structure (symbol_c *type_symbol); msousa@666: msousa@666: msousa@666: msousa@666: static bool is_ANY_ELEMENTARY (symbol_c *type_symbol); msousa@666: static bool is_ANY_SAFEELEMENTARY (symbol_c *type_symbol); msousa@666: static bool is_ANY_ELEMENTARY_compatible (symbol_c *type_symbol); msousa@666: msousa@666: static bool is_ANY_MAGNITUDE (symbol_c *type_symbol); msousa@666: static bool is_ANY_SAFEMAGNITUDE (symbol_c *type_symbol); msousa@666: static bool is_ANY_MAGNITUDE_compatible (symbol_c *type_symbol); msousa@666: msousa@666: static bool is_ANY_signed_MAGNITUDE (symbol_c *type_symbol); msousa@666: static bool is_ANY_signed_SAFEMAGNITUDE (symbol_c *type_symbol); msousa@666: static bool is_ANY_signed_MAGNITUDE_compatible (symbol_c *type_symbol); msousa@666: msousa@666: static bool is_ANY_NUM (symbol_c *type_symbol); msousa@666: static bool is_ANY_SAFENUM (symbol_c *type_symbol); msousa@666: static bool is_ANY_NUM_compatible (symbol_c *type_symbol); msousa@666: msousa@666: static bool is_ANY_signed_NUM (symbol_c *type_symbol); msousa@666: static bool is_ANY_signed_SAFENUM (symbol_c *type_symbol); msousa@666: static bool is_ANY_signed_NUM_compatible (symbol_c *type_symbol); msousa@666: msousa@666: static bool is_ANY_INT (symbol_c *type_symbol); msousa@666: static bool is_ANY_SAFEINT (symbol_c *type_symbol); msousa@666: static bool is_ANY_INT_compatible (symbol_c *type_symbol); msousa@666: msousa@666: static bool is_ANY_signed_INT (symbol_c *type_symbol); msousa@666: static bool is_ANY_signed_SAFEINT (symbol_c *type_symbol); msousa@666: static bool is_ANY_signed_INT_compatible (symbol_c *type_symbol); msousa@666: msousa@666: static bool is_ANY_unsigned_INT (symbol_c *type_symbol); msousa@666: static bool is_ANY_unsigned_SAFEINT (symbol_c *type_symbol); msousa@666: static bool is_ANY_unsigned_INT_compatible (symbol_c *type_symbol); msousa@666: msousa@666: static bool is_ANY_REAL (symbol_c *type_symbol); msousa@666: static bool is_ANY_SAFEREAL (symbol_c *type_symbol); msousa@666: static bool is_ANY_REAL_compatible (symbol_c *type_symbol); msousa@666: msousa@666: static bool is_ANY_nBIT (symbol_c *type_symbol); msousa@666: static bool is_ANY_SAFEnBIT (symbol_c *type_symbol); msousa@666: static bool is_ANY_nBIT_compatible (symbol_c *type_symbol); msousa@666: msousa@666: static bool is_BOOL (symbol_c *type_symbol); msousa@666: static bool is_SAFEBOOL (symbol_c *type_symbol); msousa@666: static bool is_BOOL_compatible (symbol_c *type_symbol); msousa@666: msousa@666: static bool is_ANY_BIT (symbol_c *type_symbol); msousa@666: static bool is_ANY_SAFEBIT (symbol_c *type_symbol); msousa@666: static bool is_ANY_BIT_compatible (symbol_c *type_symbol); msousa@668: msousa@668: static bool is_ANY_DATE (symbol_c *type_symbol); msousa@668: static bool is_ANY_SAFEDATE (symbol_c *type_symbol); msousa@668: static bool is_ANY_DATE_compatible (symbol_c *type_symbol); msousa@668: msousa@668: static bool is_TIME (symbol_c *type_symbol); msousa@668: static bool is_SAFETIME (symbol_c *type_symbol); msousa@668: static bool is_TIME_compatible (symbol_c *type_symbol); msousa@668: msousa@668: static bool is_ANY_STRING (symbol_c *type_symbol); msousa@668: static bool is_ANY_SAFESTRING (symbol_c *type_symbol); msousa@668: static bool is_ANY_STRING_compatible (symbol_c *type_symbol); msousa@668: msousa@666: }; msousa@666: