stage1_2/stage1_2_priv.hh
changeset 177 697562a5da7c
parent 175 dadda1b5401e
child 264 6facabd9c2cd
equal deleted inserted replaced
176:bef3cc16c064 177:697562a5da7c
    40 
    40 
    41 
    41 
    42 
    42 
    43 /* file with the declarations of symbol tables... */
    43 /* file with the declarations of symbol tables... */
    44 #include "../util/symtable.hh"
    44 #include "../util/symtable.hh"
    45 
    45 #include "stage1_2.hh"
    46 
    46 
    47 
    47 
    48 /*
    48 /*
    49  * This file includes the interface through which the lexical parser (stage 1 - flex)
    49  * This file includes the interface through which the lexical parser (stage 1 - flex)
    50  * and the syntax analyser (stage 2 - bison) interact between themselves.
    50  * and the syntax analyser (stage 2 - bison) interact between themselves.
    51  *
    51  *
    52  * This is mostly through direct access to shared global variables, however some
    52  * This is mostly through direct access to shared global variables, however some
    53  * of the global variables will only be accessed through some accessor functions.
    53  * of the global variables will only be accessed through some accessor functions.
    54  *
    54  *
       
    55  * This file also includes the interface between the main stage1_2() functions and 
       
    56  * the flex lexical parser.
       
    57  *
    55  * This file also includes some utility functions (strdupX() ) that are both used
    58  * This file also includes some utility functions (strdupX() ) that are both used
    56  * in the lexical and syntax analysers.
    59  * in the lexical and syntax analysers.
    57  */
    60  */
    58 
    61 
    59 
    62 
    60 
    63 
    61 
    64 
       
    65 /*************************************************************/
       
    66 /*************************************************************/
       
    67 /****                                                    *****/
       
    68 /****  I n t e r f a c e    B e t w e e n                *****/
       
    69 /****           F l e x    a n d     s t a g e 1 _ 2 ()  *****/
       
    70 /****                                                    *****/
       
    71 /*************************************************************/
       
    72 /*************************************************************/
       
    73 
       
    74 /******************************************************/
       
    75 /* whether we are suporting safe extensions           */
       
    76 /* as defined in PLCopen - Technical Committee 5      */
       
    77 /* Safety Software Technical Specification,           */
       
    78 /* Part 1: Concepts and Function Blocks,              */
       
    79 /* Version 1.0 – Official Release                     */
       
    80 /******************************************************/
       
    81 bool get_opt_safe_extensions();
       
    82 
       
    83 
       
    84 
       
    85 /*************************************************************/
       
    86 /*************************************************************/
       
    87 /****                                                    *****/
       
    88 /****  I n t e r f a c e    B e t w e e n                *****/
       
    89 /****           F l e x    a n d     B i s o n           *****/
       
    90 /****                                                    *****/
       
    91 /*************************************************************/
       
    92 /*************************************************************/
    62 
    93 
    63 /*********************************************/
    94 /*********************************************/
    64 /* print the include file stack to stderr... */
    95 /* print the include file stack to stderr... */
    65 /*********************************************/
    96 /*********************************************/
    66 /* This is a service that flex provides to bison... */
    97 /* This is a service that flex provides to bison... */
    78  * Note that bison also sets this variable correctly to the first
   109  * Note that bison also sets this variable correctly to the first
    79  * file being parsed.
   110  * file being parsed.
    80  */
   111  */
    81 extern const char *current_filename;
   112 extern const char *current_filename;
    82 
   113 
       
   114 
    83 #define MAX_BUFFER_LENGTH 1000
   115 #define MAX_BUFFER_LENGTH 1000
    84 
   116 
    85 typedef struct {
   117 typedef struct {
    86     int eof;
   118     int eof;
    87     int lineNumber;
   119     int lineNumber;
   139 /*********************************/
   171 /*********************************/
   140 /* The global symbol tables...   */
   172 /* The global symbol tables...   */
   141 /*********************************/
   173 /*********************************/
   142 /* NOTE: only accessed indirectly by the lexical parser (flex)
   174 /* NOTE: only accessed indirectly by the lexical parser (flex)
   143  *       through the function get_identifier_token()
   175  *       through the function get_identifier_token()
       
   176  *
       
   177  *       Bison accesses these data structures directly.
       
   178  *
       
   179  *       In essence, they are a data passing mechanism between Bison and Flex.
   144  */
   180  */
   145 /* NOTE: BOGUS_TOKEN_ID is defined in the bison generated file iec.y.hh.
   181 /* NOTE: BOGUS_TOKEN_ID is defined in the bison generated file iec.y.hh.
   146  *       We need this constant defined before we can declare the symbol tables.
   182  *       We need this constant defined before we can declare the symbol tables.
   147  *       However, we cannot #include "iec.y.hh" in this file (stage1_2_priv.hh) directly
   183  *       However, we cannot #include "iec.y.hh" in this file (stage1_2_priv.hh) directly
   148  *       because of the way bison ver. 2.3 is copying all declarations in the prologue
   184  *       because of the way bison ver. 2.3 is copying all declarations in the prologue
   187  * symbol found.
   223  * symbol found.
   188  */
   224  */
   189 int get_direct_variable_token(const char *direct_variable_str);
   225 int get_direct_variable_token(const char *direct_variable_str);
   190 
   226 
   191 
   227 
   192 /************************/
   228 /*************************************************************/
   193 /* Utility Functions... */
   229 /*************************************************************/
   194 /************************/
   230 /****                                                    *****/
       
   231 /****  U t i l i t y   F u n c t i o n s ...             *****/
       
   232 /****                                                    *****/
       
   233 /****                                                    *****/
       
   234 /*************************************************************/
       
   235 /*************************************************************/
   195 
   236 
   196 /* Join two strings together. Allocate space with malloc(3). */
   237 /* Join two strings together. Allocate space with malloc(3). */
   197 char *strdup2(const char *a, const char *b);
   238 char *strdup2(const char *a, const char *b);
   198 
   239 
   199 /* Join three strings together. Allocate space with malloc(3). */
   240 /* Join three strings together. Allocate space with malloc(3). */