# HG changeset patch # User mario # Date 1243883472 -7200 # Node ID 231633d1d2e49d2b84a3953dd55d162f81fc854e # Parent 38d6eb05626056b3f7321288604f52584de3d58c Moving absyntax utility functions out from stage4/generate_c diff -r 38d6eb056260 -r 231633d1d2e4 search_utils/search_utils.cc --- a/search_utils/search_utils.cc Mon Jun 01 21:08:44 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,289 +0,0 @@ -/* - * (c) 2009 Mario de Sousa - * - * Offered to the public under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General - * Public License for more details. - * - * This code is made available on the understanding that it will not be - * used in safety-critical situations without a full and competent review. - */ - -/* - * An IEC 61131-3 IL and ST compiler. - * - * Based on the - * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) - * - */ - - -/* - * This is the main stage 3a file. - * - * In stage 3a some helpful symbol tables are instanciated and populated. - * These symbol tables wll then be used by stage3b and atage4 code generators. - */ - - - - - - -// #include /* required for NULL */ -#include -#include -#include -#include -#include -#include - -#include "../util/symtable.hh" -#include "../util/dsymtable.hh" -#include "../absyntax/visitor.hh" - - - -//#define DEBUG -#ifdef DEBUG -#define TRACE(classname) printf("\n____%s____\n",classname); -#else -#define TRACE(classname) -#endif - -#define ERROR error_exit(__FILE__,__LINE__) -/* function defined in main.cc */ -extern void error_exit(const char *file_name, int line_no); - - - - - -/* A symbol table with all globally declared functions... */ -function_declaration_c null_symbol1(NULL,NULL,NULL,NULL); -dsymtable_c function_symtable; - -/* A symbol table with all globally declared functions block types... */ -function_block_declaration_c null_symbol2(NULL,NULL,NULL); -symtable_c function_block_type_symtable; - -/* A symbol table with all globally declared program types... */ -program_declaration_c null_symbol3(NULL,NULL,NULL); -symtable_c program_type_symtable; - -/* A symbol table with all user declared type definitions... */ -/* Note that function block types and program types have their - * own symbol tables, so do not get placed in this symbol table! - */ -symbol_c null_symbol4; -symtable_c type_symtable; - - - -/***********************************************************************/ -/***********************************************************************/ -/***********************************************************************/ -/***********************************************************************/ - -/* -#include "spec_init_separator.cc" -#include "function_param_iterator.cc" -#include "function_call_iterator.cc" -#include "function_call_param_iterator.cc" -#include "type_initial_value.cc" -#include "search_fb_instance_decl.cc" -#include "search_fb_typedecl.cc" -#include "search_base_type.cc" -#include "search_var_instance_decl.cc" -#include "decompose_var_instance_name.cc" -#include "search_varfb_instance_type.cc" -#include "search_constant_type.cc" -#include "search_expression_type.cc" - -#include "generate_c_base.cc" -#include "generate_c_typedecl.cc" -#include "generate_c_sfcdecl.cc" -#include "generate_c_vardecl.cc" -#include "generate_c_configbody.cc" -#include "generate_location_list.cc" -#include "generate_var_list.cc" -*/ - -/***********************************************************************/ -/***********************************************************************/ -/***********************************************************************/ -/***********************************************************************/ -/***********************************************************************/ - - -class populate_symtables_c: public iterator_visitor_c { - - public: - populate_symtables_c(void) {}; - virtual ~populate_symtables_c(void) {} - - - public: - -/*************************/ -/* B.1 - Common elements */ -/*************************/ -/*******************************************/ -/* B 1.1 - Letters, digits and identifiers */ -/*******************************************/ -/*********************/ -/* B 1.2 - Constants */ -/*********************/ -/******************************/ -/* B 1.2.1 - Numeric Literals */ -/******************************/ -/*******************************/ -/* B.1.2.2 Character Strings */ -/*******************************/ -/***************************/ -/* B 1.2.3 - Time Literals */ -/***************************/ -/************************/ -/* B 1.2.3.1 - Duration */ -/************************/ -/************************************/ -/* B 1.2.3.2 - Time of day and Date */ -/************************************/ -/**********************/ -/* B.1.3 - Data types */ -/**********************/ -/***********************************/ -/* B 1.3.1 - Elementary Data Types */ -/***********************************/ -/********************************/ -/* B.1.3.2 - Generic data types */ -/********************************/ -/********************************/ -/* B 1.3.3 - Derived data types */ -/********************************/ - -/* subrange_type_name ':' subrange_spec_init */ -void *visit(subrange_type_declaration_c *symbol) { - TRACE("subrange_type_declaration_c"); - type_symtable.insert(symbol->subrange_type_name, symbol->subrange_spec_init); - return NULL; -} - - -/* enumerated_type_name ':' enumerated_spec_init */ -void *visit(enumerated_type_declaration_c *symbol) { - TRACE("enumerated_type_declaration_c"); - type_symtable.insert(symbol->enumerated_type_name, symbol->enumerated_spec_init); - return NULL; -} - - -/* identifier ':' array_spec_init */ -void *visit(array_type_declaration_c *symbol) { - TRACE("array_type_declaration_c"); - type_symtable.insert(symbol->identifier, symbol->array_spec_init); - return NULL; -} - - -/* simple_type_name ':' simple_spec_init */ -void *visit(simple_type_declaration_c *symbol) { - TRACE("simple_type_declaration_c"); - type_symtable.insert(symbol->simple_type_name, symbol->simple_spec_init); - return NULL; -} - - -/* structure_type_name ':' structure_specification */ -void *visit(structure_type_declaration_c *symbol) { - TRACE("structure_type_declaration_c"); - type_symtable.insert(symbol->structure_type_name, symbol->structure_specification); - return NULL; -} - - - -/*********************/ -/* B 1.4 - Variables */ -/*********************/ -/********************************************/ -/* B.1.4.1 Directly Represented Variables */ -/********************************************/ -/*************************************/ -/* B.1.4.2 Multi-element Variables */ -/*************************************/ -/******************************************/ -/* B 1.4.3 - Declaration & Initialisation */ -/******************************************/ -/**************************************/ -/* B.1.5 - Program organization units */ -/**************************************/ -/***********************/ -/* B 1.5.1 - Functions */ -/***********************/ -public: -/* FUNCTION derived_function_name ':' elementary_type_name io_OR_function_var_declarations_list function_body END_FUNCTION */ -/* | FUNCTION derived_function_name ':' derived_type_name io_OR_function_var_declarations_list function_body END_FUNCTION */ -void *visit(function_declaration_c *symbol) { - TRACE("function_declaration_c"); - function_symtable.insert(symbol->derived_function_name, symbol); - - /* symbol->derived_function_name->accept(*this); */ /* Function name */ - /* symbol->type_name->accept(*this); */ /* return data type */ - /* symbol->var_declarations_list->accept(*this); */ /* Function parameters and variables */ - /* symbol->function_body->accept(*this); */ /* Function body */ - return NULL; -} - - -/*****************************/ -/* B 1.5.2 - Function Blocks */ -/*****************************/ -public: -/* FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations function_block_body END_FUNCTION_BLOCK */ -//SYM_REF4(function_block_declaration_c, fblock_name, var_declarations, fblock_body, unused) -void *visit(function_block_declaration_c *symbol) { - TRACE("function_block_declaration_c"); - function_block_type_symtable.insert(symbol->fblock_name, symbol); -/* - symbol->fblock_name->accept(*this); - symbol->var_declarations->accept(*this); - symbol->fblock_body->accept(*this); -*/ - return NULL; -} - - -/**********************/ -/* B 1.5.3 - Programs */ -/**********************/ -public: -/* PROGRAM program_type_name program_var_declarations_list function_block_body END_PROGRAM */ -//SYM_REF4(program_declaration_c, program_type_name, var_declarations, function_block_body, unused) -void *visit(program_declaration_c *symbol) { - TRACE("program_declaration_c"); - program_type_symtable.insert(symbol->program_type_name, symbol); -/* - symbol->program_type_name->accept(*this); - symbol->var_declarations->accept(*this); - symbol->function_block_body->accept(*this); -*/ - return NULL; -} - -}; /* populate_symtables_c */ - - - - - -void search_utils_init(symbol_c *tree_root) { - populate_symtables_c populate_symbols; - - tree_root->accept(populate_symbols); -} diff -r 38d6eb056260 -r 231633d1d2e4 search_utils/search_utils.hh --- a/search_utils/search_utils.hh Mon Jun 01 21:08:44 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,106 +0,0 @@ -/* - * (c) 2009 Mario de Sousa - * - * Offered to the public under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General - * Public License for more details. - * - * This code is made available on the understanding that it will not be - * used in safety-critical situations without a full and competent review. - */ - -/* - * An IEC 61131-3 IL and ST compiler. - * - * Based on the - * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) - * - */ - - -/* - * This is the main stage 3a file. - * - * In stage 3a some helpful symbol tables are instanciated and populated. - * These symbol tables wll then be used by stage3b and atage4 code generators. - */ - - - - - - -// #include /* required for NULL */ -#include "../util/symtable.hh" -#include "../util/dsymtable.hh" -#include "../absyntax/visitor.hh" - - - - - -/* A symbol table with all globally declared functions... */ -extern function_declaration_c null_symbol1; -extern dsymtable_c function_symtable; - -/* A symbol table with all globally declared functions block types... */ -extern function_block_declaration_c null_symbol2; -extern symtable_c function_block_type_symtable; - -/* A symbol table with all globally declared program types... */ -extern program_declaration_c null_symbol3; -extern symtable_c program_type_symtable; - -/* A symbol table with all user declared type definitions... */ -/* Note that function block types and program types have their - * own symbol tables, so do not get placed in this symbol table! - */ -extern symbol_c null_symbol4; -extern symtable_c type_symtable; - - - -/***********************************************************************/ -/***********************************************************************/ -/***********************************************************************/ -/***********************************************************************/ - -/* -#include "spec_init_separator.cc" -#include "function_param_iterator.cc" -#include "function_call_iterator.cc" -#include "function_call_param_iterator.cc" -#include "type_initial_value.cc" -#include "search_fb_instance_decl.cc" -#include "search_fb_typedecl.cc" -#include "search_base_type.cc" -#include "search_var_instance_decl.cc" -#include "decompose_var_instance_name.cc" -#include "search_varfb_instance_type.cc" -#include "search_constant_type.cc" -#include "search_expression_type.cc" - -#include "generate_c_base.cc" -#include "generate_c_typedecl.cc" -#include "generate_c_sfcdecl.cc" -#include "generate_c_vardecl.cc" -#include "generate_c_configbody.cc" -#include "generate_location_list.cc" -#include "generate_var_list.cc" -*/ - -/***********************************************************************/ -/***********************************************************************/ -/***********************************************************************/ -/***********************************************************************/ -/***********************************************************************/ - - - - -void search_utils_init(symbol_c *tree_root); diff -r 38d6eb056260 -r 231633d1d2e4 stage4/generate_c/function_param_iterator.cc --- a/stage4/generate_c/function_param_iterator.cc Mon Jun 01 21:08:44 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,469 +0,0 @@ -/* - * (c) 2003 Mario de Sousa - * - * Offered to the public under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General - * Public License for more details. - * - * This code is made available on the understanding that it will not be - * used in safety-critical situations without a full and competent review. - */ - -/* - * An IEC 61131-3 IL and ST compiler. - * - * Based on the - * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) - * - */ - - -/* - * Function parameter iterator. - * Iterate through the in/out parameters of a function declaration. - * Function blocks are also suported. - * - * This is part of the 4th stage that generates - * a c++ source program equivalent to the IL and ST - * code. - */ - - - - - - -//#include /* required for NULL */ -//#include -//#include - -//#include "../../util/symtable.hh" - -//#include "generate_c.hh" - - -#include "../../absyntax/visitor.hh" - - -/* given a function_declaration_c, iterate through each - * function in/out/inout parameter, returning the name - * of each parameter...function_param_iterator_c - */ -class function_param_iterator_c : public null_visitor_c { - public: - /* A type to specify the type of parameter. - * VAR_INPUT => direction_in - * VAR_OUTPUT => direction_out - * VAR_IN_OUT => direction_inout - * VAR_EXTERNAL => direction_extref - * - * Note that VAR_EXTERNAL declares variables that are in reality references - * to global variables. This is used only inside programs! - * These references to external variables must be correctly initialised to refer - * to the correct global variable. Note that the user may define which variable is to be - * referenced in a CONFIGURATION, and that different instantiations of a program - * may have the same external variable reference diffenrent global variables! - * The references must therefore be correctly initialised when the program instance - * is created. This may be done by the PROGRAM class constructor since the ST and IL - * languages do not allow the VAR_EXTERNAL reference to change at runtime - * for a specific instance. - * - * We therefore need to call a PROGRAM class constructor with the variables - * that should be refernced by the VAR_EXTERNAL variables. The direction_extref will - * be used to identify these parameters! - */ - typedef enum {direction_in, direction_out, direction_inout, direction_extref} param_direction_t ; - - - private: - /* a pointer to the function_block_declaration_c - * or function_declaration_c currently being analysed. - */ - symbol_c *f_decl; - int next_param, param_count; - identifier_c *current_param_name; - symbol_c *current_param_type; - symbol_c *current_param_default_value; - param_direction_t current_param_direction; - bool en_declared; - bool eno_declared; - - private: - void* handle_param_list(list_c *list) { - if (next_param <= param_count + list->n) - return list->elements[next_param - param_count - 1]; - - /* the desired param is not on this list... */ - param_count += list->n; - return NULL; - } - - void* handle_single_param(symbol_c *var_name) { - param_count++; - if (next_param == param_count) - return var_name; - - /* not yet the desired param... */ - return NULL; - } - - void* iterate_list(list_c *list) { - void *res; - for (int i = 0; i < list->n; i++) { - res = list->elements[i]->accept(*this); - if (res != NULL) - return res; - } - return NULL; - } - - - public: - /* start off at the first parameter once again... */ - void reset(void) { - next_param = param_count = 0; - current_param_name = NULL; - current_param_type = current_param_default_value = NULL; - en_declared = false; - eno_declared = false; - } - - /* initialise the iterator object. - * We must be given a reference to the function declaration - * that will be analysed... - */ - function_param_iterator_c(function_declaration_c *f_decl) { - this->f_decl = f_decl; - reset(); - } - - /* initialise the iterator object. - * We must be given a reference to the function block declaration - * that will be analysed... - */ - function_param_iterator_c(function_block_declaration_c *fb_decl) { - this->f_decl = fb_decl; - reset(); - } - - /* initialise the iterator object. - * We must be given a reference to the program declaration - * that will be analysed... - */ - function_param_iterator_c(program_declaration_c *p_decl) { - this->f_decl = p_decl; - reset(); - } - - /* Skip to the next parameter. After object creation, - * the object references on parameter _before_ the first, so - * this function must be called once to get the object to - * reference the first parameter... - * - * Returns the parameter's name! - */ - identifier_c *next(void) { - void *res; - identifier_c *identifier; - param_count = 0; - next_param++; - res = f_decl->accept(*this); - if (res != NULL) { - symbol_c *sym = (symbol_c *)res; - identifier = dynamic_cast(sym); - if (identifier == NULL) - ERROR; - } - else if (!en_declared) { - current_param_direction = direction_in; - identifier = declare_en_param(); - } - else if (!eno_declared) { - current_param_direction = direction_out; - identifier = declare_eno_param(); - } - else - return NULL; - - current_param_name = identifier; - return current_param_name; - } - - identifier_c *declare_en_param(void) { - en_declared = true; - identifier_c *identifier = new identifier_c("EN"); - current_param_type = (symbol_c*)(new bool_type_name_c()); - current_param_default_value = (symbol_c*)(new boolean_literal_c(current_param_type, new boolean_true_c())); - return identifier; - } - - identifier_c *declare_eno_param(void) { - eno_declared = true; - identifier_c *identifier = new identifier_c("ENO"); - current_param_type = (symbol_c*)(new bool_type_name_c()); - current_param_default_value = NULL; - return identifier; - } - - /* Returns the currently referenced parameter's default value, - * or NULL if none is specified in the function declrataion itself. - */ - symbol_c *default_value(void) { - return current_param_default_value; - } - - /* Returns the currently referenced parameter's type name. */ - symbol_c *param_type(void) { - return current_param_type; - } - - /* Returns the currently referenced parameter's data passing direction. - * i.e. VAR_INPUT, VAR_OUTPUT or VAR_INOUT - */ - param_direction_t param_direction(void) { - return current_param_direction; - } - -/******************************************/ -/* B 1.4.3 - Declaration & Initialisation */ -/******************************************/ - void *visit(input_declarations_c *symbol) { - TRACE("input_declarations_c"); - current_param_direction = direction_in; - return symbol->input_declaration_list->accept(*this); - } - void *visit(input_declaration_list_c *symbol) {TRACE("input_declaration_list_c"); return iterate_list(symbol);} - void *visit(edge_declaration_c *symbol) {TRACE("edge_declaration_c"); return symbol->var1_list->accept(*this);} - void *visit(en_param_declaration_c *symbol) { - TRACE("en_param_declaration_c"); - if (en_declared) ERROR; - return (void *)declare_en_param(); - } - - /* var1_list ':' array_spec_init */ - //SYM_REF2(array_var_init_decl_c, var1_list, array_spec_init) - void *visit(array_var_init_decl_c *symbol) {TRACE("array_var_init_decl_c"); return symbol->var1_list->accept(*this);} - - /* var1_list ':' initialized_structure */ - //SYM_REF2(structured_var_init_decl_c, var1_list, initialized_structure) - void *visit(structured_var_init_decl_c *symbol) {TRACE("structured_var_init_decl_c"); return symbol->var1_list->accept(*this);} - -#if 0 -/* name_list ':' function_block_type_name ASSIGN structure_initialization */ -/* structure_initialization -> may be NULL ! */ -SYM_REF4(fb_name_decl_c, fb_name_list, function_block_type_name, structure_initialization, unused) - -/* name_list ',' fb_name */ -SYM_LIST(fb_name_list_c) -#endif - - void *visit(output_declarations_c *symbol) { - TRACE("output_declarations_c"); - current_param_direction = direction_out; - return symbol->var_init_decl_list->accept(*this); - } - void *visit(eno_param_declaration_c *symbol) { - TRACE("eno_param_declaration_c"); - if (eno_declared) ERROR; - return (void *)declare_eno_param(); - } - void *visit(input_output_declarations_c *symbol) { - TRACE("input_output_declarations_c"); - current_param_direction = direction_inout; - return symbol->var_declaration_list->accept(*this); - } - void *visit(var_declaration_list_c *symbol) {TRACE("var_declaration_list_c"); return iterate_list(symbol);} - - - /* var1_list ':' array_specification */ - //SYM_REF2(array_var_declaration_c, var1_list, array_specification) - void *visit(array_var_declaration_c *symbol) {TRACE("array_var_declaration_c"); return symbol->var1_list->accept(*this);} - - /* var1_list ':' structure_type_name */ - //SYM_REF2(structured_var_declaration_c, var1_list, structure_type_name) - void *visit(structured_var_declaration_c *symbol) {TRACE("structured_var_declaration_c"); return symbol->var1_list->accept(*this);} - - /* VAR [CONSTANT] var_init_decl_list END_VAR */ - void *visit(var_declarations_c *symbol) {TRACE("var_declarations_c"); return NULL;} - -#if 0 -/* VAR RETAIN var_init_decl_list END_VAR */ -SYM_REF2(retentive_var_declarations_c, var_init_decl_list, unused) - -/* VAR [CONSTANT|RETAIN|NON_RETAIN] located_var_decl_list END_VAR */ -/* option -> may be NULL ! */ -SYM_REF2(located_var_declarations_c, option, located_var_decl_list) - -/* helper symbol for located_var_declarations */ -/* located_var_decl_list located_var_decl ';' */ -SYM_LIST(located_var_decl_list_c) - -/* [variable_name] location ':' located_var_spec_init */ -/* variable_name -> may be NULL ! */ -SYM_REF4(located_var_decl_c, variable_name, location, located_var_spec_init, unused) -#endif - -/*| VAR_EXTERNAL [CONSTANT] external_declaration_list END_VAR */ -/* option -> may be NULL ! */ -// SYM_REF2(external_var_declarations_c, option, external_declaration_list) - void *visit(external_var_declarations_c *symbol) { - TRACE("external_var_declarations_c"); - current_param_direction = direction_extref; - return symbol->external_declaration_list->accept(*this); - } - -/* helper symbol for external_var_declarations */ -/*| external_declaration_list external_declaration';' */ -// SYM_LIST(external_declaration_list_c) - void *visit(external_declaration_list_c *symbol) {TRACE("external_declaration_list_c"); return iterate_list(symbol);} - -/* global_var_name ':' (simple_specification|subrange_specification|enumerated_specification|array_specification|prev_declared_structure_type_name|function_block_type_name */ -//SYM_REF2(external_declaration_c, global_var_name, specification) - void *visit(external_declaration_c *symbol) { - TRACE("external_declaration_c"); - /* It is OK to store these values in the current_param_XXX - * variables, because if the desired parameter is not in the - * variable list we will be analysing, the current_param_XXXX - * variables will get overwritten when we visit the next - * var1_init_decl_c list! - */ - current_param_default_value = spec_init_sperator_c::get_init(symbol->specification); - current_param_type = spec_init_sperator_c::get_spec(symbol->specification); - - return handle_single_param(symbol->global_var_name); - } - - -#if 0 -/*| VAR_GLOBAL [CONSTANT|RETAIN] global_var_decl_list END_VAR */ -/* option -> may be NULL ! */ -SYM_REF2(global_var_declarations_c, option, global_var_decl_list) - -/* helper symbol for global_var_declarations */ -/*| global_var_decl_list global_var_decl ';' */ -SYM_LIST(global_var_decl_list_c) - -/*| global_var_spec ':' [located_var_spec_init|function_block_type_name] */ -/* type_specification ->may be NULL ! */ -SYM_REF2(global_var_decl_c, global_var_spec, type_specification) - -/*| global_var_name location */ -SYM_REF2(global_var_spec_c, global_var_name, location) - -/* AT direct_variable */ -SYM_REF2(location_c, direct_variable, unused) - -/*| global_var_list ',' global_var_name */ -SYM_LIST(global_var_list_c) - -/* var1_list ':' single_byte_string_spec */ -SYM_REF2(single_byte_string_var_declaration_c, var1_list, single_byte_string_spec) - -/* STRING ['[' integer ']'] [ASSIGN single_byte_character_string] */ -/* integer ->may be NULL ! */ -/* single_byte_character_string ->may be NULL ! */ -SYM_REF2(single_byte_string_spec_c, integer, single_byte_character_string) - -/* var1_list ':' double_byte_string_spec */ -SYM_REF2(double_byte_string_var_declaration_c, var1_list, double_byte_string_spec) - -/* WSTRING ['[' integer ']'] [ASSIGN double_byte_character_string] */ -/* integer ->may be NULL ! */ -/* double_byte_character_string ->may be NULL ! */ -SYM_REF2(double_byte_string_spec_c, integer, double_byte_character_string) - -/*| VAR [RETAIN|NON_RETAIN] incompl_located_var_decl_list END_VAR */ -/* option ->may be NULL ! */ -SYM_REF2(incompl_located_var_declarations_c, option, incompl_located_var_decl_list) - -/* helper symbol for incompl_located_var_declarations */ -/*| incompl_located_var_decl_list incompl_located_var_decl ';' */ -SYM_LIST(incompl_located_var_decl_list_c) - -/* variable_name incompl_location ':' var_spec */ -SYM_REF4(incompl_located_var_decl_c, variable_name, incompl_location, var_spec, unused) - -/* AT incompl_location_token */ -SYM_TOKEN(incompl_location_c) -#endif - - - void *visit(var1_init_decl_c *symbol) { - TRACE("var1_init_decl_c"); - /* It is OK to store these values in the current_param_XXX - * variables, because if the desired parameter is not in the - * variable list we will be analysing, the current_param_XXXX - * variables will get overwritten when we visit the next - * var1_init_decl_c list! - */ - current_param_default_value = spec_init_sperator_c::get_init(symbol->spec_init); - current_param_type = spec_init_sperator_c::get_spec(symbol->spec_init); - - return symbol->var1_list->accept(*this); - } - - - - void *visit(var1_list_c *symbol) { - TRACE("var1_list_c"); - return handle_param_list(symbol); - } - - void *visit(var_init_decl_list_c *symbol) {TRACE("var_init_decl_list_c"); return iterate_list(symbol);} - - -/***********************/ -/* B 1.5.1 - Functions */ -/***********************/ - void *visit(function_declaration_c *symbol) {TRACE("function_declaration_c"); return symbol->var_declarations_list->accept(*this);} - /* intermediate helper symbol for function_declaration */ - void *visit(var_declarations_list_c *symbol) {TRACE("var_declarations_list_c"); return iterate_list(symbol);} - void *visit(function_var_decls_c *symbol) {TRACE("function_var_decls_c"); /* ignore */ return NULL;} - - -/*****************************/ -/* B 1.5.2 - Function Blocks */ -/*****************************/ -/* FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations function_block_body END_FUNCTION_BLOCK */ - void *visit(function_block_declaration_c *symbol) {TRACE("function_block_declaration_c"); return symbol->var_declarations->accept(*this);} - -/* intermediate helper symbol for function_declaration */ -/* { io_var_declarations | other_var_declarations } */ -/* - * NOTE: we re-use the var_declarations_list_c - */ - -/* VAR_TEMP temp_var_decl_list END_VAR */ - void *visit(temp_var_decls_c *symbol) {TRACE("temp_var_decls_c"); /* ignore */ return NULL;} - void *visit(temp_var_decls_list_c *symbol) {TRACE("temp_var_decls_list_c"); /* ignore */ return NULL;} - -/* VAR NON_RETAIN var_init_decl_list END_VAR */ - void *visit(non_retentive_var_decls_c *symbol) {TRACE("non_retentive_var_decls_c"); /* ignore */ return NULL;} - - -/**********************/ -/* B 1.5.3 - Programs */ -/**********************/ -/* PROGRAM program_type_name program_var_declarations_list function_block_body END_PROGRAM */ -// SYM_REF4(program_declaration_c, program_type_name, var_declarations, function_block_body, unused) - void *visit(program_declaration_c *symbol) {TRACE("program_declaration_c"); return symbol->var_declarations->accept(*this);} - -/* intermediate helper symbol for program_declaration_c */ -/* { io_var_declarations | other_var_declarations } */ -/* - * NOTE: we re-use the var_declarations_list_c - */ - -}; - - - - - - -