mjsousa@1000: /* mjsousa@1000: * matiec - a compiler for the programming languages defined in IEC 61131-3 mjsousa@1000: * mjsousa@1000: * Copyright (C) 2015 Mario de Sousa (msousa@fe.up.pt) mjsousa@1000: * mjsousa@1000: * mjsousa@1000: * This program is free software: you can redistribute it and/or modify mjsousa@1000: * it under the terms of the GNU General Public License as published by mjsousa@1000: * the Free Software Foundation, either version 3 of the License, or mjsousa@1000: * (at your option) any later version. mjsousa@1000: * mjsousa@1000: * This program is distributed in the hope that it will be useful, mjsousa@1000: * but WITHOUT ANY WARRANTY; without even the implied warranty of mjsousa@1000: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the mjsousa@1000: * GNU General Public License for more details. mjsousa@1000: * mjsousa@1000: * You should have received a copy of the GNU General Public License mjsousa@1000: * along with this program. If not, see . mjsousa@1000: * mjsousa@1000: * mjsousa@1000: * This code is made available on the understanding that it will not be mjsousa@1000: * used in safety-critical situations without a full and competent review. mjsousa@1000: */ mjsousa@1000: mjsousa@1000: /* mjsousa@1000: * An IEC 61131-3 compiler. mjsousa@1000: * mjsousa@1000: * Based on the mjsousa@1000: * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) mjsousa@1000: * mjsousa@1000: */ mjsousa@1000: mjsousa@1000: mjsousa@1000: /* mjsousa@1000: * Case Options Checking: mjsousa@1000: * - Check whether the options in a case statement are repeated, either directly, or in a range. mjsousa@1000: * For example: mjsousa@1000: * case var of mjsousa@1000: * 1: ... <- OK mjsousa@1000: * 2: ... <- OK mjsousa@1000: * 1: ... <- OK (not an error), but produce a warning! mjsousa@1000: * 0..8: ...<- OK (not an error), but produce a warning! mjsousa@1000: */ mjsousa@1000: mjsousa@1000: #include "../absyntax_utils/absyntax_utils.hh" mjsousa@1000: mjsousa@1000: mjsousa@1000: mjsousa@1000: class case_elements_check_c: public iterator_visitor_c { mjsousa@1000: mjsousa@1000: private: mjsousa@1000: bool warning_found; mjsousa@1000: int error_count; mjsousa@1000: int current_display_error_level; mjsousa@1000: mjsousa@1000: std::vector case_elements_list; mjsousa@1000: void check_subr_subr(symbol_c *s1, symbol_c *s2); mjsousa@1000: void check_subr_symb(symbol_c *s1, symbol_c *s2); mjsousa@1000: void check_symb_symb(symbol_c *s1, symbol_c *s2); mjsousa@1000: mjsousa@1000: mjsousa@1000: public: mjsousa@1000: case_elements_check_c(symbol_c *ignore); mjsousa@1000: virtual ~case_elements_check_c(void); mjsousa@1000: int get_error_count(); mjsousa@1000: mjsousa@1000: /***************************************/ mjsousa@1000: /* B.3 - Language ST (Structured Text) */ mjsousa@1000: /***************************************/ mjsousa@1000: /********************/ mjsousa@1000: /* B 3.2 Statements */ mjsousa@1000: /********************/ mjsousa@1000: /********************************/ mjsousa@1000: /* B 3.2.3 Selection Statements */ mjsousa@1000: /********************************/ mjsousa@1000: void *visit(case_statement_c *symbol); mjsousa@1000: void *visit(case_list_c *symbol); mjsousa@1000: }; /* case_elements_check_c */ mjsousa@1000: mjsousa@1000: mjsousa@1000: mjsousa@1000: mjsousa@1000: mjsousa@1000: mjsousa@1000: