search_utils/search_utils.cc
author mario
Tue, 26 May 2009 18:04:27 +0200
changeset 178 1622dc05c6ca
permissions -rw-r--r--
Starting move of search utils to their own top level directory.
178
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
     1
/*
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
     2
 * (c) 2009 Mario de Sousa
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
     3
 *
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
     4
 * Offered to the public under the terms of the GNU General Public License
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
     5
 * as published by the Free Software Foundation; either version 2 of the
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
     6
 * License, or (at your option) any later version.
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
     7
 *
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
     8
 * This program is distributed in the hope that it will be useful, but
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
     9
 * WITHOUT ANY WARRANTY; without even the implied warranty of
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    11
 * Public License for more details.
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    12
 *
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    13
 * This code is made available on the understanding that it will not be
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    14
 * used in safety-critical situations without a full and competent review.
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    15
 */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    16
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    17
/*
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    18
 * An IEC 61131-3 IL and ST compiler.
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    19
 *
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    20
 * Based on the
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    21
 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    22
 *
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    23
 */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    24
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    25
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    26
/*
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    27
 * This is the main stage 3a file.
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    28
 *
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    29
 * In stage 3a some helpful symbol tables are instanciated and populated.
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    30
 * These symbol tables wll then be used by stage3b and atage4 code generators.
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    31
 */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    32
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    33
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    34
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    35
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    36
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    37
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    38
// #include <stdio.h>  /* required for NULL */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    39
#include <string>
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    40
#include <iostream>
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    41
#include <sstream>
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    42
#include <typeinfo>
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    43
#include <list>
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    44
#include <strings.h>
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    45
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    46
#include "../util/symtable.hh"
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    47
#include "../util/dsymtable.hh"
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    48
#include "../absyntax/visitor.hh"
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    49
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    50
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    51
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    52
//#define DEBUG
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    53
#ifdef DEBUG
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    54
#define TRACE(classname) printf("\n____%s____\n",classname);
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    55
#else
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    56
#define TRACE(classname)
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    57
#endif
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    58
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    59
#define ERROR error_exit(__FILE__,__LINE__)
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    60
/* function defined in main.cc */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    61
extern void error_exit(const char *file_name, int line_no);
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    62
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    63
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    64
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    65
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    66
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    67
/* A symbol table with all globally declared functions... */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    68
function_declaration_c null_symbol1(NULL,NULL,NULL,NULL);
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    69
dsymtable_c<function_declaration_c *, &null_symbol1> function_symtable;
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    70
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    71
/* A symbol table with all globally declared functions block types... */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    72
function_block_declaration_c null_symbol2(NULL,NULL,NULL);
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    73
symtable_c<function_block_declaration_c *, &null_symbol2> function_block_type_symtable;
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    74
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    75
/* A symbol table with all globally declared program types... */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    76
program_declaration_c null_symbol3(NULL,NULL,NULL);
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    77
symtable_c<program_declaration_c *, &null_symbol3> program_type_symtable;
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    78
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    79
/* A symbol table with all user declared type definitions... */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    80
/* Note that function block types and program types have their
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    81
 * own symbol tables, so do not get placed in this symbol table!
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    82
 */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    83
symbol_c null_symbol4;
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    84
symtable_c<symbol_c *, &null_symbol4> type_symtable;
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    85
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    86
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    87
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    88
/***********************************************************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    89
/***********************************************************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    90
/***********************************************************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    91
/***********************************************************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    92
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    93
/*
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    94
#include "spec_init_separator.cc"
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    95
#include "function_param_iterator.cc"
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    96
#include "function_call_iterator.cc"
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    97
#include "function_call_param_iterator.cc"
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    98
#include "type_initial_value.cc"
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
    99
#include "search_fb_instance_decl.cc"
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   100
#include "search_fb_typedecl.cc"
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   101
#include "search_base_type.cc"
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   102
#include "search_var_instance_decl.cc"
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   103
#include "decompose_var_instance_name.cc"
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   104
#include "search_varfb_instance_type.cc"
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   105
#include "search_constant_type.cc"
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   106
#include "search_expression_type.cc"
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   107
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   108
#include "generate_c_base.cc"
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   109
#include "generate_c_typedecl.cc"
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   110
#include "generate_c_sfcdecl.cc"
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   111
#include "generate_c_vardecl.cc"
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   112
#include "generate_c_configbody.cc"
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   113
#include "generate_location_list.cc"
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   114
#include "generate_var_list.cc"
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   115
*/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   116
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   117
/***********************************************************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   118
/***********************************************************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   119
/***********************************************************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   120
/***********************************************************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   121
/***********************************************************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   122
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   123
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   124
class populate_symtables_c: public iterator_visitor_c {
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   125
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   126
  public:
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   127
    populate_symtables_c(void) {};
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   128
    virtual ~populate_symtables_c(void) {}
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   129
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   130
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   131
  public:
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   132
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   133
/*************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   134
/* B.1 - Common elements */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   135
/*************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   136
/*******************************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   137
/* B 1.1 - Letters, digits and identifiers */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   138
/*******************************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   139
/*********************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   140
/* B 1.2 - Constants */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   141
/*********************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   142
/******************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   143
/* B 1.2.1 - Numeric Literals */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   144
/******************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   145
/*******************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   146
/* B.1.2.2   Character Strings */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   147
/*******************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   148
/***************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   149
/* B 1.2.3 - Time Literals */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   150
/***************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   151
/************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   152
/* B 1.2.3.1 - Duration */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   153
/************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   154
/************************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   155
/* B 1.2.3.2 - Time of day and Date */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   156
/************************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   157
/**********************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   158
/* B.1.3 - Data types */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   159
/**********************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   160
/***********************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   161
/* B 1.3.1 - Elementary Data Types */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   162
/***********************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   163
/********************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   164
/* B.1.3.2 - Generic data types */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   165
/********************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   166
/********************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   167
/* B 1.3.3 - Derived data types */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   168
/********************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   169
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   170
/*  subrange_type_name ':' subrange_spec_init */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   171
void *visit(subrange_type_declaration_c *symbol) {
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   172
  TRACE("subrange_type_declaration_c");  
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   173
  type_symtable.insert(symbol->subrange_type_name, symbol->subrange_spec_init);
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   174
  return NULL;
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   175
}
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   176
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   177
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   178
/*  enumerated_type_name ':' enumerated_spec_init */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   179
void *visit(enumerated_type_declaration_c *symbol) {
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   180
  TRACE("enumerated_type_declaration_c");
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   181
  type_symtable.insert(symbol->enumerated_type_name, symbol->enumerated_spec_init);
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   182
  return NULL;
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   183
}
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   184
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   185
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   186
/*  identifier ':' array_spec_init */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   187
void *visit(array_type_declaration_c *symbol) {
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   188
  TRACE("array_type_declaration_c");
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   189
  type_symtable.insert(symbol->identifier, symbol->array_spec_init);
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   190
  return NULL;
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   191
}
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   192
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   193
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   194
/*  simple_type_name ':' simple_spec_init */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   195
void *visit(simple_type_declaration_c *symbol) {
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   196
  TRACE("simple_type_declaration_c");
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   197
  type_symtable.insert(symbol->simple_type_name, symbol->simple_spec_init);
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   198
  return NULL;
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   199
}
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   200
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   201
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   202
/*  structure_type_name ':' structure_specification */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   203
void *visit(structure_type_declaration_c *symbol) {
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   204
  TRACE("structure_type_declaration_c");
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   205
  type_symtable.insert(symbol->structure_type_name, symbol->structure_specification);
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   206
  return NULL;
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   207
}
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   208
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   209
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   210
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   211
/*********************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   212
/* B 1.4 - Variables */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   213
/*********************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   214
/********************************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   215
/* B.1.4.1   Directly Represented Variables */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   216
/********************************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   217
/*************************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   218
/* B.1.4.2   Multi-element Variables */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   219
/*************************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   220
/******************************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   221
/* B 1.4.3 - Declaration & Initialisation */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   222
/******************************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   223
/**************************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   224
/* B.1.5 - Program organization units */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   225
/**************************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   226
/***********************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   227
/* B 1.5.1 - Functions */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   228
/***********************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   229
public:
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   230
/*   FUNCTION derived_function_name ':' elementary_type_name io_OR_function_var_declarations_list function_body END_FUNCTION */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   231
/* | FUNCTION derived_function_name ':' derived_type_name io_OR_function_var_declarations_list function_body END_FUNCTION */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   232
void *visit(function_declaration_c *symbol) {
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   233
  TRACE("function_declaration_c");
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   234
  function_symtable.insert(symbol->derived_function_name, symbol);
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   235
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   236
  /* symbol->derived_function_name->accept(*this);  */ /* Function name */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   237
  /* symbol->type_name->accept(*this);              */ /* return data type */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   238
  /* symbol->var_declarations_list->accept(*this);  */ /* Function parameters and variables */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   239
  /* symbol->function_body->accept(*this);          */ /* Function body */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   240
  return NULL;
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   241
}
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   242
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   243
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   244
/*****************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   245
/* B 1.5.2 - Function Blocks */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   246
/*****************************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   247
public:
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   248
/*  FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations function_block_body END_FUNCTION_BLOCK */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   249
//SYM_REF4(function_block_declaration_c, fblock_name, var_declarations, fblock_body, unused)
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   250
void *visit(function_block_declaration_c *symbol) {
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   251
  TRACE("function_block_declaration_c");
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   252
  function_block_type_symtable.insert(symbol->fblock_name, symbol);
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   253
/*
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   254
  symbol->fblock_name->accept(*this);
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   255
  symbol->var_declarations->accept(*this);
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   256
  symbol->fblock_body->accept(*this);
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   257
*/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   258
  return NULL;
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   259
}
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   260
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   261
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   262
/**********************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   263
/* B 1.5.3 - Programs */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   264
/**********************/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   265
public:
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   266
/*  PROGRAM program_type_name program_var_declarations_list function_block_body END_PROGRAM */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   267
//SYM_REF4(program_declaration_c, program_type_name, var_declarations, function_block_body, unused)
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   268
void *visit(program_declaration_c *symbol) {
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   269
  TRACE("program_declaration_c");
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   270
  program_type_symtable.insert(symbol->program_type_name, symbol);
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   271
/*
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   272
  symbol->program_type_name->accept(*this);
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   273
  symbol->var_declarations->accept(*this);
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   274
  symbol->function_block_body->accept(*this);
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   275
*/
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   276
  return NULL;
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   277
}
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   278
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   279
}; /* populate_symtables_c */
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   280
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   281
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   282
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   283
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   284
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   285
void search_utils_init(symbol_c *tree_root) {
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   286
  populate_symtables_c populate_symbols;
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   287
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   288
  tree_root->accept(populate_symbols);
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents:
diff changeset
   289
}