The code in this directory is "alpha quality" at best. USE ENTIRELY AT YOUR OWN RISK!!! 08 SEP 2000 Test program now successfully parses the weigh_st.txt sample program. Now to add the routines to generate the code. =========================================================================== This directory is a copy of the flex/bison translator for: IEC 61131-3 Instruction List (IL) IEC 61131-3 Structured Text (ST) The translator is based on the contents of Annex B of the 1998 draft of the 2nd Edition of the IEC 61131-3. The contents of the flex/bison is as exact as possible representation of Annex B with the following exceptions: Annex B.0 library_element_name NOT IMPLEMENTED library_element_declaration Start token for bison Annex B.1.1 Letters, digits and identifiers Implemenented in flex script Annex B.1.2 Constants Implemented in bison script NOTE 1: Problems exist with signed_integer semantics. An alternative "constant" token developed for use with "expression" which only includes integer, the unary '-' for the integer constant are handled as part of normal expression rules. Annex B.1.2.1 Numeric literals numeric_literal bison integer_literal bison signed_integer bison integer flex binary_integer flex bit flex octal_integer flex hex_integer flex real_integer flex expontent flex Annex B.1.2.2 Character strings Implemenented in flex script Annex B.1.2.3 Implemented in bison script Annex B.1.2.3.1 Duration Implemenented in flex script Annex B.1.2.3.2 Time of day and date Implemenented in flex script Annex B.1.3 Data types Implemented in bison script Annex B.1.3.1 Elementary data types Implemented in bison script Annex B.1.3.2 Generic data types Implemented in bison script Annex B.1.3.3 Derived data types Implemented in bison script NOTE 2: Endless loop broken, was: array_initialisation -> array_inital_element array_initial_element -> array_inital_elements array_initial_elements -> array_initialisation Correction was to remove: array_initialisation -> array_inital_element NOTE 3: Redundant data paths removed, was: constant -> structure_element_initialisation enumerated_value -> structure_element_initialisation structure_initialisation-> structure_element_initialisation constant -> array_initial_element enumerated_value -> array_initial_element structure_initialisation-> array_initial_element array_initial_element -> array_inital_elements array_initial_elements -> array_initialisation array_initialisation -> structure_element_initialisation There existed two different paths for constant, enumerated_value & structure_initialisation to convert to structure_element_initialisation The problem was corrected by removing the direct path and relying on the rules via array_initial_element. eg: constant -> array_initial_element enumerated_value -> array_initial_element structure_initialisation-> array_initial_element array_initial_element -> array_inital_elements array_initial_elements -> array_initialisation array_initialisation -> structure_element_initialisation NOTE 5: String variable declarations Problem exists as the standard defines that only one string variable can be declared at a time. This is diferent from the specification for other datatypes where multiple variables can be declared in the same declaration. eg: A : BOOL ; (* Legal *) A, B : BOOL ; (* Legal *) X : STRING[40]; (* Legal *) X, Y : STRING[40]; (* Illegal *) Bison does not appear to handle this case properly, hence the rule for string declaration has been modified to handle multiple declaration of variables. We will need to raise a warning if this "feature" is utilised. Annex B.1.4 Variables Implemented in bison script Annex B.1.4.1 Directly represented variables Implemenented in flex script Annex B.1.4.2 Multi-element variables Implemented in bison script Annex B.1.4.3 Declaration and initialisation Implemented in bison script NOTE 4: Implemented two stage type/variable identification. When a variable name is first identified by the parser system (flex/bison) it is reported to bison as an "identifier", subsequent references within the same module will be reported as "####_type_name". This eliminates a large number of reduce/reduce conflicts which arise. The following are some of the changes made: identifier {',' identifier -> var1_list replace "global_var_list" with "var1_list" removed the following rules from B.1.3.3 (handled by flex and friends) identifier -> simple_type_name identifier -> subrange_type_name identifier -> enumerated_type_name identifier -> array_type_name identifier -> structure_type_name Annex B.1.5.1 Functions Implemented in bison script Annex B.1.5.2 Function Blocks Implemented in bison script Annex B.1.5.3 Programs Implemented in bison script Annex B.1.6 Sequential function chart elements Excluded from flex/bison script due to graphical nature Annex B.1.7 Configuration elements Implemented in bison script Annex B.2.1 IL - Instructions and Operands Implemented in bison script NOTE 5: EOL (End Of Line) token is not generated by flex script (perhaps it should?), hence token removed from "instruction" generation rules. Annex B.2.2 IL - Operators Implemented in bison script Annex B.3.1 ST - Expressions Implemented in bison script Annex B.3.2 ST - Statements Implemented in bison script Annex B.3.2.1 ST - Statements (assignment) Implemented in bison script Annex B.3.2.1 ST - Statements (subprogram control) Implemented in bison script Annex B.3.2.1 ST - Statements (selection) Implemented in bison script Annex B.3.2.4 ST - Statements (iteration) Implemented in bison script =========================================================================== All routines where possible are to be performed externally from the bison script file (iec.y) to allow possible replacement for other output languages. David Campbell