etisserant@0: /* etisserant@0: * (c) 2003 Mario de Sousa etisserant@0: * etisserant@0: * Offered to the public under the terms of the GNU General Public License etisserant@0: * as published by the Free Software Foundation; either version 2 of the etisserant@0: * License, or (at your option) any later version. etisserant@0: * etisserant@0: * This program is distributed in the hope that it will be useful, but etisserant@0: * WITHOUT ANY WARRANTY; without even the implied warranty of etisserant@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General etisserant@0: * Public License for more details. etisserant@0: * etisserant@0: * This code is made available on the understanding that it will not be etisserant@0: * used in safety-critical situations without a full and competent review. etisserant@0: */ etisserant@0: etisserant@0: /* etisserant@0: * An IEC 61131-3 IL and ST compiler. etisserant@0: * etisserant@0: * Based on the etisserant@0: * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) etisserant@0: * etisserant@0: */ etisserant@0: etisserant@0: /* etisserant@0: * Definition of the Abstract Syntax data structure components etisserant@0: */ etisserant@0: etisserant@0: etisserant@0: /* etisserant@0: * ABSYNTAX.DEF etisserant@0: * etisserant@0: * This generates the parse tree structure used to bind the components etisserant@0: * identified by Bison in the correct syntax order. At the end of the etisserant@0: * Bison analysis the tree is walked in a sequential fashion generating etisserant@0: * the relavent code. etisserant@0: */ etisserant@0: etisserant@0: etisserant@0: /***************************/ etisserant@0: /* 2.1.6 - Pragmas */ etisserant@0: /***************************/ etisserant@0: SYM_TOKEN(pragma_c) etisserant@0: etisserant@0: etisserant@0: /***************************/ etisserant@0: /* B 0 - Programming Model */ etisserant@0: /***************************/ etisserant@0: SYM_LIST(library_c) etisserant@0: etisserant@0: etisserant@0: /*************************/ etisserant@0: /* B.1 - Common elements */ etisserant@0: /*************************/ etisserant@0: /*******************************************/ etisserant@0: /* B 1.1 - Letters, digits and identifiers */ etisserant@0: /*******************************************/ etisserant@0: SYM_TOKEN(identifier_c) etisserant@0: etisserant@0: etisserant@0: /*********************/ etisserant@0: /* B 1.2 - Constants */ etisserant@0: /*********************/ etisserant@0: etisserant@0: /******************************/ etisserant@0: /* B 1.2.1 - Numeric Literals */ etisserant@0: /******************************/ etisserant@0: SYM_TOKEN(real_c) etisserant@0: SYM_TOKEN(integer_c) etisserant@0: SYM_TOKEN(binary_integer_c) etisserant@0: SYM_TOKEN(octal_integer_c) etisserant@0: SYM_TOKEN(hex_integer_c) etisserant@0: etisserant@0: /* Note: etisserant@0: * We do not have signed_integer_c and signed_real_c classes. etisserant@0: * These are stored in the parse tree as a integer_c or real_c etisserant@0: * preceded by a unary minus operator. etisserant@0: */ etisserant@0: /* Not required: etisserant@0: SYM_TOKEN(signed_integer_c) etisserant@0: SYM_TOKEN(signed_real_c) etisserant@0: */ etisserant@0: etisserant@0: SYM_REF2(numeric_literal_c, type, value) etisserant@0: SYM_REF2(integer_literal_c, type, value) etisserant@0: SYM_REF2(real_literal_c, type, value) etisserant@0: SYM_REF2(bit_string_literal_c, type, value) etisserant@0: SYM_REF2(boolean_literal_c, type, value) etisserant@0: etisserant@0: /* helper class for boolean_literal_c */ etisserant@0: SYM_REF0(boolean_true_c) etisserant@0: etisserant@0: /* helper class for boolean_literal_c */ etisserant@0: SYM_REF0(boolean_false_c) etisserant@0: etisserant@0: etisserant@0: /*******************************/ etisserant@0: /* B.1.2.2 Character Strings */ etisserant@0: /*******************************/ etisserant@0: SYM_TOKEN(double_byte_character_string_c) etisserant@0: SYM_TOKEN(single_byte_character_string_c) etisserant@0: etisserant@0: etisserant@0: /***************************/ etisserant@0: /* B 1.2.3 - Time Literals */ etisserant@0: /***************************/ etisserant@0: etisserant@0: /************************/ etisserant@0: /* B 1.2.3.1 - Duration */ etisserant@0: /************************/ etisserant@0: SYM_REF0(neg_time_c) etisserant@0: SYM_REF2(duration_c, neg, interval) etisserant@0: SYM_TOKEN(fixed_point_c) etisserant@0: SYM_REF2(days_c, days, hours) etisserant@0: SYM_REF2(hours_c, hours, minutes) etisserant@0: SYM_REF2(minutes_c, minutes, seconds) etisserant@0: SYM_REF2(seconds_c, seconds, milliseconds) etisserant@0: SYM_REF2(milliseconds_c, milliseconds, unused) etisserant@0: etisserant@0: etisserant@0: /************************************/ etisserant@0: /* B 1.2.3.2 - Time of day and Date */ etisserant@0: /************************************/ etisserant@0: SYM_REF2(time_of_day_c, daytime, unused) etisserant@0: SYM_REF4(daytime_c, day_hour, day_minute, day_second, unused) etisserant@0: SYM_REF2(date_c, date_literal, unused) etisserant@0: SYM_REF4(date_literal_c, year, month, day, unused) etisserant@0: SYM_REF2(date_and_time_c, date_literal, daytime) etisserant@0: etisserant@0: etisserant@0: /**********************/ etisserant@0: /* B.1.3 - Data types */ etisserant@0: /**********************/ etisserant@0: /***********************************/ etisserant@0: /* B 1.3.1 - Elementary Data Types */ etisserant@0: /***********************************/ etisserant@0: SYM_REF0(time_type_name_c) etisserant@0: SYM_REF0(bool_type_name_c) etisserant@0: SYM_REF0(sint_type_name_c) etisserant@0: SYM_REF0(int_type_name_c) etisserant@0: SYM_REF0(dint_type_name_c) etisserant@0: SYM_REF0(lint_type_name_c) etisserant@0: SYM_REF0(usint_type_name_c) etisserant@0: SYM_REF0(uint_type_name_c) etisserant@0: SYM_REF0(udint_type_name_c) etisserant@0: SYM_REF0(ulint_type_name_c) etisserant@0: SYM_REF0(real_type_name_c) etisserant@0: SYM_REF0(lreal_type_name_c) etisserant@0: SYM_REF0(date_type_name_c) etisserant@0: SYM_REF0(tod_type_name_c) etisserant@0: SYM_REF0(dt_type_name_c) etisserant@0: SYM_REF0(byte_type_name_c) etisserant@0: SYM_REF0(word_type_name_c) etisserant@0: SYM_REF0(dword_type_name_c) etisserant@0: SYM_REF0(lword_type_name_c) etisserant@0: SYM_REF0(string_type_name_c) etisserant@0: SYM_REF0(wstring_type_name_c) etisserant@0: etisserant@0: etisserant@0: etisserant@0: /********************************/ etisserant@0: /* B.1.3.2 - Generic data types */ etisserant@0: /********************************/ etisserant@0: etisserant@0: /********************************/ etisserant@0: /* B 1.3.3 - Derived data types */ etisserant@0: /********************************/ etisserant@0: /* TYPE type_declaration_list END_TYPE */ etisserant@0: SYM_REF2(data_type_declaration_c, type_declaration_list, unused) etisserant@0: etisserant@0: /* helper symbol for data_type_declaration */ etisserant@0: SYM_LIST(type_declaration_list_c) etisserant@0: etisserant@0: /* simple_type_name ':' simple_spec_init */ etisserant@0: SYM_REF2(simple_type_declaration_c, simple_type_name, simple_spec_init) etisserant@0: etisserant@0: etisserant@0: /* simple_specification ASSIGN constant */ etisserant@0: SYM_REF2(simple_spec_init_c, simple_specification, constant) etisserant@0: etisserant@0: /* subrange_type_name ':' subrange_spec_init */ etisserant@0: SYM_REF2(subrange_type_declaration_c, subrange_type_name, subrange_spec_init) etisserant@0: etisserant@0: /* subrange_specification ASSIGN signed_integer */ etisserant@0: SYM_REF2(subrange_spec_init_c, subrange_specification, signed_integer) etisserant@0: etisserant@0: /* integer_type_name '(' subrange')' */ etisserant@0: SYM_REF2(subrange_specification_c, integer_type_name, subrange) etisserant@0: etisserant@0: /* signed_integer DOTDOT signed_integer */ etisserant@0: SYM_REF2(subrange_c, lower_limit, upper_limit) etisserant@0: etisserant@0: /* enumerated_type_name ':' enumerated_spec_init */ etisserant@0: SYM_REF2(enumerated_type_declaration_c, enumerated_type_name, enumerated_spec_init) etisserant@0: etisserant@0: /* enumerated_specification ASSIGN enumerated_value */ etisserant@0: SYM_REF2(enumerated_spec_init_c, enumerated_specification, enumerated_value) etisserant@0: etisserant@0: /* helper symbol for enumerated_specification->enumerated_spec_init */ etisserant@0: /* enumerated_value_list ',' enumerated_value */ etisserant@0: SYM_LIST(enumerated_value_list_c) etisserant@0: etisserant@0: /* enumerated_type_name '#' identifier */ etisserant@0: SYM_REF2(enumerated_value_c, type, value) etisserant@0: etisserant@0: /* identifier ':' array_spec_init */ etisserant@0: SYM_REF2(array_type_declaration_c, identifier, array_spec_init) etisserant@0: etisserant@0: /* array_specification [ASSIGN array_initialization} */ etisserant@0: /* array_initialization may be NULL ! */ etisserant@0: SYM_REF2(array_spec_init_c, array_specification, array_initialization) etisserant@0: etisserant@0: /* ARRAY '[' array_subrange_list ']' OF non_generic_type_name */ etisserant@0: SYM_REF2(array_specification_c, array_subrange_list, non_generic_type_name) etisserant@0: etisserant@0: /* helper symbol for array_specification */ etisserant@0: /* array_subrange_list ',' subrange */ etisserant@0: SYM_LIST(array_subrange_list_c) etisserant@0: etisserant@0: /* array_initialization: '[' array_initial_elements_list ']' */ etisserant@0: /* helper symbol for array_initialization */ etisserant@0: /* array_initial_elements_list ',' array_initial_elements */ etisserant@0: SYM_LIST(array_initial_elements_list_c) etisserant@0: etisserant@0: /* integer '(' [array_initial_element] ')' */ etisserant@0: /* array_initial_element may be NULL ! */ etisserant@0: SYM_REF2(array_initial_elements_c, integer, array_initial_element) etisserant@0: etisserant@0: /* structure_type_name ':' structure_specification */ etisserant@0: SYM_REF2(structure_type_declaration_c, structure_type_name, structure_specification) etisserant@0: etisserant@0: /* structure_type_name ASSIGN structure_initialization */ etisserant@0: /* structure_initialization may be NULL ! */ etisserant@0: SYM_REF2(initialized_structure_c, structure_type_name, structure_initialization) etisserant@0: etisserant@0: /* helper symbol for structure_declaration */ etisserant@0: /* structure_declaration: STRUCT structure_element_declaration_list END_STRUCT */ etisserant@0: /* structure_element_declaration_list structure_element_declaration ';' */ etisserant@0: SYM_LIST(structure_element_declaration_list_c) etisserant@0: etisserant@0: /* structure_element_name ':' *_spec_init */ etisserant@0: SYM_REF2(structure_element_declaration_c, structure_element_name, spec_init) etisserant@0: etisserant@0: /* helper symbol for structure_initialization */ etisserant@0: /* structure_initialization: '(' structure_element_initialization_list ')' */ etisserant@0: /* structure_element_initialization_list ',' structure_element_initialization */ etisserant@0: SYM_LIST(structure_element_initialization_list_c) etisserant@0: etisserant@0: /* structure_element_name ASSIGN value */ etisserant@0: SYM_REF2(structure_element_initialization_c, structure_element_name, value) etisserant@0: etisserant@0: /* string_type_name ':' elementary_string_type_name string_type_declaration_size string_type_declaration_init */ etisserant@0: /* etisserant@0: * NOTE: etisserant@0: * (Summary: Contrary to what is expected, the etisserant@0: * string_type_declaration_c is not used to store etisserant@0: * simple string type declarations that do not include etisserant@0: * size limits. etisserant@0: * For e.g.: etisserant@0: * str1_type: STRING := "hello!" etisserant@0: * will be stored in a simple_type_declaration_c etisserant@0: * instead of a string_type_declaration_c. etisserant@0: * The following: etisserant@0: * str2_type: STRING [64] := "hello!" etisserant@0: * will be stored in a sring_type_declaration_c etisserant@0: * etisserant@0: * Read on for why this is done... etisserant@0: * End Summary) etisserant@0: * etisserant@0: * According to the spec, the valid construct etisserant@0: * TYPE new_str_type : STRING := "hello!"; END_TYPE etisserant@0: * has two possible routes to type_declaration... etisserant@0: * etisserant@0: * Route 1: etisserant@0: * type_declaration: single_element_type_declaration etisserant@0: * single_element_type_declaration: simple_type_declaration etisserant@0: * simple_type_declaration: identifier ':' simple_spec_init etisserant@0: * simple_spec_init: simple_specification ASSIGN constant etisserant@0: * (shift: identifier <- 'new_str_type') etisserant@0: * simple_specification: elementary_type_name etisserant@0: * elementary_type_name: STRING etisserant@0: * (shift: elementary_type_name <- STRING) etisserant@0: * (reduce: simple_specification <- elementary_type_name) etisserant@0: * (shift: constant <- "hello!") etisserant@0: * (reduce: simple_spec_init: simple_specification ASSIGN constant) etisserant@0: * (reduce: ...) etisserant@0: * etisserant@0: * etisserant@0: * Route 2: etisserant@0: * type_declaration: string_type_declaration etisserant@0: * string_type_declaration: identifier ':' elementary_string_type_name string_type_declaration_size string_type_declaration_init etisserant@0: * (shift: identifier <- 'new_str_type') etisserant@0: * elementary_string_type_name: STRING etisserant@0: * (shift: elementary_string_type_name <- STRING) etisserant@0: * (shift: string_type_declaration_size <- empty ) etisserant@0: * string_type_declaration_init: ASSIGN character_string etisserant@0: * (shift: character_string <- "hello!") etisserant@0: * (reduce: string_type_declaration_init <- ASSIGN character_string) etisserant@0: * (reduce: string_type_declaration <- identifier ':' elementary_string_type_name string_type_declaration_size string_type_declaration_init ) etisserant@0: * (reduce: type_declaration <- string_type_declaration) etisserant@0: * etisserant@0: * etisserant@0: * At first glance it seems that removing route 1 would make etisserant@0: * the most sense. Unfortunately the construct 'simple_spec_init' etisserant@0: * shows up multiple times in other rules, so changing this construct etisserant@0: * would also mean changing all the rules in which it appears. etisserant@0: * I (Mario) therefore chose to remove route 2 instead. This means etisserant@0: * that the above declaration gets stored in a etisserant@0: * simple_type_declaration_c, and not in a string_type_declaration_c etisserant@0: * as would be expected! etisserant@0: */ etisserant@0: /* string_type_name ':' elementary_string_type_name string_type_declaration_size string_type_declaration_init */ etisserant@0: SYM_REF4(string_type_declaration_c, string_type_name, etisserant@0: elementary_string_type_name, etisserant@0: string_type_declaration_size, etisserant@0: string_type_declaration_init) /* may be == NULL! */ etisserant@0: etisserant@0: etisserant@0: /*********************/ etisserant@0: /* B 1.4 - Variables */ etisserant@0: /*********************/ etisserant@0: SYM_REF2(symbolic_variable_c, var_name, unused) etisserant@0: etisserant@0: /********************************************/ etisserant@0: /* B.1.4.1 Directly Represented Variables */ etisserant@0: /********************************************/ etisserant@0: SYM_TOKEN(direct_variable_c) etisserant@0: etisserant@0: /*************************************/ etisserant@0: /* B.1.4.2 Multi-element Variables */ etisserant@0: /*************************************/ etisserant@0: /* subscripted_variable '[' subscript_list ']' */ etisserant@0: SYM_REF2(array_variable_c, subscripted_variable, subscript_list) etisserant@0: etisserant@0: /* subscript_list ',' subscript */ etisserant@0: SYM_LIST(subscript_list_c) etisserant@0: etisserant@0: /* record_variable '.' field_selector */ etisserant@0: /* WARNING: input and/or output variables of function blocks etisserant@1: * may be accessed as fields of a structured variable! etisserant@0: * Code handling a structured_variable_c must take etisserant@0: * this into account! etisserant@0: */ etisserant@0: SYM_REF2(structured_variable_c, record_variable, field_selector) etisserant@0: etisserant@0: /******************************************/ etisserant@0: /* B 1.4.3 - Declaration & Initialisation */ etisserant@0: /******************************************/ etisserant@0: SYM_REF0(constant_option_c) etisserant@0: SYM_REF0(retain_option_c) etisserant@0: SYM_REF0(non_retain_option_c) etisserant@0: etisserant@0: /* option -> the RETAIN/NON_RETAIN/ directive... */ etisserant@0: SYM_REF2(input_declarations_c, option, input_declaration_list) etisserant@0: etisserant@0: /* helper symbol for input_declarations */ etisserant@0: SYM_LIST(input_declaration_list_c) etisserant@0: etisserant@0: /* edge -> The F_EDGE or R_EDGE directive */ etisserant@0: SYM_REF2(edge_declaration_c, edge, var1_list) etisserant@0: etisserant@0: SYM_REF0(raising_edge_option_c) etisserant@0: SYM_REF0(falling_edge_option_c) etisserant@0: etisserant@0: /* spec_init is one of the following... etisserant@0: * simple_spec_init_c * etisserant@0: * subrange_spec_init_c * etisserant@0: * enumerated_spec_init_c * etisserant@0: */ etisserant@0: SYM_REF2(var1_init_decl_c, var1_list, spec_init) etisserant@0: etisserant@0: /* | var1_list ',' variable_name */ etisserant@0: SYM_LIST(var1_list_c) etisserant@0: etisserant@0: /* var1_list ':' array_spec_init */ etisserant@0: SYM_REF2(array_var_init_decl_c, var1_list, array_spec_init) etisserant@0: etisserant@0: /* var1_list ':' initialized_structure */ etisserant@0: SYM_REF2(structured_var_init_decl_c, var1_list, initialized_structure) etisserant@0: etisserant@0: /* fb_name_list ':' function_block_type_name ASSIGN structure_initialization */ etisserant@0: /* structure_initialization -> may be NULL ! */ etisserant@0: SYM_REF4(fb_name_decl_c, fb_name_list, function_block_type_name, structure_initialization, unused) etisserant@0: etisserant@0: /* fb_name_list ',' fb_name */ etisserant@0: SYM_LIST(fb_name_list_c) etisserant@0: etisserant@0: /* VAR_OUTPUT [RETAIN | NON_RETAIN] var_init_decl_list END_VAR */ etisserant@0: /* option -> may be NULL ! */ etisserant@0: SYM_REF2(output_declarations_c, option, var_init_decl_list) etisserant@0: etisserant@0: /* VAR_IN_OUT var_declaration_list END_VAR */ etisserant@0: SYM_REF2(input_output_declarations_c, var_declaration_list, unused) etisserant@0: etisserant@0: /* helper symbol for input_output_declarations */ etisserant@0: /* var_declaration_list var_declaration ';' */ etisserant@0: SYM_LIST(var_declaration_list_c) etisserant@0: etisserant@0: /* var1_list ':' array_specification */ etisserant@0: SYM_REF2(array_var_declaration_c, var1_list, array_specification) etisserant@0: etisserant@0: /* var1_list ':' structure_type_name */ etisserant@0: SYM_REF2(structured_var_declaration_c, var1_list, structure_type_name) etisserant@0: etisserant@0: /* VAR [CONSTANT] var_init_decl_list END_VAR */ etisserant@0: /* option -> may be NULL ! */ etisserant@0: SYM_REF2(var_declarations_c, option, var_init_decl_list) etisserant@0: etisserant@0: /* VAR RETAIN var_init_decl_list END_VAR */ etisserant@0: SYM_REF2(retentive_var_declarations_c, var_init_decl_list, unused) etisserant@0: etisserant@0: /* VAR [CONSTANT|RETAIN|NON_RETAIN] located_var_decl_list END_VAR */ etisserant@0: /* option -> may be NULL ! */ etisserant@0: SYM_REF2(located_var_declarations_c, option, located_var_decl_list) etisserant@0: etisserant@0: /* helper symbol for located_var_declarations */ etisserant@0: /* located_var_decl_list located_var_decl ';' */ etisserant@0: SYM_LIST(located_var_decl_list_c) etisserant@0: etisserant@0: /* [variable_name] location ':' located_var_spec_init */ etisserant@0: /* variable_name -> may be NULL ! */ etisserant@0: SYM_REF4(located_var_decl_c, variable_name, location, located_var_spec_init, unused) etisserant@0: etisserant@0: /*| VAR_EXTERNAL [CONSTANT] external_declaration_list END_VAR */ etisserant@0: /* option -> may be NULL ! */ etisserant@0: SYM_REF2(external_var_declarations_c, option, external_declaration_list) etisserant@0: etisserant@0: /* helper symbol for external_var_declarations */ etisserant@0: /*| external_declaration_list external_declaration';' */ etisserant@0: SYM_LIST(external_declaration_list_c) etisserant@0: etisserant@0: /* global_var_name ':' (simple_specification|subrange_specification|enumerated_specification|array_specification|prev_declared_structure_type_name|function_block_type_name */ etisserant@0: SYM_REF2(external_declaration_c, global_var_name, specification) etisserant@0: etisserant@0: /*| VAR_GLOBAL [CONSTANT|RETAIN] global_var_decl_list END_VAR */ etisserant@0: /* option -> may be NULL ! */ etisserant@0: SYM_REF2(global_var_declarations_c, option, global_var_decl_list) etisserant@0: etisserant@0: /* helper symbol for global_var_declarations */ etisserant@0: /*| global_var_decl_list global_var_decl ';' */ etisserant@0: SYM_LIST(global_var_decl_list_c) etisserant@0: etisserant@0: /*| global_var_spec ':' [located_var_spec_init|function_block_type_name] */ etisserant@0: /* type_specification ->may be NULL ! */ etisserant@0: SYM_REF2(global_var_decl_c, global_var_spec, type_specification) etisserant@0: etisserant@0: /*| global_var_name location */ etisserant@0: SYM_REF2(global_var_spec_c, global_var_name, location) etisserant@0: etisserant@0: /* AT direct_variable */ etisserant@0: SYM_REF2(location_c, direct_variable, unused) etisserant@0: etisserant@0: /*| global_var_list ',' global_var_name */ etisserant@0: SYM_LIST(global_var_list_c) etisserant@0: etisserant@0: /* var1_list ':' single_byte_string_spec */ etisserant@0: SYM_REF2(single_byte_string_var_declaration_c, var1_list, single_byte_string_spec) etisserant@0: etisserant@0: /* STRING ['[' integer ']'] [ASSIGN single_byte_character_string] */ etisserant@0: /* integer ->may be NULL ! */ etisserant@0: /* single_byte_character_string ->may be NULL ! */ etisserant@0: SYM_REF2(single_byte_string_spec_c, integer, single_byte_character_string) etisserant@0: etisserant@0: /* var1_list ':' double_byte_string_spec */ etisserant@0: SYM_REF2(double_byte_string_var_declaration_c, var1_list, double_byte_string_spec) etisserant@0: etisserant@0: /* WSTRING ['[' integer ']'] [ASSIGN double_byte_character_string] */ etisserant@0: /* integer ->may be NULL ! */ etisserant@0: /* double_byte_character_string ->may be NULL ! */ etisserant@0: SYM_REF2(double_byte_string_spec_c, integer, double_byte_character_string) etisserant@0: etisserant@0: /*| VAR [RETAIN|NON_RETAIN] incompl_located_var_decl_list END_VAR */ etisserant@0: /* option ->may be NULL ! */ etisserant@0: SYM_REF2(incompl_located_var_declarations_c, option, incompl_located_var_decl_list) etisserant@0: etisserant@0: /* helper symbol for incompl_located_var_declarations */ etisserant@0: /*| incompl_located_var_decl_list incompl_located_var_decl ';' */ etisserant@0: SYM_LIST(incompl_located_var_decl_list_c) etisserant@0: etisserant@0: /* variable_name incompl_location ':' var_spec */ etisserant@0: SYM_REF4(incompl_located_var_decl_c, variable_name, incompl_location, var_spec, unused) etisserant@0: etisserant@0: /* AT incompl_location_token */ etisserant@0: SYM_TOKEN(incompl_location_c) etisserant@0: etisserant@0: /* intermediate helper symbol for: etisserant@0: * - non_retentive_var_decls etisserant@0: * - output_declarations etisserant@0: */ etisserant@0: SYM_LIST(var_init_decl_list_c) etisserant@0: etisserant@0: etisserant@0: etisserant@0: etisserant@0: /**************************************/ etisserant@0: /* B.1.5 - Program organization units */ etisserant@0: /**************************************/ etisserant@0: /***********************/ etisserant@0: /* B 1.5.1 - Functions */ etisserant@0: /***********************/ etisserant@0: SYM_REF4(function_declaration_c, derived_function_name, type_name, var_declarations_list, function_body) etisserant@0: etisserant@0: /* intermediate helper symbol for etisserant@0: * - function_declaration etisserant@0: * - function_block_declaration etisserant@0: * - program_declaration etisserant@0: */ etisserant@0: SYM_LIST(var_declarations_list_c) etisserant@0: etisserant@0: /* option -> storage method, CONSTANT or */ etisserant@0: SYM_REF2(function_var_decls_c, option, decl_list) etisserant@0: etisserant@0: /* intermediate helper symbol for function_var_decls */ etisserant@0: SYM_LIST(var2_init_decl_list_c) etisserant@0: etisserant@0: etisserant@0: /*****************************/ etisserant@0: /* B 1.5.2 - Function Blocks */ etisserant@0: /*****************************/ etisserant@0: /* FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations function_block_body END_FUNCTION_BLOCK */ etisserant@0: SYM_REF4(function_block_declaration_c, fblock_name, var_declarations, fblock_body, unused) etisserant@0: etisserant@0: /* intermediate helper symbol for function_declaration */ etisserant@0: /* { io_var_declarations | other_var_declarations } */ etisserant@0: /* etisserant@0: * NOTE: we re-use the var_declarations_list_c etisserant@0: */ etisserant@0: etisserant@0: /* VAR_TEMP temp_var_decl_list END_VAR */ etisserant@0: SYM_REF2(temp_var_decls_c, var_decl_list, unused) etisserant@0: etisserant@0: /* intermediate helper symbol for temp_var_decls */ etisserant@0: SYM_LIST(temp_var_decls_list_c) etisserant@0: etisserant@0: /* VAR NON_RETAIN var_init_decl_list END_VAR */ etisserant@0: SYM_REF2(non_retentive_var_decls_c, var_decl_list, unused) etisserant@0: etisserant@0: etisserant@0: /**********************/ etisserant@0: /* B 1.5.3 - Programs */ etisserant@0: /**********************/ etisserant@0: /* PROGRAM program_type_name program_var_declarations_list function_block_body END_PROGRAM */ etisserant@0: SYM_REF4(program_declaration_c, program_type_name, var_declarations, function_block_body, unused) etisserant@0: etisserant@0: /* intermediate helper symbol for program_declaration_c */ etisserant@0: /* { io_var_declarations | other_var_declarations } */ etisserant@0: /* etisserant@0: * NOTE: we re-use the var_declarations_list_c etisserant@0: */ etisserant@0: etisserant@0: etisserant@0: etisserant@0: /*********************************************/ etisserant@0: /* B.1.6 Sequential function chart elements */ etisserant@0: /*********************************************/ etisserant@0: etisserant@1: SYM_LIST(sequential_function_chart_c) etisserant@1: etisserant@1: SYM_LIST(sfc_network_c) etisserant@1: etisserant@1: SYM_REF2(initial_step_c, step_name, action_association_list) etisserant@1: etisserant@1: SYM_LIST(action_association_list_c) etisserant@1: SYM_REF2(step_c, step_name, action_association_list) etisserant@1: SYM_REF4(action_association_c, action_name, action_qualifier, indicator_name_list, unused) etisserant@1: etisserant@1: SYM_TOKEN(qualifier_c) etisserant@1: SYM_TOKEN(timed_qualifier_c) etisserant@1: etisserant@1: SYM_LIST(indicator_name_list_c) etisserant@1: etisserant@1: SYM_REF2(action_qualifier_c, action_qualifier, action_time) etisserant@1: lbessard@3: SYM_REF6(transition_c, transition_name, integer, from_steps, to_steps, transition_condition_il, transition_condition_st) etisserant@1: etisserant@1: SYM_REF2(steps_c, step_name, step_name_list) etisserant@1: etisserant@1: SYM_LIST(step_name_list_c) etisserant@1: etisserant@1: SYM_REF2(transition_condition_c, simple_instr_list, expression) etisserant@1: etisserant@1: SYM_REF2(action_c, action_name, function_block_body) etisserant@0: etisserant@0: /********************************/ etisserant@0: /* B 1.7 Configuration elements */ etisserant@0: /********************************/ etisserant@0: etisserant@0: /* etisserant@0: CONFIGURATION configuration_name etisserant@0: optional_global_var_declarations etisserant@0: (resource_declaration_list | single_resource_declaration) etisserant@0: optional_access_declarations etisserant@0: optional_instance_specific_initializations etisserant@0: END_CONFIGURATION etisserant@0: */ etisserant@0: SYM_REF6(configuration_declaration_c, configuration_name, global_var_declarations, resource_declarations, access_declarations, instance_specific_initializations, unused) etisserant@0: etisserant@0: /* helper symbol for configuration_declaration */ etisserant@0: SYM_LIST(resource_declaration_list_c) etisserant@0: etisserant@0: /* etisserant@0: RESOURCE resource_name ON resource_type_name etisserant@0: optional_global_var_declarations etisserant@0: single_resource_declaration etisserant@0: END_RESOURCE etisserant@0: */ etisserant@0: SYM_REF4(resource_declaration_c, resource_name, resource_type_name, global_var_declarations, resource_declaration) etisserant@0: etisserant@0: /* task_configuration_list program_configuration_list */ etisserant@0: SYM_REF2(single_resource_declaration_c, task_configuration_list, program_configuration_list) etisserant@0: etisserant@0: /* helper symbol for single_resource_declaration */ etisserant@0: SYM_LIST(task_configuration_list_c) etisserant@0: etisserant@0: /* helper symbol for single_resource_declaration */ etisserant@0: SYM_LIST(program_configuration_list_c) etisserant@0: etisserant@0: /* helper symbol for etisserant@0: * - access_path etisserant@0: * - instance_specific_init etisserant@0: */ etisserant@0: SYM_LIST(any_fb_name_list_c) etisserant@0: etisserant@0: /* [resource_name '.'] global_var_name ['.' structure_element_name] */ etisserant@0: SYM_REF4(global_var_reference_c, resource_name, global_var_name, structure_element_name, unused) etisserant@0: etisserant@0: /* prev_declared_program_name '.' symbolic_variable */ etisserant@0: SYM_REF2(program_output_reference_c, program_name, symbolic_variable) etisserant@0: etisserant@0: /* TASK task_name task_initialization */ etisserant@0: SYM_REF2(task_configuration_c, task_name, task_initialization) etisserant@0: etisserant@0: /* '(' [SINGLE ASSIGN data_source ','] [INTERVAL ASSIGN data_source ','] PRIORITY ASSIGN integer ')' */ etisserant@0: SYM_REF4(task_initialization_c, single_data_source, interval_data_source, priority_data_source, unused) etisserant@0: etisserant@0: /* PROGRAM [RETAIN | NON_RETAIN] program_name [WITH task_name] ':' program_type_name ['(' prog_conf_elements ')'] */ etisserant@0: SYM_REF6(program_configuration_c, retain_option, program_name, task_name, program_type_name, prog_conf_elements, unused) etisserant@0: etisserant@0: /* prog_conf_elements ',' prog_conf_element */ etisserant@0: SYM_LIST(prog_conf_elements_c) etisserant@0: etisserant@0: /* fb_name WITH task_name */ etisserant@0: SYM_REF2(fb_task_c, fb_name, task_name) etisserant@0: etisserant@0: /* any_symbolic_variable ASSIGN prog_data_source */ etisserant@0: SYM_REF2(prog_cnxn_assign_c, symbolic_variable, prog_data_source) etisserant@0: etisserant@0: /* any_symbolic_variable SENDTO data_sink */ etisserant@0: SYM_REF2(prog_cnxn_sendto_c, symbolic_variable, prog_data_source) etisserant@0: etisserant@0: /* VAR_CONFIG instance_specific_init_list END_VAR */ etisserant@0: SYM_REF2(instance_specific_initializations_c, instance_specific_init_list, unused) etisserant@0: etisserant@0: /* helper symbol for instance_specific_initializations */ etisserant@0: SYM_LIST(instance_specific_init_list_c) etisserant@0: etisserant@0: /* resource_name '.' program_name '.' {fb_name '.'} etisserant@0: ((variable_name [location] ':' located_var_spec_init) | (fb_name ':' fb_initialization)) etisserant@0: */ etisserant@0: SYM_REF6(instance_specific_init_c, resource_name, program_name, any_fb_name_list, variable_name, location, initialization) etisserant@0: etisserant@0: /* helper symbol for instance_specific_init */ etisserant@0: /* function_block_type_name ':=' structure_initialization */ etisserant@0: SYM_REF2(fb_initialization_c, function_block_type_name, structure_initialization) etisserant@0: etisserant@0: etisserant@0: etisserant@0: /****************************************/ etisserant@0: /* B.2 - Language IL (Instruction List) */ etisserant@0: /****************************************/ etisserant@0: /***********************************/ etisserant@0: /* B 2.1 Instructions and Operands */ etisserant@0: /***********************************/ etisserant@0: /*| instruction_list il_instruction */ etisserant@0: SYM_LIST(instruction_list_c) etisserant@0: etisserant@0: /* | label ':' [il_incomplete_instruction] eol_list */ etisserant@0: SYM_REF2(il_instruction_c, label, il_instruction) etisserant@0: etisserant@0: etisserant@0: /* | il_simple_operator [il_operand] */ etisserant@0: SYM_REF2(il_simple_operation_c, il_simple_operator, il_operand) etisserant@0: etisserant@0: /* | function_name [il_operand_list] */ etisserant@0: SYM_REF2(il_function_call_c, function_name, il_operand_list) etisserant@0: etisserant@0: etisserant@0: /* | il_expr_operator '(' [il_operand] eol_list [simple_instr_list] ')' */ etisserant@0: SYM_REF4(il_expression_c, il_expr_operator, il_operand, simple_instr_list, unused) etisserant@0: etisserant@0: /* il_jump_operator label */ etisserant@0: SYM_REF2(il_jump_operation_c, il_jump_operator, label) etisserant@0: etisserant@0: /* il_call_operator prev_declared_fb_name etisserant@0: * | il_call_operator prev_declared_fb_name '(' ')' etisserant@0: * | il_call_operator prev_declared_fb_name '(' eol_list ')' etisserant@0: * | il_call_operator prev_declared_fb_name '(' il_operand_list ')' etisserant@0: * | il_call_operator prev_declared_fb_name '(' eol_list il_param_list ')' etisserant@0: */ etisserant@0: SYM_REF4(il_fb_call_c, il_call_operator, fb_name, il_operand_list, il_param_list) etisserant@0: etisserant@0: etisserant@0: /* | function_name '(' eol_list [il_param_list] ')' */ etisserant@0: SYM_REF2(il_formal_funct_call_c, function_name, il_param_list) etisserant@0: etisserant@0: /* | il_operand_list ',' il_operand */ etisserant@0: SYM_LIST(il_operand_list_c) etisserant@0: etisserant@0: /* | simple_instr_list il_simple_instruction */ etisserant@0: SYM_LIST(simple_instr_list_c) etisserant@0: etisserant@0: /* | il_initial_param_list il_param_instruction */ etisserant@0: SYM_LIST(il_param_list_c) etisserant@0: etisserant@0: /* il_assign_operator il_operand etisserant@0: * | il_assign_operator '(' eol_list simple_instr_list ')' etisserant@0: */ etisserant@0: SYM_REF4(il_param_assignment_c, il_assign_operator, il_operand, simple_instr_list, unused) etisserant@0: etisserant@0: /* il_assign_out_operator variable */ etisserant@0: SYM_REF2(il_param_out_assignment_c, il_assign_out_operator, variable) etisserant@0: etisserant@0: etisserant@0: etisserant@0: /*******************/ etisserant@0: /* B 2.2 Operators */ etisserant@0: /*******************/ etisserant@0: SYM_REF0(LD_operator_c) etisserant@0: SYM_REF0(LDN_operator_c) etisserant@0: SYM_REF0(ST_operator_c) etisserant@0: SYM_REF0(STN_operator_c) etisserant@0: SYM_REF0(NOT_operator_c) etisserant@0: SYM_REF0(S_operator_c) etisserant@0: SYM_REF0(R_operator_c) etisserant@0: SYM_REF0(S1_operator_c) etisserant@0: SYM_REF0(R1_operator_c) etisserant@0: SYM_REF0(CLK_operator_c) etisserant@0: SYM_REF0(CU_operator_c) etisserant@0: SYM_REF0(CD_operator_c) etisserant@0: SYM_REF0(PV_operator_c) etisserant@0: SYM_REF0(IN_operator_c) etisserant@0: SYM_REF0(PT_operator_c) etisserant@0: SYM_REF0(AND_operator_c) etisserant@0: SYM_REF0(OR_operator_c) etisserant@0: SYM_REF0(XOR_operator_c) etisserant@0: SYM_REF0(ANDN_operator_c) etisserant@0: SYM_REF0(ORN_operator_c) etisserant@0: SYM_REF0(XORN_operator_c) etisserant@0: SYM_REF0(ADD_operator_c) etisserant@0: SYM_REF0(SUB_operator_c) etisserant@0: SYM_REF0(MUL_operator_c) etisserant@0: SYM_REF0(DIV_operator_c) etisserant@0: SYM_REF0(MOD_operator_c) etisserant@0: SYM_REF0(GT_operator_c) etisserant@0: SYM_REF0(GE_operator_c) etisserant@0: SYM_REF0(EQ_operator_c) etisserant@0: SYM_REF0(LT_operator_c) etisserant@0: SYM_REF0(LE_operator_c) etisserant@0: SYM_REF0(NE_operator_c) etisserant@0: SYM_REF0(CAL_operator_c) etisserant@0: SYM_REF0(CALC_operator_c) etisserant@0: SYM_REF0(CALCN_operator_c) etisserant@0: SYM_REF0(RET_operator_c) etisserant@0: SYM_REF0(RETC_operator_c) etisserant@0: SYM_REF0(RETCN_operator_c) etisserant@0: SYM_REF0(JMP_operator_c) etisserant@0: SYM_REF0(JMPC_operator_c) etisserant@0: SYM_REF0(JMPCN_operator_c) etisserant@0: etisserant@0: /*| [NOT] any_identifier SENDTO */ etisserant@0: SYM_REF2(il_assign_out_operator_c, option, variable_name) etisserant@0: etisserant@0: etisserant@0: etisserant@0: /***************************************/ etisserant@0: /* B.3 - Language ST (Structured Text) */ etisserant@0: /***************************************/ etisserant@0: /***********************/ etisserant@0: /* B 3.1 - Expressions */ etisserant@0: /***********************/ etisserant@0: SYM_REF2(or_expression_c, l_exp, r_exp) etisserant@0: SYM_REF2(xor_expression_c, l_exp, r_exp) etisserant@0: SYM_REF2(and_expression_c, l_exp, r_exp) etisserant@0: SYM_REF2(equ_expression_c, l_exp, r_exp) etisserant@0: SYM_REF2(notequ_expression_c, l_exp, r_exp) etisserant@0: SYM_REF2(lt_expression_c, l_exp, r_exp) etisserant@0: SYM_REF2(gt_expression_c, l_exp, r_exp) etisserant@0: SYM_REF2(le_expression_c, l_exp, r_exp) etisserant@0: SYM_REF2(ge_expression_c, l_exp, r_exp) etisserant@0: SYM_REF2(add_expression_c, l_exp, r_exp) etisserant@0: SYM_REF2(sub_expression_c, l_exp, r_exp) etisserant@0: SYM_REF2(mul_expression_c, l_exp, r_exp) etisserant@0: SYM_REF2(div_expression_c, l_exp, r_exp) etisserant@0: SYM_REF2(mod_expression_c, l_exp, r_exp) etisserant@0: SYM_REF2(power_expression_c, l_exp, r_exp) etisserant@0: SYM_REF2(neg_expression_c, exp, unused) etisserant@0: SYM_REF2(not_expression_c, exp, unused) etisserant@0: etisserant@0: SYM_REF2(function_invocation_c, function_name, parameter_assignment_list) etisserant@0: etisserant@0: etisserant@0: /********************/ etisserant@0: /* B 3.2 Statements */ etisserant@0: /********************/ etisserant@0: SYM_LIST(statement_list_c) etisserant@0: etisserant@0: etisserant@0: /*********************************/ etisserant@0: /* B 3.2.1 Assignment Statements */ etisserant@0: /*********************************/ etisserant@0: SYM_REF2(assignment_statement_c, l_exp, r_exp) etisserant@0: etisserant@0: etisserant@0: /*****************************************/ etisserant@0: /* B 3.2.2 Subprogram Control Statements */ etisserant@0: /*****************************************/ etisserant@0: /* RETURN */ etisserant@0: SYM_REF0(return_statement_c) etisserant@0: etisserant@0: /* fb_name '(' [param_assignment_list] ')' */ etisserant@0: /* param_assignment_list -> may be NULL ! */ etisserant@0: SYM_REF2(fb_invocation_c, fb_name, param_assignment_list) etisserant@0: etisserant@0: /* helper symbol for fb_invocation */ etisserant@0: /* param_assignment_list ',' param_assignment */ etisserant@0: SYM_LIST(param_assignment_list_c) etisserant@0: etisserant@0: /* variable_name ASSIGN expression */ etisserant@0: SYM_REF2(input_variable_param_assignment_c, variable_name, expression) etisserant@0: etisserant@0: /* [NOT] variable_name '=>' variable */ etisserant@0: SYM_REF4(output_variable_param_assignment_c, not_param, variable_name, variable, unused) etisserant@0: etisserant@0: /* helper CLASS for output_variable_param_assignment */ etisserant@0: SYM_REF0(not_paramassign_c) etisserant@0: etisserant@0: etisserant@0: /********************************/ etisserant@0: /* B 3.2.3 Selection Statements */ etisserant@0: /********************************/ etisserant@0: /* IF expression THEN statement_list elseif_statement_list ELSE statement_list END_IF */ etisserant@0: SYM_REF4(if_statement_c, expression, statement_list, elseif_statement_list, else_statement_list) etisserant@0: etisserant@0: /* helper symbol for if_statement */ etisserant@0: SYM_LIST(elseif_statement_list_c) etisserant@0: etisserant@0: /* helper symbol for elseif_statement_list */ etisserant@0: /* ELSIF expression THEN statement_list */ etisserant@0: SYM_REF2(elseif_statement_c, expression, statement_list) etisserant@0: etisserant@0: /* CASE expression OF case_element_list ELSE statement_list END_CASE */ etisserant@0: SYM_REF4(case_statement_c, expression, case_element_list, statement_list, unused) etisserant@0: etisserant@0: /* helper symbol for case_statement */ etisserant@0: SYM_LIST(case_element_list_c) etisserant@0: etisserant@0: /* case_list ':' statement_list */ etisserant@0: SYM_REF2(case_element_c, case_list, statement_list) etisserant@0: etisserant@0: SYM_LIST(case_list_c) etisserant@0: etisserant@0: etisserant@0: /********************************/ etisserant@0: /* B 3.2.4 Iteration Statements */ etisserant@0: /********************************/ etisserant@0: /* FOR control_variable ASSIGN expression TO expression [BY expression] DO statement_list END_FOR */ etisserant@0: SYM_REF6(for_statement_c, control_variable, beg_expression, end_expression, by_expression, statement_list, unused) etisserant@0: etisserant@0: /* WHILE expression DO statement_list END_WHILE */ etisserant@0: SYM_REF2(while_statement_c, expression, statement_list) etisserant@0: etisserant@0: /* REPEAT statement_list UNTIL expression END_REPEAT */ etisserant@0: SYM_REF2(repeat_statement_c, statement_list, expression) etisserant@0: etisserant@0: /* EXIT */ etisserant@0: SYM_REF0(exit_statement_c) etisserant@0: etisserant@0: