msousa@678: /* msousa@678: * matiec - a compiler for the programming languages defined in IEC 61131-3 msousa@678: * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt) msousa@678: * Copyright (C) 2007-2011 Laurent Bessard and Edouard Tisserant msousa@678: * msousa@678: * This program is free software: you can redistribute it and/or modify msousa@678: * it under the terms of the GNU General Public License as published by msousa@678: * the Free Software Foundation, either version 3 of the License, or msousa@678: * (at your option) any later version. msousa@678: * msousa@678: * This program is distributed in the hope that it will be useful, msousa@678: * but WITHOUT ANY WARRANTY; without even the implied warranty of msousa@678: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the msousa@678: * GNU General Public License for more details. msousa@678: * msousa@678: * You should have received a copy of the GNU General Public License msousa@678: * along with this program. If not, see . msousa@678: * msousa@678: * msousa@678: * This code is made available on the understanding that it will not be msousa@678: * used in safety-critical situations without a full and competent review. msousa@678: */ msousa@678: msousa@678: /* msousa@678: * An IEC 61131-3 compiler. msousa@678: * msousa@678: * Based on the msousa@678: * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) msousa@678: * msousa@678: */ msousa@678: msousa@678: msousa@678: /* msousa@678: * Some classes to help with debuging. msousa@678: * msousa@678: * These classes will print out the current state of a symbol or a portion of the Abstract Syntax Tree. msousa@678: */ msousa@678: msousa@678: msousa@678: msousa@678: msousa@678: msousa@678: msousa@678: #include "../absyntax/visitor.hh" msousa@678: msousa@678: msousa@678: msousa@678: class print_symbol_c: public fcall_visitor_c { msousa@678: public: msousa@678: static void print(symbol_c *symbol); msousa@678: msousa@678: protected: msousa@678: void fcall(symbol_c *symbol); msousa@678: /* AST symbols with extra data have their own specialised methods for printing that data */ msousa@678: void *visit(il_instruction_c *symbol); msousa@678: msousa@678: private: msousa@678: static print_symbol_c *singleton; msousa@678: msousa@678: void dump_symbol(symbol_c* symbol); msousa@678: }; msousa@678: msousa@678: msousa@678: msousa@678: msousa@678: msousa@678: msousa@678: class print_ast_c: public fcall_iterator_visitor_c { msousa@678: public: msousa@678: static void print(symbol_c *symbol); msousa@678: msousa@678: protected: msousa@678: void prefix_fcall(symbol_c *symbol); msousa@678: void suffix_fcall(symbol_c *symbol); msousa@678: msousa@678: private: msousa@678: static print_ast_c *singleton; msousa@678: }; msousa@678: msousa@678: msousa@678: msousa@678: msousa@678: msousa@678: msousa@678: msousa@678: msousa@678: msousa@678: msousa@678: msousa@678: msousa@678: msousa@678: msousa@678: msousa@678: