absyntax_utils/debug_ast.hh
author Edouard Tisserant <edouard.tisserant@gmail.com>
Fri, 26 Apr 2024 09:27:21 +0200
changeset 1105 8128cad6a6e3
parent 979 f8f1d89ff7d5
permissions -rw-r--r--
merge
678
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     1
/*
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     2
 *  matiec - a compiler for the programming languages defined in IEC 61131-3
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     3
 *  Copyright (C) 2003-2011  Mario de Sousa (msousa@fe.up.pt)
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     4
 *  Copyright (C) 2007-2011  Laurent Bessard and Edouard Tisserant
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     5
 *
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     6
 *  This program is free software: you can redistribute it and/or modify
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     7
 *  it under the terms of the GNU General Public License as published by
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     8
 *  the Free Software Foundation, either version 3 of the License, or
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     9
 *  (at your option) any later version.
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    10
 *
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    11
 *  This program is distributed in the hope that it will be useful,
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    14
 *  GNU General Public License for more details.
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    15
 *
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    16
 *  You should have received a copy of the GNU General Public License
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    17
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    18
 *
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    19
 *
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    20
 * This code is made available on the understanding that it will not be
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    21
 * used in safety-critical situations without a full and competent review.
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    22
 */
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    23
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    24
/*
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    25
 * An IEC 61131-3 compiler.
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    26
 *
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    27
 * Based on the
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    28
 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    29
 *
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    30
 */
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    31
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    32
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    33
/*
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    34
 * Some classes to help with debuging.
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    35
 *
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    36
 * These classes will print out the current state of a symbol or a portion of the Abstract Syntax Tree.
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    37
 */
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    38
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    39
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    40
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    41
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    42
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    43
725
bfbe4aca6b77 Change the public interface to debug functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 678
diff changeset
    44
#include "../absyntax/absyntax.hh"
678
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    45
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    46
725
bfbe4aca6b77 Change the public interface to debug functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 678
diff changeset
    47
class debug_c { 
678
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    48
  public:
979
f8f1d89ff7d5 Add debug_c::print(const_value_c) for printing of const values.
mjsousa
parents: 725
diff changeset
    49
    static void print(const_value_c  cvalue);
f8f1d89ff7d5 Add debug_c::print(const_value_c) for printing of const values.
mjsousa
parents: 725
diff changeset
    50
    static void print(symbol_c      *symbol);
f8f1d89ff7d5 Add debug_c::print(const_value_c) for printing of const values.
mjsousa
parents: 725
diff changeset
    51
    static void print(const char    *str);
678
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    52
725
bfbe4aca6b77 Change the public interface to debug functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 678
diff changeset
    53
    /* print the AST from this point downwards */
bfbe4aca6b77 Change the public interface to debug functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 678
diff changeset
    54
    static void print_ast(symbol_c *root_symbol);
678
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    55
};
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    56
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    57
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    58
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    59
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    60
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    61
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    62
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    63
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    64
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    65
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    66
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    67
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    68
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    69
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    70
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    71
725
bfbe4aca6b77 Change the public interface to debug functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 678
diff changeset
    72
bfbe4aca6b77 Change the public interface to debug functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 678
diff changeset
    73