mario@181: /* msousa@265: * matiec - a compiler for the programming languages defined in IEC 61131-3 msousa@265: * msousa@265: * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt) Edouard@279: * Copyright (C) 2007-2011 Laurent Bessard and Edouard Tisserant msousa@265: * msousa@265: * This program is free software: you can redistribute it and/or modify msousa@265: * it under the terms of the GNU General Public License as published by msousa@265: * the Free Software Foundation, either version 3 of the License, or msousa@265: * (at your option) any later version. msousa@265: * msousa@265: * This program is distributed in the hope that it will be useful, msousa@265: * but WITHOUT ANY WARRANTY; without even the implied warranty of msousa@265: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the msousa@265: * GNU General Public License for more details. msousa@265: * msousa@265: * You should have received a copy of the GNU General Public License msousa@265: * along with this program. If not, see . msousa@265: * mario@181: * mario@181: * This code is made available on the understanding that it will not be mario@181: * used in safety-critical situations without a full and competent review. mario@181: */ mario@181: mario@181: /* msousa@265: * An IEC 61131-3 compiler. mario@181: * mario@181: * Based on the mario@181: * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) mario@181: * mario@181: */ mario@181: msousa@504: /* Search in a VAR* END_VAR declaration for the delcration of the specified variable instance. msousa@504: * Will return: msousa@504: * - the declaration itself (get_decl() ) msousa@504: * - the type of declaration in which the variable was declared (get_vartype() ) msousa@504: * msousa@504: * The variable instance may NOT be a member of a structure of a memeber mario@181: * of a structure of an element of an array of ... mario@181: * msousa@504: * For example, considering the following 'variables': mario@181: * window.points[1].coordinate.x mario@181: * window.points[1].colour msousa@504: * offset[99] msousa@504: * msousa@504: * passing a reference to 'points', 'points[1]', 'points[1].colour', 'colour' msousa@504: * ARE NOT ALLOWED! mario@181: * mario@181: * This class must only be passed the name of the variable that will appear mario@181: * in the variable declaration. In the above examples, this would be msousa@504: * 'window.points[1].coordinate.x' msousa@504: * 'window.points[1].coordinate' msousa@504: * 'window.points[1]' msousa@504: * 'window' msousa@504: * 'window.points[1].colour' msousa@504: * 'offset' msousa@504: * 'offset[99]' msousa@504: * msousa@504: * msousa@504: */ msousa@504: msousa@504: /* Note: msousa@504: * Determining the declaration type of a specific variable instance (including msousa@504: * function block instances) really means determining whether the variable was declared in a msousa@504: * VAR_INPUT msousa@504: * VAR_OUTPUT msousa@504: * VAR_IN_OUT msousa@504: * VAR msousa@504: * VAR_TEMP msousa@504: * VAR_EXTERNAL msousa@504: * VAR_GLOBAL msousa@504: * VAR AT -> Located variable! msousa@504: * msousa@504: */ msousa@504: msousa@504: /* Note: msousa@504: * The current_type_decl that this class returns may reference the mario@181: * name of a type, or the type declaration itself! mario@181: * For an example of the first, consider a variable declared as ... mario@181: * x : AAA; mario@181: * where the AAA type is previously declared as whatever. mario@181: * For an example of the second, consider a variable declared as ... mario@181: * x : array of int [10]; ----> is allowed mario@181: * mario@181: * If it is the first, we will return a reference to the name, if the second mario@181: * we return a reference to the declaration!! mario@181: */ msousa@504: msousa@504: mario@181: #include "absyntax_utils.hh" mario@181: mario@181: msousa@504: msousa@504: msousa@504: mario@181: search_var_instance_decl_c::search_var_instance_decl_c(symbol_c *search_scope) { mario@181: this->current_vartype = none_vt; mario@181: this->search_scope = search_scope; mario@181: this->search_name = NULL; mario@181: this->current_type_decl = NULL; manuele@507: this->current_option = none_opt; mario@181: } mario@181: msousa@504: symbol_c *search_var_instance_decl_c::get_decl(symbol_c *variable) { laurent@217: this->current_vartype = none_vt; manuele@507: this->current_option = none_opt; msousa@504: this->search_name = get_var_name_c::get_name(variable); mario@181: return (symbol_c *)search_scope->accept(*this); mario@181: } mario@181: msousa@536: search_var_instance_decl_c::vt_t search_var_instance_decl_c::get_vartype(symbol_c *variable) { msousa@417: this->current_vartype = none_vt; manuele@507: this->current_option = none_opt; msousa@504: this->search_name = get_var_name_c::get_name(variable); msousa@417: search_scope->accept(*this); manuele@507: return this->current_vartype; manuele@507: } manuele@507: msousa@536: search_var_instance_decl_c::opt_t search_var_instance_decl_c::get_option(symbol_c *variable) { manuele@507: this->current_vartype = none_vt; manuele@507: this->current_option = none_opt; manuele@507: this->search_name = get_var_name_c::get_name(variable); manuele@507: search_scope->accept(*this); manuele@507: return this->current_option; manuele@507: } msousa@417: msousa@531: msousa@531: msousa@531: /* This is a temporary fix. Hopefully, once I clean up stage4 code, and I change the way msousa@531: * we generate C code, this function will no longer be needed! msousa@531: */ msousa@531: #include /* required for typeid() */ msousa@531: bool search_var_instance_decl_c::type_is_complex(symbol_c *symbol) { msousa@531: symbol_c *decl; msousa@531: search_base_type_c search_base_type; msousa@531: msousa@531: decl = this->get_decl(symbol); msousa@531: if (NULL == decl) ERROR; msousa@531: decl = search_base_type.get_basetype_decl(decl); msousa@531: if (NULL == decl) ERROR; msousa@531: msousa@531: return ((typeid( *(decl) ) == typeid( array_specification_c )) || msousa@531: // (typeid( *(decl) ) == typeid( array_spec_init_c )) || /* does not seem to be necessary */ msousa@531: (typeid( *(decl) ) == typeid( structure_type_declaration_c )) || msousa@531: (typeid( *(decl) ) == typeid( structure_element_declaration_list_c )) || msousa@531: // (typeid( *(decl) ) == typeid( structure_type_declaration_c )) || /* does not seem to be necessary */ Laurent@706: (typeid( *(decl) ) == typeid( initialized_structure_c )) || Laurent@706: (search_base_type.type_is_fb(decl) && current_vartype == external_vt) msousa@531: ); msousa@531: } msousa@531: Laurent@706: bool search_var_instance_decl_c::type_is_fb(symbol_c *symbol) { Laurent@706: symbol_c *decl; Laurent@706: search_base_type_c search_base_type; Laurent@706: Laurent@706: decl = this->get_decl(symbol); Laurent@706: if (NULL == decl) ERROR; Laurent@706: return search_base_type.type_is_fb(decl); Laurent@706: } msousa@531: mario@181: /***************************/ mario@181: /* B 0 - Programming Model */ mario@181: /***************************/ mario@181: void *search_var_instance_decl_c::visit(library_c *symbol) { mario@181: /* we do not want to search multiple declaration scopes, laurent@217: * so we do not visit all the functions, function blocks, etc... mario@181: */ mario@181: return NULL; mario@181: } mario@181: mario@181: mario@181: mario@181: /******************************************/ laurent@217: /* B 1.4.3 - Declaration & Initialization */ mario@181: /******************************************/ laurent@217: mario@181: /* edge -> The F_EDGE or R_EDGE directive */ mario@181: // SYM_REF2(edge_declaration_c, edge, var1_list) mario@181: // TODO manuele@507: void *search_var_instance_decl_c::visit(constant_option_c *symbol) { manuele@507: current_option = constant_opt; manuele@507: return NULL; manuele@507: } manuele@507: manuele@507: void *search_var_instance_decl_c::visit(retain_option_c *symbol) { manuele@507: current_option = retain_opt; manuele@507: return NULL; manuele@507: } manuele@507: manuele@507: void *search_var_instance_decl_c::visit(non_retain_option_c *symbol) { manuele@507: current_option = non_retain_opt; manuele@507: return NULL; manuele@507: } mario@181: mario@181: void *search_var_instance_decl_c::visit(input_declarations_c *symbol) { mario@181: current_vartype = input_vt; manuele@507: current_option = none_opt; /* not really required. Just to make the code more readable */ manuele@507: if (NULL != symbol->option) manuele@507: symbol->option->accept(*this); mario@181: void *res = symbol->input_declaration_list->accept(*this); mario@181: if (res == NULL) { mario@181: current_vartype = none_vt; manuele@507: current_option = none_opt; mario@181: } mario@181: return res; mario@181: } mario@181: mario@181: /* VAR_OUTPUT [RETAIN | NON_RETAIN] var_init_decl_list END_VAR */ mario@181: /* option -> may be NULL ! */ mario@181: void *search_var_instance_decl_c::visit(output_declarations_c *symbol) { mario@181: current_vartype = output_vt; manuele@507: current_option = none_opt; /* not really required. Just to make the code more readable */ manuele@507: if (NULL != symbol->option) manuele@507: symbol->option->accept(*this); mario@181: void *res = symbol->var_init_decl_list->accept(*this); mario@181: if (res == NULL) { mario@181: current_vartype = none_vt; manuele@507: current_option = none_opt; mario@181: } mario@181: return res; mario@181: } mario@181: mario@181: /* VAR_IN_OUT var_declaration_list END_VAR */ mario@181: void *search_var_instance_decl_c::visit(input_output_declarations_c *symbol) { mario@181: current_vartype = inoutput_vt; manuele@507: current_option = none_opt; /* not really required. Just to make the code more readable */ mario@181: void *res = symbol->var_declaration_list->accept(*this); mario@181: if (res == NULL) { mario@181: current_vartype = none_vt; mario@181: } mario@181: return res; mario@181: } mario@181: ccb@202: /* ENO : BOOL */ ccb@202: void *search_var_instance_decl_c::visit(eno_param_declaration_c *symbol) { ccb@202: if (compare_identifiers(symbol->name, search_name) == 0) ccb@202: return symbol->type; ccb@202: return NULL; ccb@202: } ccb@202: ccb@202: mario@181: /* VAR [CONSTANT] var_init_decl_list END_VAR */ mario@181: /* option -> may be NULL ! */ mario@181: /* helper symbol for input_declarations */ mario@181: void *search_var_instance_decl_c::visit(var_declarations_c *symbol) { mario@181: current_vartype = private_vt; manuele@507: current_option = none_opt; /* not really required. Just to make the code more readable */ manuele@507: if (NULL != symbol->option) manuele@507: symbol->option->accept(*this); mario@181: void *res = symbol->var_init_decl_list->accept(*this); mario@181: if (res == NULL) { mario@181: current_vartype = none_vt; manuele@507: current_option = none_opt; mario@181: } mario@181: return res; mario@181: } mario@181: mario@181: /* VAR RETAIN var_init_decl_list END_VAR */ mario@181: void *search_var_instance_decl_c::visit(retentive_var_declarations_c *symbol) { mario@181: current_vartype = private_vt; manuele@507: current_option = retain_opt; mario@181: void *res = symbol->var_init_decl_list->accept(*this); mario@181: if (res == NULL) { mario@181: current_vartype = none_vt; manuele@507: current_option = none_opt; mario@181: } mario@181: return res; mario@181: } mario@181: mario@181: /* VAR [CONSTANT|RETAIN|NON_RETAIN] located_var_decl_list END_VAR */ mario@181: /* option -> may be NULL ! */ mario@181: //SYM_REF2(located_var_declarations_c, option, located_var_decl_list) mario@181: void *search_var_instance_decl_c::visit(located_var_declarations_c *symbol) { mario@181: current_vartype = located_vt; manuele@507: current_option = none_opt; /* not really required. Just to make the code more readable */ manuele@507: if (NULL != symbol->option) manuele@507: symbol->option->accept(*this); mario@181: void *res = symbol->located_var_decl_list->accept(*this); mario@181: if (res == NULL) { mario@181: current_vartype = none_vt; manuele@507: current_option = none_opt; mario@181: } mario@181: return res; mario@181: } mario@181: mario@181: /*| VAR_EXTERNAL [CONSTANT] external_declaration_list END_VAR */ mario@181: /* option -> may be NULL ! */ mario@181: //SYM_REF2(external_var_declarations_c, option, external_declaration_list) mario@181: void *search_var_instance_decl_c::visit(external_var_declarations_c *symbol) { mario@181: current_vartype = external_vt; manuele@507: current_option = none_opt; /* not really required. Just to make the code more readable */ manuele@507: if (NULL != symbol->option) manuele@507: symbol->option->accept(*this); mario@181: void *res = symbol->external_declaration_list->accept(*this); mario@181: if (res == NULL) { mario@181: current_vartype = none_vt; manuele@507: current_option = none_opt; mario@181: } mario@181: return res; mario@181: } mario@181: mario@181: /*| VAR_GLOBAL [CONSTANT|RETAIN] global_var_decl_list END_VAR */ mario@181: /* option -> may be NULL ! */ mario@181: //SYM_REF2(global_var_declarations_c, option, global_var_decl_list) mario@181: void *search_var_instance_decl_c::visit(global_var_declarations_c *symbol) { mario@181: current_vartype = global_vt; manuele@507: current_option = none_opt; /* not really required. Just to make the code more readable */ manuele@507: if (NULL != symbol->option) manuele@507: symbol->option->accept(*this); mario@181: void *res = symbol->global_var_decl_list->accept(*this); mario@181: if (res == NULL) { mario@181: current_vartype = none_vt; manuele@507: current_option = none_opt; mario@181: } mario@181: return res; mario@181: } mario@181: mario@181: /* var1_list is one of the following... mario@181: * simple_spec_init_c * mario@181: * subrange_spec_init_c * mario@181: * enumerated_spec_init_c * mario@181: */ mario@181: // SYM_REF2(var1_init_decl_c, var1_list, spec_init) mario@181: void *search_var_instance_decl_c::visit(var1_init_decl_c *symbol) { mario@181: current_type_decl = symbol->spec_init; mario@181: return symbol->var1_list->accept(*this); mario@181: } mario@181: mario@181: /* var1_list ',' variable_name */ mario@181: // SYM_LIST(var1_list_c) mario@181: void *search_var_instance_decl_c::visit(var1_list_c *symbol) { mario@181: list_c *list = symbol; mario@181: for(int i = 0; i < list->n; i++) { mario@181: if (compare_identifiers(list->elements[i], search_name) == 0) mario@181: /* by now, current_type_decl should be != NULL */ mario@181: return current_type_decl; mario@181: } mario@181: return NULL; mario@181: } mario@181: mario@181: /* name_list ':' function_block_type_name ASSIGN structure_initialization */ mario@181: /* structure_initialization -> may be NULL ! */ mario@181: void *search_var_instance_decl_c::visit(fb_name_decl_c *symbol) { mario@181: current_type_decl = symbol->function_block_type_name; mario@181: return symbol->fb_name_list->accept(*this); mario@181: } mario@181: mario@181: /* name_list ',' fb_name */ mario@181: void *search_var_instance_decl_c::visit(fb_name_list_c *symbol) { mario@181: list_c *list = symbol; mario@181: for(int i = 0; i < list->n; i++) { mario@181: if (compare_identifiers(list->elements[i], search_name) == 0) msousa@504: /* by now, current_fb_declaration should be != NULL */ mario@181: return current_type_decl; mario@181: } mario@181: return NULL; mario@181: } mario@181: mario@181: /* var1_list ':' array_spec_init */ mario@181: // SYM_REF2(array_var_init_decl_c, var1_list, array_spec_init) mario@181: void *search_var_instance_decl_c::visit(array_var_init_decl_c *symbol) { mario@181: current_type_decl = symbol->array_spec_init; mario@181: return symbol->var1_list->accept(*this); mario@181: } mario@181: mario@181: /* var1_list ':' initialized_structure */ mario@181: // SYM_REF2(structured_var_init_decl_c, var1_list, initialized_structure) mario@181: void *search_var_instance_decl_c::visit(structured_var_init_decl_c *symbol) { mario@181: current_type_decl = symbol->initialized_structure; mario@181: return symbol->var1_list->accept(*this); mario@181: } mario@181: mario@181: /* var1_list ':' array_specification */ mario@181: // SYM_REF2(array_var_declaration_c, var1_list, array_specification) mario@181: void *search_var_instance_decl_c::visit(array_var_declaration_c *symbol) { mario@181: current_type_decl = symbol->array_specification; mario@181: return symbol->var1_list->accept(*this); mario@181: } mario@181: mario@181: /* var1_list ':' structure_type_name */ mario@181: // SYM_REF2(structured_var_declaration_c, var1_list, structure_type_name) mario@181: void *search_var_instance_decl_c::visit(structured_var_declaration_c *symbol) { mario@181: current_type_decl = symbol->structure_type_name; mario@181: return symbol->var1_list->accept(*this); mario@181: } mario@181: mario@181: /* [variable_name] location ':' located_var_spec_init */ mario@181: /* variable_name -> may be NULL ! */ mario@181: // SYM_REF4(located_var_decl_c, variable_name, location, located_var_spec_init, unused) mario@181: // TODO!! mario@181: mario@181: /* global_var_name ':' (simple_specification|subrange_specification|enumerated_specification|array_specification|prev_declared_structure_type_name|function_block_type_name */ mario@181: // SYM_REF2(external_declaration_c, global_var_name, specification) mario@181: void *search_var_instance_decl_c::visit(external_declaration_c *symbol) { mario@181: if (compare_identifiers(symbol->global_var_name, search_name) == 0) mario@181: return symbol->specification; mario@181: return NULL; mario@181: } mario@181: mario@181: /*| global_var_spec ':' [located_var_spec_init|function_block_type_name] */ mario@181: /* type_specification ->may be NULL ! */ mario@181: // SYM_REF2(global_var_decl_c, global_var_spec, type_specification) mario@181: void *search_var_instance_decl_c::visit(global_var_decl_c *symbol) { mario@181: if (symbol->type_specification != NULL) { mario@181: current_type_decl = symbol->type_specification; mario@181: return symbol->global_var_spec->accept(*this); mario@181: } mario@181: else mario@181: return NULL; mario@181: } mario@181: mario@181: /*| global_var_name location */ mario@181: //SYM_REF2(global_var_spec_c, global_var_name, location) mario@181: void *search_var_instance_decl_c::visit(global_var_spec_c *symbol) { mario@181: if (symbol->global_var_name != NULL && compare_identifiers(symbol->global_var_name, search_name) == 0) mario@181: return current_type_decl; mario@181: else mario@181: return symbol->location->accept(*this); mario@181: } mario@181: mario@181: /*| global_var_list ',' global_var_name */ mario@181: //SYM_LIST(global_var_list_c) mario@181: void *search_var_instance_decl_c::visit(global_var_list_c *symbol) { mario@181: list_c *list = symbol; mario@181: for(int i = 0; i < list->n; i++) { mario@181: if (compare_identifiers(list->elements[i], search_name) == 0) mario@181: /* by now, current_type_decl should be != NULL */ mario@181: return current_type_decl; mario@181: } mario@181: return NULL; mario@181: } mario@181: mario@181: /* [variable_name] location ':' located_var_spec_init */ mario@181: /* variable_name -> may be NULL ! */ mario@181: //SYM_REF4(located_var_decl_c, variable_name, location, located_var_spec_init, unused) mario@181: void *search_var_instance_decl_c::visit(located_var_decl_c *symbol) { mario@181: if (symbol->variable_name != NULL && compare_identifiers(symbol->variable_name, search_name) == 0) mario@181: return symbol->located_var_spec_init; mario@181: else { mario@181: current_type_decl = symbol->located_var_spec_init; mario@181: return symbol->location->accept(*this); mario@181: } mario@181: } mario@181: mario@181: /*| global_var_spec ':' [located_var_spec_init|function_block_type_name] */ mario@181: /* type_specification ->may be NULL ! */ mario@181: // SYM_REF2(global_var_decl_c, global_var_spec, type_specification) mario@181: // TODO!! mario@181: mario@181: /* AT direct_variable */ mario@181: // SYM_REF2(location_c, direct_variable, unused) mario@181: void *search_var_instance_decl_c::visit(location_c *symbol) { mario@181: if (compare_identifiers(symbol->direct_variable, search_name) == 0) mario@181: return current_type_decl; mario@181: else mario@181: return NULL; mario@181: } mario@181: mario@181: /*| global_var_list ',' global_var_name */ mario@181: // SYM_LIST(global_var_list_c) mario@181: // TODO!! mario@181: mario@181: /* var1_list ':' single_byte_string_spec */ mario@181: // SYM_REF2(single_byte_string_var_declaration_c, var1_list, single_byte_string_spec) mario@181: void *search_var_instance_decl_c::visit(single_byte_string_var_declaration_c *symbol) { mario@181: current_type_decl = symbol->single_byte_string_spec; mario@181: return symbol->var1_list->accept(*this); mario@181: } mario@181: mario@181: /* STRING ['[' integer ']'] [ASSIGN single_byte_character_string] */ mario@181: /* integer ->may be NULL ! */ mario@181: /* single_byte_character_string ->may be NULL ! */ mario@181: // SYM_REF2(single_byte_string_spec_c, integer, single_byte_character_string) mario@181: // TODO!! mario@181: mario@181: /* var1_list ':' double_byte_string_spec */ mario@181: // SYM_REF2(double_byte_string_var_declaration_c, var1_list, double_byte_string_spec) mario@181: void *search_var_instance_decl_c::visit(double_byte_string_var_declaration_c *symbol) { mario@181: current_type_decl = symbol->double_byte_string_spec; mario@181: return symbol->var1_list->accept(*this); mario@181: } mario@181: mario@181: /* WSTRING ['[' integer ']'] [ASSIGN double_byte_character_string] */ mario@181: /* integer ->may be NULL ! */ mario@181: /* double_byte_character_string ->may be NULL ! */ mario@181: // SYM_REF2(double_byte_string_spec_c, integer, double_byte_character_string) mario@181: // TODO!! mario@181: mario@181: /* variable_name incompl_location ':' var_spec */ mario@181: // SYM_REF4(incompl_located_var_decl_c, variable_name, incompl_location, var_spec, unused) mario@181: // TODO!! mario@181: mario@181: /* AT incompl_location_token */ mario@181: // SYM_TOKEN(incompl_location_c) mario@181: // TODO!! mario@181: mario@181: mario@181: /**************************************/ mario@181: /* B.1.5 - Program organization units */ mario@181: /**************************************/ mario@181: /***********************/ mario@181: /* B 1.5.1 - Functions */ mario@181: /***********************/ mario@181: // SYM_REF4(function_declaration_c, derived_function_name, type_name, var_declarations_list, function_body) mario@181: void *search_var_instance_decl_c::visit(function_declaration_c *symbol) { mario@181: /* functions have a variable named after themselves, to store mario@181: * the variable that will be returned!! mario@181: */ mario@181: if (compare_identifiers(symbol->derived_function_name, search_name) == 0) mario@181: return symbol->type_name; mario@181: mario@181: /* no need to search through all the body, so we only mario@181: * visit the variable declarations...! mario@181: */ mario@181: return symbol->var_declarations_list->accept(*this); mario@181: } mario@181: mario@181: /*****************************/ mario@181: /* B 1.5.2 - Function Blocks */ mario@181: /*****************************/ msousa@619: /* FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations function_block_body END_FUNCTION_BLOCK */ msousa@619: // SYM_REF3(function_block_declaration_c, fblock_name, var_declarations, fblock_body) mario@181: void *search_var_instance_decl_c::visit(function_block_declaration_c *symbol) { msousa@619: /* visit the variable declarations...! */ msousa@619: void *res = symbol->var_declarations->accept(*this); msousa@619: if (NULL != res) msousa@619: return res; msousa@619: msousa@619: /* not yet found, so we look into the body, to see if it is an SFC step! */ msousa@619: return symbol->fblock_body->accept(*this); mario@181: } mario@181: mario@181: /**********************/ mario@181: /* B 1.5.3 - Programs */ mario@181: /**********************/ msousa@619: /* PROGRAM program_type_name program_var_declarations_list function_block_body END_PROGRAM */ msousa@619: // SYM_REF3(program_declaration_c, program_type_name, var_declarations, function_block_body) mario@181: void *search_var_instance_decl_c::visit(program_declaration_c *symbol) { msousa@619: /* visit the variable declarations...! */ msousa@619: void *res = symbol->var_declarations->accept(*this); msousa@619: if (NULL != res) msousa@619: return res; msousa@619: msousa@619: /* not yet found, so we look into the body, to see if it is an SFC step! */ msousa@619: return symbol->function_block_body->accept(*this); msousa@619: } msousa@619: msousa@619: msousa@619: /*********************************************/ msousa@619: /* B.1.6 Sequential function chart elements */ msousa@619: /*********************************************/ msousa@619: /* | sequential_function_chart sfc_network */ msousa@619: // SYM_LIST(sequential_function_chart_c) msousa@619: /* search_var_instance_decl_c inherits from serach_visitor_c, so no need to implement the following method. */ msousa@619: // void *search_var_instance_decl_c::visit(sequential_function_chart_c *symbol) {...} msousa@619: msousa@619: /* initial_step {step | transition | action} */ msousa@619: // SYM_LIST(sfc_network_c) msousa@619: /* search_var_instance_decl_c inherits from serach_visitor_c, so no need to implement the following method. */ msousa@619: // void *search_var_instance_decl_c::visit(sfc_network_c *symbol) {...} msousa@619: msousa@619: msousa@619: /* INITIAL_STEP step_name ':' action_association_list END_STEP */ msousa@619: // SYM_REF2(initial_step_c, step_name, action_association_list) msousa@619: void *search_var_instance_decl_c::visit(initial_step_c *symbol) { msousa@619: if (compare_identifiers(symbol->step_name, search_name) == 0) msousa@619: return symbol; msousa@619: return NULL; msousa@619: } msousa@619: msousa@619: /* STEP step_name ':' action_association_list END_STEP */ msousa@619: // SYM_REF2(step_c, step_name, action_association_list) msousa@619: void *search_var_instance_decl_c::visit(step_c *symbol) { msousa@619: if (compare_identifiers(symbol->step_name, search_name) == 0) msousa@619: return symbol; msousa@619: return NULL; mario@181: } mario@181: mario@181: mario@181: /********************************/ mario@181: /* B 1.7 Configuration elements */ mario@181: /********************************/ mario@181: mario@181: /* mario@181: CONFIGURATION configuration_name mario@181: optional_global_var_declarations mario@181: (resource_declaration_list | single_resource_declaration) mario@181: optional_access_declarations mario@181: optional_instance_specific_initializations mario@181: END_CONFIGURATION mario@181: */ mario@181: /* mario@181: SYM_REF6(configuration_declaration_c, configuration_name, global_var_declarations, resource_declarations, access_declarations, instance_specific_initializations, unused) mario@181: */ mario@181: void *search_var_instance_decl_c::visit(configuration_declaration_c *symbol) { mario@181: /* no need to search through all the configuration, so we only mario@181: * visit the global variable declarations...! mario@181: */ mario@181: if (symbol->global_var_declarations != NULL) mario@181: return symbol->global_var_declarations->accept(*this); mario@181: else mario@181: return NULL; mario@181: } mario@181: mario@181: /* mario@181: RESOURCE resource_name ON resource_type_name mario@181: optional_global_var_declarations mario@181: single_resource_declaration mario@181: END_RESOURCE mario@181: */ mario@181: // SYM_REF4(resource_declaration_c, resource_name, resource_type_name, global_var_declarations, resource_declaration) mario@181: void *search_var_instance_decl_c::visit(resource_declaration_c *symbol) { mario@181: /* no need to search through all the resource, so we only mario@181: * visit the global variable declarations...! mario@181: */ mario@181: if (symbol->global_var_declarations != NULL) mario@181: return symbol->global_var_declarations->accept(*this); mario@181: else mario@181: return NULL; mario@181: } mario@181: mario@181: /* task_configuration_list program_configuration_list */ mario@181: // SYM_REF2(single_resource_declaration_c, task_configuration_list, program_configuration_list) mario@181: void *search_var_instance_decl_c::visit(single_resource_declaration_c *symbol) { mario@181: /* no need to search through all the resource, mario@181: * and there is no global variable declarations...! mario@181: */ mario@181: return NULL; mario@181: } mario@181: msousa@619: msousa@619: msousa@619: /****************************************/ msousa@619: /* B.2 - Language IL (Instruction List) */ msousa@619: /****************************************/ msousa@619: /***********************************/ msousa@619: /* B 2.1 Instructions and Operands */ msousa@619: /***********************************/ msousa@619: /*| instruction_list il_instruction */ msousa@619: // SYM_LIST(instruction_list_c) msousa@619: void *search_var_instance_decl_c::visit(instruction_list_c *symbol) { msousa@619: /* IL code does not contain any variable declarations! */ msousa@619: return NULL; msousa@619: } msousa@619: msousa@619: msousa@619: /***************************************/ msousa@619: /* B.3 - Language ST (Structured Text) */ msousa@619: /***************************************/ msousa@619: /********************/ msousa@619: /* B 3.2 Statements */ msousa@619: /********************/ msousa@619: // SYM_LIST(statement_list_c) msousa@619: void *search_var_instance_decl_c::visit(statement_list_c *symbol) { msousa@619: /* ST code does not contain any variable declarations! */ msousa@619: return NULL; msousa@619: }