readme
changeset 270 f1674941c3ad
parent 265 4d222f46f8cc
child 444 92d40d2a7adc
equal deleted inserted replaced
256:101c7f148b9a 270:f1674941c3ad
     1 
     1 
     2 
     2 
     3 
     3 
     4   IEC 61131-3 IL and ST compiler
     4   MATIEC - IEC 61131-3 compiler
     5 
     5 
     6 
     6 
     7   The following compiler has been based on the
     7   The following compiler has been based on the
     8   FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
     8   FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
     9 
     9 
    10 
    10 
    11   (c) 2003 Mario de Sousa
    11   Copyright (C) 2003-2011  Mario de Sousa (msousa@fe.up.pt)
    12 
    12 
    13 
    13 
    14 
    14 
    15 ****************************************************************
    15 ****************************************************************
    16 ****************************************************************
    16 ****************************************************************
    25 ****************************************************************
    25 ****************************************************************
    26 
    26 
    27  The compiler works in 4(+1) stages:
    27  The compiler works in 4(+1) stages:
    28  Stage 1   - Lexical analyser      - implemented with flex (iec.flex)
    28  Stage 1   - Lexical analyser      - implemented with flex (iec.flex)
    29  Stage 2   - Syntax parser         - implemented with bison (iec.y)
    29  Stage 2   - Syntax parser         - implemented with bison (iec.y)
    30  Stage 3   - Semantics analyser    - not yet implemented
    30  Stage 3   - Semantics analyser    - currently in its early stages
    31  Stage 4   - Code generator        - implemented in C++
    31  Stage 4   - Code generator        - implemented in C++
    32  Stage 4+1 - Binary code generator - gcc, javac, etc...
    32  Stage 4+1 - Binary code generator - gcc, javac, etc...
    33 
    33 
    34 
    34 
    35  Data structures passed between stages, in global variables:
    35  Data structures passed between stages, in global variables:
    53 possible because both stages are executed in the same pass.
    53 possible because both stages are executed in the same pass.
    54 
    54 
    55 
    55 
    56 
    56 
    57  NOTE 2
    57  NOTE 2
    58  ======
       
    59   I (Mario) have a feeling that the abstract syntax may be
       
    60 considerably simplified without any drawbacks to semantic checking
       
    61 and code generation. I have nevertheless opted to keep as much 
       
    62 info as possible in the abstract syntax tree, in case it may become
       
    63 necessary further on.
       
    64  Once we start coding the next stages (semantic checking and code
       
    65 generation) I will get a better understanding of what is required
       
    66 of the abstract syntax tree. At that stage I will be better
       
    67 positioned to make a more informed decision on how best to structure
       
    68 the abstract syntax tree.
       
    69  For now, we play conservative and keep as much info as possible.
       
    70 
       
    71  
       
    72 
       
    73  NOTE 3
       
    74  ======
    58  ======
    75  It would be nice to get this parser integrated into the gcc
    59  It would be nice to get this parser integrated into the gcc
    76 group of compilers. We would then be able to compile our st/il
    60 group of compilers. We would then be able to compile our st/il
    77 programs directly into executable binaries, for all the processor
    61 programs directly into executable binaries, for all the processor
    78 architectures gcc currently supports.
    62 architectures gcc currently supports.
   143 =======
   127 =======
   144 
   128 
   145 We extend the IEC 61131-3 standard syntax to allow inclusion of 
   129 We extend the IEC 61131-3 standard syntax to allow inclusion of 
   146 other files. The accepted syntax is:
   130 other files. The accepted syntax is:
   147 
   131 
   148    (*#include "<filename>" *)
   132    {#include "<filename>" }
   149 
   133 
   150 Note how this would be ignored by other standard complient compilers 
   134 We use a pragma directive for this (allowed by the standard itself),
   151 as a simple comment!
   135  since it is an extension of the standard. In principle, this would 
       
   136 be ignored by other standard complient compilers!
   152 
   137 
   153 
   138 
   154 
   139 
   155 ****************************************************************
   140 ****************************************************************
   156 ****************************************************************
   141 ****************************************************************
   401 
   386 
   402 
   387 
   403 
   388 
   404 **************************************************************************
   389 **************************************************************************
   405 
   390 
   406   (c) 2003 Mario de Sousa
   391   Copyright (C) 2003-2011  Mario de Sousa (msousa@fe.up.pt)