absyntax_utils/debug_ast.hh
changeset 678 01e33dc2a255
child 725 bfbe4aca6b77
equal deleted inserted replaced
677:740da3255d9d 678:01e33dc2a255
       
     1 /*
       
     2  *  matiec - a compiler for the programming languages defined in IEC 61131-3
       
     3  *  Copyright (C) 2003-2011  Mario de Sousa (msousa@fe.up.pt)
       
     4  *  Copyright (C) 2007-2011  Laurent Bessard and Edouard Tisserant
       
     5  *
       
     6  *  This program is free software: you can redistribute it and/or modify
       
     7  *  it under the terms of the GNU General Public License as published by
       
     8  *  the Free Software Foundation, either version 3 of the License, or
       
     9  *  (at your option) any later version.
       
    10  *
       
    11  *  This program is distributed in the hope that it will be useful,
       
    12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    14  *  GNU General Public License for more details.
       
    15  *
       
    16  *  You should have received a copy of the GNU General Public License
       
    17  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
       
    18  *
       
    19  *
       
    20  * This code is made available on the understanding that it will not be
       
    21  * used in safety-critical situations without a full and competent review.
       
    22  */
       
    23 
       
    24 /*
       
    25  * An IEC 61131-3 compiler.
       
    26  *
       
    27  * Based on the
       
    28  * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
       
    29  *
       
    30  */
       
    31 
       
    32 
       
    33 /*
       
    34  * Some classes to help with debuging.
       
    35  *
       
    36  * These classes will print out the current state of a symbol or a portion of the Abstract Syntax Tree.
       
    37  */
       
    38 
       
    39 
       
    40 
       
    41 
       
    42 
       
    43 
       
    44 #include "../absyntax/visitor.hh"
       
    45 
       
    46 
       
    47 
       
    48 class print_symbol_c: public fcall_visitor_c { 
       
    49   public:
       
    50     static void print(symbol_c *symbol);
       
    51     
       
    52   protected:
       
    53     void fcall(symbol_c *symbol);  
       
    54     /* AST symbols with extra data have their own specialised methods for printing that data */
       
    55     void *visit(il_instruction_c *symbol);
       
    56 
       
    57   private:
       
    58     static print_symbol_c *singleton;
       
    59     
       
    60     void dump_symbol(symbol_c* symbol);
       
    61 };
       
    62 
       
    63 
       
    64 
       
    65 
       
    66 
       
    67 
       
    68 class print_ast_c: public fcall_iterator_visitor_c { 
       
    69   public:
       
    70     static void print(symbol_c *symbol);
       
    71     
       
    72   protected:
       
    73   void prefix_fcall(symbol_c *symbol);
       
    74   void suffix_fcall(symbol_c *symbol);  
       
    75   
       
    76   private:
       
    77     static print_ast_c *singleton;    
       
    78 };
       
    79 
       
    80 
       
    81 
       
    82 
       
    83 
       
    84 
       
    85 
       
    86 
       
    87 
       
    88 
       
    89 
       
    90 
       
    91 
       
    92 
       
    93 
       
    94