readme
author mjsousa
Sat, 09 Aug 2014 09:20:03 +0100
changeset 923 0ad7843d3790
parent 457 67d8b07bac22
permissions -rwxr-xr-x
Add support for non standard REF_TO ANY (equivalent to void *)
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     1
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     2
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     3
265
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 67
diff changeset
     4
  MATIEC - IEC 61131-3 compiler
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     5
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     6
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     7
  The following compiler has been based on the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     8
  FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     9
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    10
444
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    11
  Copyright (C) 2003-2012  Mario de Sousa (msousa@fe.up.pt)
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    12
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    13
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    14
****************************************************************
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    15
****************************************************************
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    16
****************************************************************
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    17
*********                                              *********
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    18
*********                                              *********
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    19
*********         O V E R A L L    G O A L S           *********
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    20
*********                                              *********
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    21
*********                                              *********
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    22
****************************************************************
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    23
****************************************************************
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    24
****************************************************************
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    25
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    26
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    27
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    28
 This project has the goal of producing an open source compiler for the programming languages defined
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    29
in the IEC 61131-3 standard. These programming languages are mostly used in the industrial automation 
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    30
domain, to program PLCs (Programmable Logic Controllers).
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    31
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    32
 This standard defines 5 programming languages:
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    33
     - IL : Instructtion List
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    34
            A textual programming language, somewhat similar to assembly.
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    35
     - ST : Structured Text
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    36
            A textual programming language, somewhat similar to Pascal.
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    37
     - FBD: Function Block Diagram
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    38
            A graphical programming language, somewhat similar to an electrical circuit diagram based on small 
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    39
             scale integration ICs (Integrated Circuits) (counters, AND/OR/XOR/... logic gates, timers, ...).
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    40
     - LD : Ladder Diagram
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    41
            A graphical programming language, somewhat similar to an electrical circuit diagram based on 
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    42
             relays (used for basic cabled logic controllers).
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    43
     - SFC: Sequential Function Chart
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    44
            A graphical programming language, that defines a state machine, based largely on Grafcet.
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    45
            (may also be expressed in textual format).
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    46
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    47
 Of the above 5 languages, the standard defines textual representations for IL, ST and SFC. 
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    48
It is these 3 languages that we target, and we currently support all three, as long as they are
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    49
expressed in the textual format as defined in the standard.
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    50
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    51
 Currently the matiec project generates two compilers (more correctly, code translaters, but we like
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    52
to call them compilers :-O ): iec2c, and iec2iec
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    53
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    54
 Both compilers accept the same input: a text file with ST, IL and/or SFC code.
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    55
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    56
 The iec2c compiler generates ANSI C code which is equivalent to the IEC 61131-3 code expressed in the input file.
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    57
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    58
 The iec2iec compiler generates IEC61131-3 code which is equivalent to the IEC 61131-3 code expressed in the input file.
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    59
This last compiler should generate and output file which should be almost identical to the input file (some formating 
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    60
may change, as well as the case of letters, etc.). This 'compiler' is mostly used by the matiec project contributors
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    61
to help debug the lexical and syntax portions of the compilers.
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    62
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    63
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    64
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    65
 To compile/build these compilers, just
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    66
$./configure; make
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    67
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    68
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    69
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    70
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    71
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    72
****************************************************************
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    73
****************************************************************
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    74
****************************************************************
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    75
*********                                              *********
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    76
*********                                              *********
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    77
*********   O V E R A L L    A R C H I T E C T U R E   *********
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    78
*********                                              *********
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    79
*********                                              *********
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    80
****************************************************************
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    81
****************************************************************
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    82
****************************************************************
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    83
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    84
 The compiler works in 4(+1) stages:
444
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    85
 ==================================
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    86
 Stage 1    - Lexical analyser       - implemented with flex (stage1_2/iec_flex.ll)
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    87
 Stage 2    - Syntax parser          - implemented with bison (stage1_2/iec_bison.yy)
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    88
 Stage pre3 - Populate symbol tables - Symbol tables that will ease searching for symbols in the abstract symbol tree.
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    89
 Stage 3    - Semantics analyser     - currently does type checking only
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    90
 Stage 4    - Code generator         - generates ANSI C code
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    91
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    92
 Stage 5    - Binary code generator - gcc, javac, etc... (Not integrated into matiec compiler. Must be called explicitly by the user.)
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    93
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    94
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    95
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    96
 Data structures passed between stages, in global variables:
444
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    97
 ==========================================================
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    98
   1->2   : tokens (int), and token values (char *) (defined in stage1_2/stage1_2_priv.hh)
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
    99
   2->1   : symbol tables (implemented in util/symtable.[hh|cc], and defined in stage1_2/stage1_2_priv.hh)
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   100
   2->3   : abstract syntax tree (tree of C++ objects, whose classes are defined in absyntax/absyntax.hh)
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   101
pre3->3,4 : global symbol tables (defined in util/[d]symtable.[hh|cc] and declared in absyntax_utils/absyntax_utils.hh)
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   102
   3->4   : abstract syntax tree (same as 2->3), but now annotated (i.e. some extra data inserted into the absyntax tree)
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   103
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   104
   4->5   : file with program in c, java, etc...
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   105
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   106
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   107
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   108
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   109
 The compiler works in several passes:
444
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   110
 ====================================
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   111
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   112
Stage 1 and Stage 2
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   113
-------------------
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   114
  Executed in one single pass. This pass will:
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   115
  - Do lexical analysis
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   116
  - Do syntax analysis
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   117
  - Execute the absyntax_utils/add_en_eno_param_decl_c visitor class
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   118
    This class will add the EN and ENO parameter declarations to all
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   119
    functions that do not have them already explicitly declared by the user.
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   120
    This will let us handle these parameters in the remaining compiler just as if
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   121
    they were standard input/output parameters.
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   122
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   123
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   124
Stage Pre3
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   125
----------
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   126
  Executed in one single pass. This pass will populate the following symbol tables:
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   127
   - function_symtable;            /* A symbol table with all globally declared functions POUs. */
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   128
   - function_block_type_symtable; /* A symbol table with all globally declared functions block POUs. */
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   129
   - program_type_symtable;        /* A symbol table with all globally declared program POUs. */
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   130
   - type_symtable;                /* A symbol table with all user declared (non elementary) datat type definitions. */
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   131
   - enumerated_value_symtable;    /* A symbol table with all identifiers (values) declared for enumerated types. */
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   132
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   133
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   134
Stage 3
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   135
-------
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   136
  Executes two algorithms (flow control analysis, and data type analysis) in several passes.
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   137
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   138
  Flow control:
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   139
     Pass 1: Does flow control analysis (for now only of IL code) 
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   140
             Implemented in -> stage3/flow_control_analysis_c
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   141
             This will anotate the abstract syntax tree 
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   142
             (Every object of the class il_instruction_c that is in the abstract syntax tree will have the variable 'prev_il_instruction' correctly filled in.)
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   143
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   144
  Data Type Analysis
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   145
     Pass 1: Analyses the possible data types each expression/literal/IL instruction/etc. may take 
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   146
             Implemented in -> stage3/fill_candidate_datatypes_c
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   147
             This will anotate the abstract syntax tree 
457
67d8b07bac22 Change prev_il_instruction to a vector<>
Mario de Sousa <msousa@fe.up.pt>
parents: 444
diff changeset
   148
             (Every object of in the abstract syntax tree that may have a data type, will have the variable 'candidate_datatypes' correctly filled in.
67d8b07bac22 Change prev_il_instruction to a vector<>
Mario de Sousa <msousa@fe.up.pt>
parents: 444
diff changeset
   149
             Additionally, objects in the abstract syntax tree that represen function invocations will have the variable 
67d8b07bac22 Change prev_il_instruction to a vector<>
Mario de Sousa <msousa@fe.up.pt>
parents: 444
diff changeset
   150
              'candidate_functions' correctly filled in.)
67d8b07bac22 Change prev_il_instruction to a vector<>
Mario de Sousa <msousa@fe.up.pt>
parents: 444
diff changeset
   151
Pass 2: Narrows all the possible data types each expression/literal/IL instruction/etc. may take down to a single data type 
444
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   152
             Implemented in -> stage3/narrow_candidate_datatypes_c
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   153
             This will anotate the abstract syntax tree 
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   154
             (Every object of in the abstract syntax tree that may have a data type, will have the variable 'datatype' correctly filled in.
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   155
              Additionally, objects in the abstract syntax tree that represen function invocations will have the variables 
457
67d8b07bac22 Change prev_il_instruction to a vector<>
Mario de Sousa <msousa@fe.up.pt>
parents: 444
diff changeset
   156
              'called_function_declaration' and 'extensible_param_count' correctly filled in.
444
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   157
              Additionally, objects in the abstract syntax tree that represen function block (FB) invocations will have the variable
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   158
              'called_fb_declaration' correctly filled in.)
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   159
     Pass 2: Prints error messages in the event of the IEC 61131-3 source code being analysed contains semantic data type incompatibility errors.
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   160
             Implemented in -> stage3/print_datatype_errors_c
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   161
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   162
  
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   163
Stage 4
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   164
-------
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   165
  Has 2 possible implementations.
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   166
  
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   167
  iec2c  :  Generates C source code in a single pass (stage4/generate_c).
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   168
  iec2iec:  Generates IEC61131 source code in a single pass (stage4/generate_iec).
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   169
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   170
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   171
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   172
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   173
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   174
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   175
****************************************************************
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   176
****************************************************************
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   177
****************************************************************
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   178
*********                                              *********
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   179
*********                                              *********
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   180
*********               N O T E S                      *********
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   181
*********                                              *********
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   182
*********                                              *********
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   183
****************************************************************
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   184
****************************************************************
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   185
****************************************************************
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   186
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   187
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   188
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   189
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   190
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   191
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   192
 NOTE 1
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   193
 ======
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   194
 Note that stage 2 passes data back to stage 1. This is only
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   195
possible because both stages are executed in the same pass.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   196
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   197
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   198
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   199
 NOTE 2
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   200
 ======
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   201
 It would be nice to get this parser integrated into the gcc
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   202
group of compilers. We would then be able to compile our st/il
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   203
programs directly into executable binaries, for all the processor
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   204
architectures gcc currently supports.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   205
 The gcc compilers are divided into a frontend and backend. The
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   206
data structure between these two stages is called the syntax
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   207
tree. In essence, we would need to create a new frontend that
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   208
would parse the st/il program and build the syntax tree.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   209
Unfortunately the gcc syntax tree is not very well documented,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   210
and doing semantic checking on this tree would probably be a
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   211
nightmare.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   212
 We therefore chose to follow the same route as the gnat (ada 95)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   213
and cobol compilers, i.e. generate our own abstract syntax tree,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   214
do semantic checking on our tree, do whatever optimisation
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   215
we can at this level on our own tree, and only then build
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   216
the gcc syntax tree from our abstract syntax tree.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   217
 All this may still be integrated with the gcc backend to generate
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   218
a new gnu compiler for the st and il programming languages.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   219
Since generating the gcc syntax tree will probably envolve some
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   220
trial and error effort due to the sparseness of documentation,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   221
we chose to start off by coding a C++ code generator for
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   222
our stage 4. We may later implement a gcc syntax tree generator
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   223
as an alternative stage 4 process, and then integrate it with
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   224
the gcc toplevel.c file (command line parsing, etc...).
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   225
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   226
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   227
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   228
****************************************************************
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   229
****************************************************************
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   230
****************************************************************
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   231
*********                                              *********
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   232
*********                                              *********
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   233
*********               S T A G E      1               *********
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   234
*********                                              *********
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   235
*********                                              *********
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   236
****************************************************************
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   237
****************************************************************
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   238
****************************************************************
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   239
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   240
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   241
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   242
Issue 1
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   243
=======
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   244
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   245
 The syntax defines the common_character_representation as:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   246
<any printable character except '$', '"' or "'"> | <escape sequences>
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   247
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   248
 Flex includes the function print_char() that defines
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   249
all printable characters portably (i.e. whatever character
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   250
encoding is currently being used , ASCII, EBCDIC, etc...)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   251
Unfortunately, we cannot generate the definition of
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   252
common_character_representation portably, since flex
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   253
does not allow definition of sets by subtracting
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   254
elements in one set from another set (Note how
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   255
common_character_representation could be defined by
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   256
subtracting '$' '"' and "'" from print_char() ).
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   257
This means we must build up the defintion of
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   258
common_character_representation using only set addition,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   259
which leaves us with the only choice of defining the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   260
characters non-portably...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   261
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   262
 In short, the definition we use for common_character_representation
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   263
only works for ASCII character encoding!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   264
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   265
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   266
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   267
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   268
Issue 2
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   269
=======
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   270
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   271
We extend the IEC 61131-3 standard syntax to allow inclusion of 
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   272
other files. The accepted syntax is:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   273
265
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 67
diff changeset
   274
   {#include "<filename>" }
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 67
diff changeset
   275
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 67
diff changeset
   276
We use a pragma directive for this (allowed by the standard itself),
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 67
diff changeset
   277
 since it is an extension of the standard. In principle, this would 
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 67
diff changeset
   278
be ignored by other standard complient compilers!
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   279
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   280
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   281
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   282
****************************************************************
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   283
****************************************************************
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   284
****************************************************************
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   285
*********                                              *********
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   286
*********                                              *********
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   287
*********               S T A G E      2               *********
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   288
*********                                              *********
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   289
*********                                              *********
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   290
****************************************************************
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   291
****************************************************************
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   292
****************************************************************
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   293
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   294
 Overall Comments
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   295
 ================
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   296
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   297
 
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   298
 Comment 1
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   299
 ---------
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   300
 We have augmented the syntax the specification defines to include
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   301
restrictions defined in the semantics of the languages.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   302
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   303
 This is required because the syntax cannot be parsed by a LALR(1)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   304
parser as it is presented in the specification. Many reduce/reduce
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   305
and shift/reduce conflicts arise. This is mainly because the parser
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   306
cannot discern how to reduce an identifier. Identifiers show up in
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   307
many places in the syntax, and it is not entirely possible to
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   308
figure out if the identifier is a variable_name, enumeration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   309
value, function block name, etc... only from the context in
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   310
which it appears.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   311
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   312
 A more detailed example of why we need symbol tables are
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   313
the type definitions...  In definition of new types
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   314
(section B 1.3.3) the parser needs to figure out the class of
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   315
the new type being defined (enumerated, structure, array, etc...).
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   316
This works well when the base classes are elementary types
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   317
(or structures, enumeration, arrays, etc. thereof). It becomes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   318
confusing to the parser when the new_type is based on a previously
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   319
user defined type.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   320
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   321
TYPE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   322
  new_type_1 : INT := 99;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   323
  new_type_2 : new_type_1 := 100;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   324
END_TYPE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   325
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   326
 When parsing new_type_1, the parser can figure out that the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   327
identifier new_type_1 is a simple_type_name, because it is
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   328
based on a elementary type without structure, arrays, etc...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   329
 While parsing new_type_2, it becomes confused how to reduce
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   330
the new_type_2 identifier, as it is based on the identifier
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   331
new_type_1, of which it does not know the class (remember, at this
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   332
stage new_type_1 is a simple identifier!).
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   333
 We therefore need to keep track of the class of the user
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   334
defined types as they are declared, so that the lexical analyser
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   335
can tell the syntax parser what class the type belongs to. We
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   336
cannot use the abstract syntax tree itself to search for the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   337
declaration of new_type_1 as we only get a handle to the root
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   338
of the tree at the end of the parsing.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   339
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   340
 We therefore maintain an independent and parallel table of symbols,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   341
that is filled as we come across the type delcarations in the code.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   342
Actually, we ended up also needing to store variable names in
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   343
the symbol table. Since variable names come and go out of scope
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   344
depending on what portion of code we are parsing, we sometimes
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   345
need to remove the variable names from the symbol table.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   346
Since the ST and IL languages only have a single level of scope,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   347
I (Mario) found it easier to simply use a second symbol table for
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   348
the variable names that is completely cleared when the parser
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   349
reaches the end of a function (function block or program).
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   350
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   351
What I mean when I say that these languages have a single level
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   352
of scope is that all variables used in a function (function block
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   353
or program) must be declared inside that function (function block
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   354
or program). Even global variables must be re-declared as EXTERN
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   355
before a function may access them! This means that it is easy
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   356
to simply load up the variable name symbol table when we start
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   357
parsing a function (function block or program), and to clear it
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   358
when we reach the end. Checking whether variables declared
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   359
as EXTERN really exist inside a RESOURCE or a CONFIGURATION
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   360
is left to stage 3 (semantic checking) where we can use the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   361
abstract tree itself to search for the variables (NOTE: semantic
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   362
cheching at stage 3 has not yet been implemented, so we may yet
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   363
end up using a symbol table too at that stage!).
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   364
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   365
 Due to the use of the symbol tables, and special identifier
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   366
tokens depending on the type of identifier it had previously
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   367
been declared in the code being parsed, the syntax was slightly
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   368
changed regarding the definition of variable names, derived
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   369
function names, etc... FROM for e.g.:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   370
variable_name: identifier;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   371
TO
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   372
variable_name: variable_name_token;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   373
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   374
 Flex first looks at the symbol tables when it finds an identifier,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   375
and returns the correct token corresponding to the identifier
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   376
type in question. Only if the identifier is not currently stored
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   377
in any symbol table, does flex return a simple identifier_token.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   378
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   379
 This means that the declarations of variables, functions etc...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   380
were changed FROM:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   381
function_declaration: FUNCTION derived_function_name ...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   382
TO
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   383
function_declaration: FUNCTION identifier ...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   384
since the initial definition of derived_function_name had been
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   385
changed FROM
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   386
derived_function_name: identifier;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   387
TO
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   388
derived_function_name: derived_function_name_token;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   389
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   390
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   391
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   392
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   393
 Comment 2
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   394
 ---------
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   395
 Since the ST and IL languages share a lot of common syntax,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   396
I have decided to write a single parser to handle both languages
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   397
simultaneously. This approach has the advantage that the user
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   398
may mix the language used in the same file, as long as each function
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   399
is written in a single lanuage.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   400
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   401
 This approach also assumes that all the IL language operators are
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   402
keywords, which means that it is not possible to define variables
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   403
using names such as "LD", "ST", etc...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   404
Note that the spec does not consider these operators to be keywords,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   405
so it means that they should be available for variable names! On the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   406
other hand, all implementations of the ST and IL languages seems to
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   407
treat them as keywords, so there is not much harm in doing the same.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   408
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   409
 If it ever becomes necessary to allow variables with names of IL 
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   410
operators, either the syntax will have to be augmented, or we can 
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   411
brake up the parser in two: one for ST and another for IL.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   412
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   413
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   414
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   415
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   416
/* B 1.3.3 - Derived data types */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   417
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   418
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   419
Issue 1
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   420
=======
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   421
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   422
According to the spec, the valid construct
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   423
TYPE new_str_type : STRING := "hello!"; END_TYPE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   424
has two possible routes to type_declaration...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   425
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   426
Route 1:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   427
type_declaration: single_element_type_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   428
single_element_type_declaration: simple_type_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   429
simple_type_declaration: identifier ':' simple_spec_init
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   430
simple_spec_init: simple_specification ASSIGN constant
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   431
(shift:  identifier <- 'new_str_type')
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   432
simple_specification: elementary_type_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   433
elementary_type_name: STRING
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   434
(shift: elementary_type_name <- STRING)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   435
(reduce: simple_specification <- elementary_type_name)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   436
(shift: constant <- "hello!")
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   437
(reduce: simple_spec_init: simple_specification ASSIGN constant)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   438
(reduce: ...)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   439
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   440
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   441
Route 2:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   442
type_declaration: string_type_declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   443
string_type_declaration: identifier ':' elementary_string_type_name string_type_declaration_size string_type_declaration_init
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   444
(shift:  identifier <- 'new_str_type')
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   445
elementary_string_type_name: STRING
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   446
(shift: elementary_string_type_name <- STRING)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   447
(shift: string_type_declaration_size <- /* empty */)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   448
string_type_declaration_init: ASSIGN character_string
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   449
(shift: character_string <- "hello!")
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   450
(reduce: string_type_declaration_init <- ASSIGN character_string)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   451
(reduce: string_type_declaration <- identifier ':' elementary_string_type_name string_type_declaration_size string_type_declaration_init )
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   452
(reduce: type_declaration <- string_type_declaration)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   453
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   454
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   455
 At first glance it seems that removing route 1 would make
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   456
the most sense. Unfortunately the construct 'simple_spec_init'
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   457
shows up multiple times in other rules, so changing this construct
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   458
would mean changing all the rules in which it appears.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   459
I (Mario) therefore chose to remove route 2 instead. This means
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   460
that the above declaration gets stored in a
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   461
simple_type_declaration_c, and not in a string_type_declaration_c
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   462
as would be expected!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   463
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   464
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   465
/***********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   466
/* B 1.5.1 - Functions */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   467
/***********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   468
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   469
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   470
Issue 1
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   471
=======
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   472
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   473
 Due to reduce/reduce conflicts between identifiers
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   474
being reduced to either a variable or an enumerator value,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   475
we were forced to keep a symbol table of the names
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   476
of all declared variables. Variables are no longer
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   477
created from simple identifier_token, but from
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   478
variable_name_token.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   479
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   480
 BUT, in functions the function name may be used as
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   481
a variable! In order to be able to parse this correctly,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   482
the token parser (flex) must return a variable_name_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   483
when it comes across the function name, while parsing
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   484
the function itself.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   485
We do this by inserting the function name into the variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   486
symbol table, and having flex return a variable_name_token
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   487
whenever it comes across it.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   488
When we finish parsing the function the variable name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   489
symbol table is cleared of all entries, and the function
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   490
name is inserted into the library element symbol table. This
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   491
means that from then onwards flex will return a
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   492
derived_function_name_token whenever it comes across the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   493
function name.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   494
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   495
In order to insert the function name into the variable_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   496
symbol table BEFORE the function body gets parsed, we
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   497
need the parser to reduce a construct that contains the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   498
the function name. That is why we created the extra
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   499
construct 'function_name_declaration', i.e. to force
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   500
the parser to reduce it, before parsing the function body,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   501
and therefore get an oportunity to insert the function name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   502
into the variable name symbol table!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   503
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   504
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   505
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   506
/* B 3.2.4 Iteration Statements */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   507
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   508
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   509
Issue 1
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   510
=======
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   511
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   512
For the 'FOR' iteration loop
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   513
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   514
  FOR control_variable ASSIGN expression TO expression BY expression DO statement_list END_FOR
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   515
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   516
The spec declares the control variable in the syntax as
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   517
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   518
  control_variable: identifier;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   519
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   520
but then defines the semantics of control_variable (Section 3.3.2.4)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   521
as being of an integer type (e.g., SINT, INT, or DINT).
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   522
Obviously this presuposes that the control_variable must have been
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   523
declared in some 'VAR .. VAR_END' construct, so I (Mario) changed
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   524
the syntax to read
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   525
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   526
  control_variable: variable_name;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   527
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   528
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   529
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   530
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   531
**************************************************************************
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   532
444
92d40d2a7adc Update comments on general architecture.
Mario de Sousa <msousa@fe.up.pt>
parents: 265
diff changeset
   533
  Copyright (C) 2003-2012  Mario de Sousa (msousa@fe.up.pt)