mario@181: /* msousa@265: * matiec - a compiler for the programming languages defined in IEC 61131-3 mario@181: * msousa@265: * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt) Edouard@279: * Copyright (C) 2007-2011 Laurent Bessard and Edouard Tisserant mario@181: * msousa@265: * This program is free software: you can redistribute it and/or modify msousa@265: * it under the terms of the GNU General Public License as published by msousa@265: * the Free Software Foundation, either version 3 of the License, or msousa@265: * (at your option) any later version. msousa@265: * msousa@265: * This program is distributed in the hope that it will be useful, msousa@265: * but WITHOUT ANY WARRANTY; without even the implied warranty of msousa@265: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the msousa@265: * GNU General Public License for more details. msousa@265: * msousa@265: * You should have received a copy of the GNU General Public License msousa@265: * along with this program. If not, see . msousa@265: * 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: /* msousa@265: * An IEC 61131-3 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: * Separation of type specification and default value constructs mario@181: * (for e.g. simple_spec_init_c), into a type specificiation part, mario@181: * and a default value part. mario@181: */ mario@181: mario@181: #include "../absyntax/absyntax.hh" mario@181: #include "../absyntax/visitor.hh" mario@181: mario@181: class spec_init_sperator_c: public null_visitor_c { mario@181: mario@181: private: mario@181: /* this is a singleton class... */ mario@181: static spec_init_sperator_c *class_instance; mario@181: static spec_init_sperator_c *get_class_instance(void); mario@181: mario@181: private: mario@181: typedef enum {search_spec, search_init} search_what_t; mario@181: static search_what_t search_what; mario@181: mario@181: public: mario@181: /* the only two public functions... */ mario@181: static symbol_c *get_spec(symbol_c *spec_init); mario@181: mario@181: static symbol_c *get_init(symbol_c *spec_init); mario@181: mario@181: mario@181: private: mario@181: mario@181: mario@181: /*******************************************/ mario@181: /* B 1.1 - Letters, digits and identifiers */ mario@181: /*******************************************/ mario@181: // SYM_TOKEN(identifier_c) mario@181: void *visit(identifier_c *symbol); mario@181: mario@181: mario@181: /********************************/ mario@181: /* B 1.3.3 - Derived data types */ mario@181: /********************************/ mario@181: mario@181: /* simple_specification ASSIGN constant */ mario@181: void *visit(simple_spec_init_c *symbol); mario@181: mario@181: /* subrange_specification ASSIGN signed_integer */ mario@181: void *visit(subrange_spec_init_c *symbol); mario@181: mario@181: /* integer_type_name '(' subrange')' */ mario@181: void *visit(subrange_specification_c *symbol); mario@181: mario@181: /* array_specification [ASSIGN array_initialization} */ mario@181: /* array_initialization may be NULL ! */ mario@181: void *visit(array_spec_init_c *symbol); mario@181: mario@181: /* enumerated_specification ASSIGN enumerated_value */ mario@181: void *visit(enumerated_spec_init_c *symbol); mario@181: mario@181: /* structure_type_name ASSIGN structure_initialization */ mario@181: /* structure_initialization may be NULL ! */ mario@181: //SYM_REF2(initialized_structure_c, structure_type_name, structure_initialization) mario@181: void *visit(initialized_structure_c *symbol); mario@181: mario@181: mario@181: /******************************************/ mario@181: /* B 1.4.3 - Declaration & Initialisation */ mario@181: /******************************************/ mario@181: mario@181: /* fb_name_list ':' function_block_type_name ASSIGN structure_initialization */ mario@181: /* structure_initialization -> may be NULL ! */ mario@181: void *visit(fb_name_decl_c *symbol); msousa@350: msousa@350: /* STRING '[' integer ']' msousa@350: * STRING ASSIGN single_byte_character_string msousa@350: * STRING '[' integer ']' ASSIGN single_byte_character_string msousa@350: */ msousa@350: void *visit(single_byte_string_spec_c *symbol); msousa@350: msousa@350: /* WSTRING '[' integer ']' msousa@350: * WSTRING ASSIGN double_byte_character_string msousa@350: * WSTRING '[' integer ']' ASSIGN double_byte_character_string msousa@350: */ msousa@350: void *visit(double_byte_string_spec_c *symbol); msousa@350: mario@181: }; /* class spec_init_sperator_c */