absyntax_utils/debug_ast.cc
author Mario de Sousa <msousa@fe.up.pt>
Fri, 09 Nov 2012 14:34:36 +0000
changeset 724 d19877568878
parent 678 01e33dc2a255
child 725 bfbe4aca6b77
permissions -rw-r--r--
Check for errors in enum datatype declarations. (This is not yet complete as it will not yet stop the compilation process if these errors are found)
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) 2012  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
 *
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     5
 *  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
     6
 *  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
     7
 *  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
     8
 *  (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
     9
 *
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    10
 *  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
    11
 *  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
    12
 *  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
    13
 *  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
    14
 *
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    15
 *  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
    16
 *  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
    17
 *
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
 * 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
    20
 * 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
    21
 */
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
 * 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
    25
 *
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    26
 * 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
    27
 * 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
    28
 *
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
 * 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
    34
 *
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    35
 * 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
    36
 */
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
/* TODO: Use a class similar to stage4out_c so that we can have nice indentation when printing an AST
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    39
 *       Create a template so that we can TRACE the execution of other visitor classes doing usefull work!
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
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    44
#include <unistd.h>
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    45
#include <stdio.h>  /* required for NULL */
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    46
#include "absyntax_utils.hh"
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    47
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    48
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    49
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    50
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    51
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    52
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    53
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    54
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
print_symbol_c *print_symbol_c::singleton = NULL;
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
void print_symbol_c::print(symbol_c* symbol) {
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    63
  if (NULL == singleton)   singleton = new print_symbol_c();
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    64
  if (NULL == singleton)   ERROR;
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
  symbol->accept(*singleton);
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
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    72
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    73
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    74
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    75
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    76
void print_symbol_c::fcall(symbol_c* symbol) {
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    77
  dump_symbol(symbol);
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    78
  fprintf(stderr, "\n");
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    79
}
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    80
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    81
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    82
void print_symbol_c::dump_symbol(symbol_c* symbol) {
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    83
  fprintf(stderr, "(%03d:%03d..%03d:%03d) \t%s\t", symbol->first_line, symbol->first_column, symbol->last_line, symbol->last_column, symbol->absyntax_cname());
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    84
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    85
  fprintf(stderr, "  datatype=");
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    86
  if (NULL == symbol->datatype)
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    87
    fprintf(stderr, "NULL\t\t");
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    88
  else 
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    89
    fprintf(stderr, symbol->datatype->absyntax_cname());
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    90
  fprintf(stderr, "\t<-{");
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    91
  if (symbol->candidate_datatypes.size() == 0) {
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    92
    fprintf(stderr, "\t\t\t\t\t");
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    93
  } else if (symbol->candidate_datatypes.size() <= 2) {
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    94
    for (unsigned int i = 0; i < 2; i++)
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    95
      if (i < symbol->candidate_datatypes.size())
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    96
        fprintf(stderr, " %s,", symbol->candidate_datatypes[i]->absyntax_cname());
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    97
      else
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    98
        fprintf(stderr, "\t\t\t");
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    99
  } else {
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   100
    fprintf(stderr, "(%d)\t\t\t\t\t", symbol->candidate_datatypes.size());
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   101
  }
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   102
  fprintf(stderr, "}\t");          
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   103
}
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   104
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   105
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   106
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   107
void *print_symbol_c::visit(il_instruction_c *symbol) {
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   108
   dump_symbol(symbol);
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   109
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   110
  fprintf(stderr, "  next_il_=%d ", symbol->next_il_instruction.size());
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   111
  fprintf(stderr, "  prev_il_=%d ", symbol->prev_il_instruction.size());
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   112
  
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   113
  if (symbol->prev_il_instruction.size() == 0)
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   114
    fprintf(stderr, "(----,");
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   115
  else if (symbol->prev_il_instruction[0]->datatype == NULL)
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   116
    fprintf(stderr, "(NULL,");
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   117
  else if (!get_datatype_info_c::is_type_valid(symbol->prev_il_instruction[0]->datatype))
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   118
    fprintf(stderr, "(****,");
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   119
  else
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   120
    fprintf(stderr, "(    ,");
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   121
  
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   122
  if (symbol->next_il_instruction.size() == 0)
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   123
    fprintf(stderr, "----)");
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   124
  else if (symbol->next_il_instruction[0]->datatype == NULL)
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   125
    fprintf(stderr, "NULL)");
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   126
  else if (!get_datatype_info_c::is_type_valid(symbol->next_il_instruction[0]->datatype))
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   127
    fprintf(stderr, "****)");
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   128
  else 
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   129
    fprintf(stderr, "    )");
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   130
  
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   131
  fprintf(stderr, "\n");
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   132
  
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   133
  return NULL;
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   134
};
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   135
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   136
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   137
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   138
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   139
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   140
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   141
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   142
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   143
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   144
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   145
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   146
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   147
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   148
print_ast_c *print_ast_c::singleton = NULL;
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   149
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   150
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   151
void print_ast_c::print(symbol_c* symbol) {
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   152
  if (NULL == singleton)   singleton = new print_ast_c();
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   153
  if (NULL == singleton)   ERROR;
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   154
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   155
  symbol->accept(*singleton);
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   156
}
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   157
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   158
  
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   159
void print_ast_c::prefix_fcall(symbol_c* symbol) {print_symbol_c::print(symbol);}
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   160
void print_ast_c::suffix_fcall(symbol_c* symbol) {}
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   161
  
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   162
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   163
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   164
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   165
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   166
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   167
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   168
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   169
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   170
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   171
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   172
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   173
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   174
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   175
01e33dc2a255 Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   176