laurent@377: /* laurent@377: * matiec - a compiler for the programming languages defined in IEC 61131-3 laurent@377: * laurent@377: * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt) laurent@377: * Copyright (C) 2007-2011 Laurent Bessard and Edouard Tisserant laurent@377: * laurent@377: * This program is free software: you can redistribute it and/or modify laurent@377: * it under the terms of the GNU General Public License as published by laurent@377: * the Free Software Foundation, either version 3 of the License, or laurent@377: * (at your option) any later version. laurent@377: * laurent@377: * This program is distributed in the hope that it will be useful, laurent@377: * but WITHOUT ANY WARRANTY; without even the implied warranty of laurent@377: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the laurent@377: * GNU General Public License for more details. laurent@377: * laurent@377: * You should have received a copy of the GNU General Public License laurent@377: * along with this program. If not, see . laurent@377: * laurent@377: * laurent@377: * This code is made available on the understanding that it will not be laurent@377: * used in safety-critical situations without a full and competent review. laurent@377: */ laurent@377: laurent@377: /* laurent@377: * An IEC 61131-3 compiler. laurent@377: * laurent@377: * Based on the laurent@377: * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) laurent@377: * laurent@377: */ laurent@377: laurent@377: laurent@377: /* laurent@377: * Array dimension iterator. laurent@377: * Iterate through the dimensions of array specification. laurent@377: * laurent@377: * This is part of the 4th stage that generates laurent@377: * a c++ source program equivalent to the IL and ST laurent@377: * code. laurent@377: */ laurent@377: laurent@377: /* Given a array_specification_c, iterate through laurent@377: * each subrange, returning the symbol of each subrange laurent@377: * ...array_dimension_iterator_c laurent@377: */ laurent@377: laurent@377: laurent@377: #include "../absyntax/visitor.hh" laurent@377: laurent@377: laurent@377: class array_dimension_iterator_c : public null_visitor_c { laurent@377: private: laurent@377: /* a pointer to the array_specification_c currently being analyzed */ laurent@377: symbol_c *array_specification; laurent@377: /* used when called to iterate() for a parameter */ msousa@562: subrange_c *current_array_dimension; laurent@377: laurent@377: private: laurent@377: void* iterate_list(list_c *list); laurent@377: laurent@377: public: laurent@377: /* start off at the first dimension once again... */ laurent@377: void reset(void); laurent@377: laurent@377: /* initialize the iterator object. msousa@562: * We must be given a reference to a array_specification_c that will be analyzed... laurent@377: */ laurent@377: array_dimension_iterator_c(symbol_c *symbol); laurent@377: laurent@377: /* Skip to the next subrange. After object creation, laurent@377: * the object references on subrange _before_ the first, so laurent@377: * this function must be called once to get the object to laurent@377: * reference the first subrange... laurent@377: * laurent@377: * Returns the subrange symbol! laurent@377: */ msousa@562: subrange_c *next(void); msousa@562: laurent@377: laurent@377: private: laurent@377: laurent@377: /********************************/ laurent@377: /* B 1.3.3 - Derived data types */ laurent@377: /********************************/ laurent@377: /* signed_integer DOTDOT signed_integer */ laurent@377: void *visit(subrange_c *symbol); laurent@377: laurent@377: /* ARRAY '[' array_subrange_list ']' OF non_generic_type_name */ laurent@377: void *visit(array_specification_c *symbol); laurent@377: laurent@377: /* array_subrange_list ',' subrange */ laurent@377: void *visit(array_subrange_list_c *symbol); laurent@377: laurent@377: }; // function_param_iterator_c laurent@377: laurent@377: laurent@377: laurent@377: laurent@377: laurent@377: laurent@377: