stage1_2/stage1_2_priv.hh
author mario
Tue, 26 May 2009 18:04:27 +0200
changeset 178 1622dc05c6ca
parent 177 697562a5da7c
child 264 6facabd9c2cd
permissions -rw-r--r--
Starting move of search utils to their own top level directory.
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
     1
/*
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
     2
 * (c) 2007 Mario de Sousa
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
     3
 *
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
     4
 * Offered to the public under the terms of the GNU General Public License
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
     5
 * as published by the Free Software Foundation; either version 2 of the
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
     6
 * License, or (at your option) any later version.
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
     7
 *
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
     8
 * This program is distributed in the hope that it will be useful, but
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
     9
 * WITHOUT ANY WARRANTY; without even the implied warranty of
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    11
 * Public License for more details.
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    12
 *
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    13
 * This code is made available on the understanding that it will not be
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    14
 * used in safety-critical situations without a full and competent review.
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    15
 */
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    16
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    17
/*
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    18
 * An IEC 61131-3 IL and ST compiler.
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    19
 *
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    20
 * Based on the
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    21
 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    22
 *
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    23
 */
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    24
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    25
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    26
/*
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    27
 * The private interface to stage1_2.cc 
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    28
 */
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    29
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    30
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    31
20
81a06a308b7e *** empty log message ***
mario
parents: 15
diff changeset
    32
/* !!! WARNING !!!
81a06a308b7e *** empty log message ***
mario
parents: 15
diff changeset
    33
 *
81a06a308b7e *** empty log message ***
mario
parents: 15
diff changeset
    34
 *       Whoever includes this file (stage1_2_priv.hh) will need
81a06a308b7e *** empty log message ***
mario
parents: 15
diff changeset
    35
 *       to first inlcude iec.y.hh !!
81a06a308b7e *** empty log message ***
mario
parents: 15
diff changeset
    36
 *
81a06a308b7e *** empty log message ***
mario
parents: 15
diff changeset
    37
 *       Read other comments further down to understand why we don't
81a06a308b7e *** empty log message ***
mario
parents: 15
diff changeset
    38
 *       include iec.y.hh in this file.
81a06a308b7e *** empty log message ***
mario
parents: 15
diff changeset
    39
 */
81a06a308b7e *** empty log message ***
mario
parents: 15
diff changeset
    40
81a06a308b7e *** empty log message ***
mario
parents: 15
diff changeset
    41
81a06a308b7e *** empty log message ***
mario
parents: 15
diff changeset
    42
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    43
/* file with the declarations of symbol tables... */
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    44
#include "../util/symtable.hh"
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    45
#include "stage1_2.hh"
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    46
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    47
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    48
/*
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    49
 * This file includes the interface through which the lexical parser (stage 1 - flex)
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    50
 * and the syntax analyser (stage 2 - bison) interact between themselves.
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    51
 *
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    52
 * This is mostly through direct access to shared global variables, however some
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    53
 * of the global variables will only be accessed through some accessor functions.
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    54
 *
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    55
 * This file also includes the interface between the main stage1_2() functions and 
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    56
 * the flex lexical parser.
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    57
 *
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    58
 * This file also includes some utility functions (strdupX() ) that are both used
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    59
 * in the lexical and syntax analysers.
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    60
 */
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    61
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    62
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    63
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    64
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    65
/*************************************************************/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    66
/*************************************************************/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    67
/****                                                    *****/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    68
/****  I n t e r f a c e    B e t w e e n                *****/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    69
/****           F l e x    a n d     s t a g e 1 _ 2 ()  *****/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    70
/****                                                    *****/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    71
/*************************************************************/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    72
/*************************************************************/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    73
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    74
/******************************************************/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    75
/* whether we are suporting safe extensions           */
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    76
/* as defined in PLCopen - Technical Committee 5      */
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    77
/* Safety Software Technical Specification,           */
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    78
/* Part 1: Concepts and Function Blocks,              */
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    79
/* Version 1.0 – Official Release                     */
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    80
/******************************************************/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    81
bool get_opt_safe_extensions();
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    82
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    83
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    84
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    85
/*************************************************************/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    86
/*************************************************************/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    87
/****                                                    *****/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    88
/****  I n t e r f a c e    B e t w e e n                *****/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    89
/****           F l e x    a n d     B i s o n           *****/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    90
/****                                                    *****/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    91
/*************************************************************/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    92
/*************************************************************/
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    93
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    94
/*********************************************/
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    95
/* print the include file stack to stderr... */
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    96
/*********************************************/
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    97
/* This is a service that flex provides to bison... */
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    98
void print_include_stack(void);
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    99
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   100
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   101
/**************************************/
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   102
/* The name of the file being parsed. */
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   103
/**************************************/
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   104
/* The name of the file currently being parsed...
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   105
 * Note that flex accesses and updates this global variable
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   106
 * apropriately whenever it comes across an (*#include <filename> *)
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   107
 * directive...
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   108
 * ... and bison will use it when producing error messages.
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   109
 * Note that bison also sets this variable correctly to the first
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   110
 * file being parsed.
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   111
 */
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   112
extern const char *current_filename;
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   113
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   114
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 86
diff changeset
   115
#define MAX_BUFFER_LENGTH 1000
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   116
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 86
diff changeset
   117
typedef struct {
32bd7ef40897 Adding some improvements:
lbessard
parents: 86
diff changeset
   118
    int eof;
32bd7ef40897 Adding some improvements:
lbessard
parents: 86
diff changeset
   119
    int lineNumber;
32bd7ef40897 Adding some improvements:
lbessard
parents: 86
diff changeset
   120
    int currentChar;
32bd7ef40897 Adding some improvements:
lbessard
parents: 86
diff changeset
   121
    int lineLength;
32bd7ef40897 Adding some improvements:
lbessard
parents: 86
diff changeset
   122
    int currentTokenStart;
32bd7ef40897 Adding some improvements:
lbessard
parents: 86
diff changeset
   123
    char* buffer;
32bd7ef40897 Adding some improvements:
lbessard
parents: 86
diff changeset
   124
    FILE *in_file;
32bd7ef40897 Adding some improvements:
lbessard
parents: 86
diff changeset
   125
  } tracking_t;
32bd7ef40897 Adding some improvements:
lbessard
parents: 86
diff changeset
   126
32bd7ef40897 Adding some improvements:
lbessard
parents: 86
diff changeset
   127
int GetNextChar(char *b, int maxBuffer);
32bd7ef40897 Adding some improvements:
lbessard
parents: 86
diff changeset
   128
tracking_t* GetNewTracking(FILE* in_file);
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   129
68
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   130
/****************************************************/
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   131
/* Controlling the entry to the body_state in flex. */
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   132
/****************************************************/
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   133
void cmd_goto_body_state(void);
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   134
int  get_goto_body_state(void);
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   135
void rst_goto_body_state(void);
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   136
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   137
68
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   138
/*************************************************************/
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   139
/* Controlling the entry to the sfc_qualifier_state in flex. */
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   140
/*************************************************************/
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   141
void cmd_goto_sfc_qualifier_state(void);
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   142
int  get_goto_sfc_qualifier_state(void);
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   143
void rst_goto_sfc_qualifier_state(void);
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   144
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   145
86
1988bf1634da Adding support for use of PRIORITY as identifier inside SFC.
mario
parents: 74
diff changeset
   146
/*************************************************************/
1988bf1634da Adding support for use of PRIORITY as identifier inside SFC.
mario
parents: 74
diff changeset
   147
/* Controlling the entry to the sfc_priority_state in flex.  */
1988bf1634da Adding support for use of PRIORITY as identifier inside SFC.
mario
parents: 74
diff changeset
   148
/*************************************************************/
1988bf1634da Adding support for use of PRIORITY as identifier inside SFC.
mario
parents: 74
diff changeset
   149
void cmd_goto_sfc_priority_state(void);
1988bf1634da Adding support for use of PRIORITY as identifier inside SFC.
mario
parents: 74
diff changeset
   150
int  get_goto_sfc_priority_state(void);
1988bf1634da Adding support for use of PRIORITY as identifier inside SFC.
mario
parents: 74
diff changeset
   151
void rst_goto_sfc_priority_state(void);
1988bf1634da Adding support for use of PRIORITY as identifier inside SFC.
mario
parents: 74
diff changeset
   152
1988bf1634da Adding support for use of PRIORITY as identifier inside SFC.
mario
parents: 74
diff changeset
   153
74
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 68
diff changeset
   154
/*********************************************************/
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 68
diff changeset
   155
/* Controlling the entry to the task_init_state in flex. */
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 68
diff changeset
   156
/*********************************************************/
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 68
diff changeset
   157
void cmd_goto_task_init_state(void);
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 68
diff changeset
   158
int  get_goto_task_init_state(void);
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 68
diff changeset
   159
void rst_goto_task_init_state(void);
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 68
diff changeset
   160
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 68
diff changeset
   161
68
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   162
/****************************************************************/
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   163
/* Returning to state in flex previously pushed onto the stack. */
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   164
/****************************************************************/
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   165
void cmd_pop_state(void);
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   166
int  get_pop_state(void);
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   167
void rst_pop_state(void);
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   168
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   169
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   170
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   171
/*********************************/
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   172
/* The global symbol tables...   */
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   173
/*********************************/
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   174
/* NOTE: only accessed indirectly by the lexical parser (flex)
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   175
 *       through the function get_identifier_token()
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   176
 *
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   177
 *       Bison accesses these data structures directly.
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   178
 *
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   179
 *       In essence, they are a data passing mechanism between Bison and Flex.
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   180
 */
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   181
/* NOTE: BOGUS_TOKEN_ID is defined in the bison generated file iec.y.hh.
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   182
 *       We need this constant defined before we can declare the symbol tables.
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   183
 *       However, we cannot #include "iec.y.hh" in this file (stage1_2_priv.hh) directly
20
81a06a308b7e *** empty log message ***
mario
parents: 15
diff changeset
   184
 *       because of the way bison ver. 2.3 is copying all declarations in the prologue
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   185
 *       of iec.y to the iec.y.hh file (including an #include stage1_2_priv.hh).
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   186
 *       So, if we were to include "iec.y.hh" here, we would get a circular include.
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   187
 *       All this means that whoever includes this file (stage1_2_priv.hh) will need
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   188
 *       to take care to first inlcude iec.y.hh !!
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   189
 */ 
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   190
/* A symbol table to store all the library elements */
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   191
/* e.g.: <function_name , function_decl>
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   192
 *       <fb_name , fb_decl>
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   193
 *       <type_name , type_decl>
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   194
 *       <program_name , program_decl>
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   195
 *       <configuration_name , configuration_decl>
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   196
 */
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   197
extern symtable_c<int, BOGUS_TOKEN_ID> library_element_symtable;
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   198
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   199
/* A symbol table to store the declared variables of
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   200
 * the function currently being parsed...
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   201
 */
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   202
extern symtable_c<int, BOGUS_TOKEN_ID> variable_name_symtable;
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   203
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 136
diff changeset
   204
/* A symbol table to store the declared direct variables of
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 136
diff changeset
   205
 * the function currently being parsed...
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 136
diff changeset
   206
 */
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 136
diff changeset
   207
extern symtable_c<int, BOGUS_TOKEN_ID> direct_variable_symtable;
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 136
diff changeset
   208
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   209
/* Function only called from within flex!
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   210
 *
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   211
 * search for a symbol in either of the two symbol tables
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   212
 * declared above, and return the token id of the first
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   213
 * symbol found.
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   214
 * Searches first in the variables, and only if not found
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   215
 * does it continue searching in the library elements
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   216
 */
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   217
int get_identifier_token(const char *identifier_str);
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   218
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 136
diff changeset
   219
/* Function only called from within flex!
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 136
diff changeset
   220
 *
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 136
diff changeset
   221
 * search for a symbol in direct variables symbol table
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 136
diff changeset
   222
 * declared above, and return the token id of the first
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 136
diff changeset
   223
 * symbol found.
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 136
diff changeset
   224
 */
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 136
diff changeset
   225
int get_direct_variable_token(const char *direct_variable_str);
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   226
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   227
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   228
/*************************************************************/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   229
/*************************************************************/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   230
/****                                                    *****/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   231
/****  U t i l i t y   F u n c t i o n s ...             *****/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   232
/****                                                    *****/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   233
/****                                                    *****/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   234
/*************************************************************/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   235
/*************************************************************/
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   236
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   237
/* Join two strings together. Allocate space with malloc(3). */
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   238
char *strdup2(const char *a, const char *b);
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   239
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   240
/* Join three strings together. Allocate space with malloc(3). */
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   241
char *strdup3(const char *a, const char *b, const char *c);
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   242
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   243
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   244