stage1_2/stage1_2_priv.hh
author mjsousa
Sun, 28 Sep 2014 17:39:28 +0100
changeset 934 2a42a68f4b59
parent 881 e05d69c1ccb3
child 952 e984cfdf3b10
permissions -rwxr-xr-x
Turn support of derefencing operator '^' an option (default is not supported).
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
     1
/*
264
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 177
diff changeset
     2
 *  matiec - a compiler for the programming languages defined in IEC 61131-3
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 177
diff changeset
     3
 *
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 177
diff changeset
     4
 *  Copyright (C) 2003-2011  Mario de Sousa (msousa@fe.up.pt)
279
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 264
diff changeset
     5
 *  Copyright (C) 2007-2011  Laurent Bessard and Edouard Tisserant
264
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 177
diff changeset
     6
 *
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 177
diff changeset
     7
 *  This program is free software: you can redistribute it and/or modify
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 177
diff changeset
     8
 *  it under the terms of the GNU General Public License as published by
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 177
diff changeset
     9
 *  the Free Software Foundation, either version 3 of the License, or
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 177
diff changeset
    10
 *  (at your option) any later version.
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 177
diff changeset
    11
 *
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 177
diff changeset
    12
 *  This program is distributed in the hope that it will be useful,
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 177
diff changeset
    13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 177
diff changeset
    14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 177
diff changeset
    15
 *  GNU General Public License for more details.
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 177
diff changeset
    16
 *
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 177
diff changeset
    17
 *  You should have received a copy of the GNU General Public License
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 177
diff changeset
    18
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 177
diff changeset
    19
 *
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    20
 *
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    21
 * 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
    22
 * 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
    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
/*
264
6facabd9c2cd Updating License info (with Edoaurd's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 177
diff changeset
    26
 * An IEC 61131-3 compiler.
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    27
 *
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    28
 * Based on the
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    29
 * 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
    30
 *
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    31
 */
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    32
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    33
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    34
/*
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    35
 * The private interface to stage1_2.cc 
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    36
 */
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    37
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    38
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    39
20
81a06a308b7e *** empty log message ***
mario
parents: 15
diff changeset
    40
/* !!! WARNING !!!
81a06a308b7e *** empty log message ***
mario
parents: 15
diff changeset
    41
 *
81a06a308b7e *** empty log message ***
mario
parents: 15
diff changeset
    42
 *       Whoever includes this file (stage1_2_priv.hh) will need
822
a7d9e0b8636b Fix build on Ubuntu 13.10
Edouard Tisserant
parents: 761
diff changeset
    43
 *       to first inlcude iec_bison.hh !!
20
81a06a308b7e *** empty log message ***
mario
parents: 15
diff changeset
    44
 *
81a06a308b7e *** empty log message ***
mario
parents: 15
diff changeset
    45
 *       Read other comments further down to understand why we don't
822
a7d9e0b8636b Fix build on Ubuntu 13.10
Edouard Tisserant
parents: 761
diff changeset
    46
 *       include iec_bison.hh in this file.
20
81a06a308b7e *** empty log message ***
mario
parents: 15
diff changeset
    47
 */
81a06a308b7e *** empty log message ***
mario
parents: 15
diff changeset
    48
81a06a308b7e *** empty log message ***
mario
parents: 15
diff changeset
    49
81a06a308b7e *** empty log message ***
mario
parents: 15
diff changeset
    50
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    51
/* file with the declarations of symbol tables... */
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    52
#include "../util/symtable.hh"
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    53
#include "stage1_2.hh"
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    54
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    55
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    56
/*
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    57
 * 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
    58
 * 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
    59
 *
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    60
 * 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
    61
 * 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
    62
 *
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    63
 * 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
    64
 * the flex lexical parser.
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    65
 *
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    66
 * 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
    67
 * in the lexical and syntax analysers.
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    68
 */
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    69
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    70
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    71
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
    72
177
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
/****                                                    *****/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    76
/****  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
    77
/****           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
    78
/****                                                    *****/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    79
/*************************************************************/
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
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
/* whether we are suporting safe extensions           */
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    84
/* as defined in PLCopen - Technical Committee 5      */
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    85
/* Safety Software Technical Specification,           */
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    86
/* Part 1: Concepts and Function Blocks,              */
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    87
/* Version 1.0 – Official Release                     */
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    88
/******************************************************/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    89
bool get_opt_safe_extensions();
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    90
867
a435684a5223 Add option to control support for nested comments (default is off, as defined in IEC 61131-3 v2)
mjsousa
parents: 761
diff changeset
    91
/************************************/
a435684a5223 Add option to control support for nested comments (default is off, as defined in IEC 61131-3 v2)
mjsousa
parents: 761
diff changeset
    92
/* whether to allow nested comments */
a435684a5223 Add option to control support for nested comments (default is off, as defined in IEC 61131-3 v2)
mjsousa
parents: 761
diff changeset
    93
/************************************/
a435684a5223 Add option to control support for nested comments (default is off, as defined in IEC 61131-3 v2)
mjsousa
parents: 761
diff changeset
    94
bool get_opt_nested_comments();
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
    95
934
2a42a68f4b59 Turn support of derefencing operator '^' an option (default is not supported).
mjsousa
parents: 881
diff changeset
    96
/**************************************************************************/
2a42a68f4b59 Turn support of derefencing operator '^' an option (default is not supported).
mjsousa
parents: 881
diff changeset
    97
/* whether to allow REF(), DREF(), REF_TO, NULL and ^ operators/keywords  */
2a42a68f4b59 Turn support of derefencing operator '^' an option (default is not supported).
mjsousa
parents: 881
diff changeset
    98
/**************************************************************************/
2a42a68f4b59 Turn support of derefencing operator '^' an option (default is not supported).
mjsousa
parents: 881
diff changeset
    99
bool get_opt_ref_standard_extensions();
873
dea39ef02847 Add limited support for the REF() operator (defined in v3 of IEC 61131-3)
mjsousa
parents: 867
diff changeset
   100
dea39ef02847 Add limited support for the REF() operator (defined in v3 of IEC 61131-3)
mjsousa
parents: 867
diff changeset
   101
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   102
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   103
/*************************************************************/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   104
/*************************************************************/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   105
/****                                                    *****/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   106
/****  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
   107
/****           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
   108
/****                                                    *****/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   109
/*************************************************************/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   110
/*************************************************************/
15
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
/*********************************************/
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   113
/* print the include file stack to stderr... */
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   114
/*********************************************/
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   115
/* 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
   116
void print_include_stack(void);
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   117
756
634f476cb60f Insert the auto generated enum datatype conversion functions after the TYPE...END_TYPE, instead of at the end of input file.
Mario de Sousa <msousa@fe.up.pt>
parents: 354
diff changeset
   118
/*****************************************************/
634f476cb60f Insert the auto generated enum datatype conversion functions after the TYPE...END_TYPE, instead of at the end of input file.
Mario de Sousa <msousa@fe.up.pt>
parents: 354
diff changeset
   119
/* Ask flex to include the source code in the string */
634f476cb60f Insert the auto generated enum datatype conversion functions after the TYPE...END_TYPE, instead of at the end of input file.
Mario de Sousa <msousa@fe.up.pt>
parents: 354
diff changeset
   120
/*****************************************************/
634f476cb60f Insert the auto generated enum datatype conversion functions after the TYPE...END_TYPE, instead of at the end of input file.
Mario de Sousa <msousa@fe.up.pt>
parents: 354
diff changeset
   121
/* This is a service that flex provides to bison... */
634f476cb60f Insert the auto generated enum datatype conversion functions after the TYPE...END_TYPE, instead of at the end of input file.
Mario de Sousa <msousa@fe.up.pt>
parents: 354
diff changeset
   122
/* The string should contain valid IEC 61131-3 source code. Bison will ask flex to insert source 
634f476cb60f Insert the auto generated enum datatype conversion functions after the TYPE...END_TYPE, instead of at the end of input file.
Mario de Sousa <msousa@fe.up.pt>
parents: 354
diff changeset
   123
 * code into the input stream of IEC code being parsed. The code to be inserted is typically
634f476cb60f Insert the auto generated enum datatype conversion functions after the TYPE...END_TYPE, instead of at the end of input file.
Mario de Sousa <msousa@fe.up.pt>
parents: 354
diff changeset
   124
 * generated automatically.
634f476cb60f Insert the auto generated enum datatype conversion functions after the TYPE...END_TYPE, instead of at the end of input file.
Mario de Sousa <msousa@fe.up.pt>
parents: 354
diff changeset
   125
 * Currently this is used to insert conversion functions ***_TO_*** (as defined by the standard)
634f476cb60f Insert the auto generated enum datatype conversion functions after the TYPE...END_TYPE, instead of at the end of input file.
Mario de Sousa <msousa@fe.up.pt>
parents: 354
diff changeset
   126
 * between user defined (i.e. derived) enumerated datatypes, and some basic datatypes 
634f476cb60f Insert the auto generated enum datatype conversion functions after the TYPE...END_TYPE, instead of at the end of input file.
Mario de Sousa <msousa@fe.up.pt>
parents: 354
diff changeset
   127
 * (e.g. INT, STRING, etc...)
634f476cb60f Insert the auto generated enum datatype conversion functions after the TYPE...END_TYPE, instead of at the end of input file.
Mario de Sousa <msousa@fe.up.pt>
parents: 354
diff changeset
   128
 */
634f476cb60f Insert the auto generated enum datatype conversion functions after the TYPE...END_TYPE, instead of at the end of input file.
Mario de Sousa <msousa@fe.up.pt>
parents: 354
diff changeset
   129
void include_string(const char *source_code);
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   130
757
f1fc4aa6f0e3 Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents: 756
diff changeset
   131
f1fc4aa6f0e3 Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents: 756
diff changeset
   132
/**********************************/
f1fc4aa6f0e3 Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents: 756
diff changeset
   133
/* Tell flex which file to parse. */
f1fc4aa6f0e3 Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents: 756
diff changeset
   134
/**********************************/
f1fc4aa6f0e3 Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents: 756
diff changeset
   135
/* This is a service that flex provides to bison... */
f1fc4aa6f0e3 Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents: 756
diff changeset
   136
/* Tell flex which file to parse. This function will not imediately start parsing the file.
f1fc4aa6f0e3 Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents: 756
diff changeset
   137
 * To parse the file, you then need to call yyparse()
f1fc4aa6f0e3 Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents: 756
diff changeset
   138
 *
761
7b52623a2f37 Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents: 757
diff changeset
   139
 * Returns NULL on error opening the file (and a valid errno), or 0 on success.
7b52623a2f37 Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents: 757
diff changeset
   140
 * Caller must close the file!
7b52623a2f37 Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents: 757
diff changeset
   141
 */
7b52623a2f37 Allow bison to ask for an END_OF_INPUT token multiple times!
mjsousa
parents: 757
diff changeset
   142
FILE *parse_file(const char *filename);
757
f1fc4aa6f0e3 Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents: 756
diff changeset
   143
f1fc4aa6f0e3 Code cleanup: move tracking functions to flex.
Mario de Sousa <msousa@fe.up.pt>
parents: 756
diff changeset
   144
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   145
68
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   146
/****************************************************/
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   147
/* Controlling the entry to the body_state in flex. */
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   148
/****************************************************/
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   149
void cmd_goto_body_state(void);
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   150
int  get_goto_body_state(void);
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   151
void rst_goto_body_state(void);
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   152
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   153
68
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   154
/*************************************************************/
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   155
/* Controlling the entry to the sfc_qualifier_state in flex. */
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   156
/*************************************************************/
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   157
void cmd_goto_sfc_qualifier_state(void);
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   158
int  get_goto_sfc_qualifier_state(void);
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   159
void rst_goto_sfc_qualifier_state(void);
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   160
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   161
86
1988bf1634da Adding support for use of PRIORITY as identifier inside SFC.
mario
parents: 74
diff changeset
   162
/*************************************************************/
1988bf1634da Adding support for use of PRIORITY as identifier inside SFC.
mario
parents: 74
diff changeset
   163
/* 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
   164
/*************************************************************/
1988bf1634da Adding support for use of PRIORITY as identifier inside SFC.
mario
parents: 74
diff changeset
   165
void cmd_goto_sfc_priority_state(void);
1988bf1634da Adding support for use of PRIORITY as identifier inside SFC.
mario
parents: 74
diff changeset
   166
int  get_goto_sfc_priority_state(void);
1988bf1634da Adding support for use of PRIORITY as identifier inside SFC.
mario
parents: 74
diff changeset
   167
void rst_goto_sfc_priority_state(void);
1988bf1634da Adding support for use of PRIORITY as identifier inside SFC.
mario
parents: 74
diff changeset
   168
1988bf1634da Adding support for use of PRIORITY as identifier inside SFC.
mario
parents: 74
diff changeset
   169
74
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 68
diff changeset
   170
/*********************************************************/
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 68
diff changeset
   171
/* Controlling the entry to the task_init_state in flex. */
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 68
diff changeset
   172
/*********************************************************/
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 68
diff changeset
   173
void cmd_goto_task_init_state(void);
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 68
diff changeset
   174
int  get_goto_task_init_state(void);
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 68
diff changeset
   175
void rst_goto_task_init_state(void);
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 68
diff changeset
   176
85af9521bf63 fixing identifier issues of PRIORITY, SINGLE, and INTERVAL
mario
parents: 68
diff changeset
   177
68
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   178
/****************************************************************/
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   179
/* Returning to state in flex previously pushed onto the stack. */
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   180
/****************************************************************/
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   181
void cmd_pop_state(void);
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   182
int  get_pop_state(void);
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   183
void rst_pop_state(void);
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   184
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   185
b0a43002dcac Adding basic error checking.
mario
parents: 20
diff changeset
   186
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   187
/*********************************/
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   188
/* The global symbol tables...   */
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
/* 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
   191
 *       through the function get_identifier_token()
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   192
 *
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   193
 *       Bison accesses these data structures directly.
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   194
 *
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   195
 *       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
   196
 */
822
a7d9e0b8636b Fix build on Ubuntu 13.10
Edouard Tisserant
parents: 761
diff changeset
   197
/* NOTE: BOGUS_TOKEN_ID is defined in the bison generated file iec_bison.hh.
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   198
 *       We need this constant defined before we can declare the symbol tables.
822
a7d9e0b8636b Fix build on Ubuntu 13.10
Edouard Tisserant
parents: 761
diff changeset
   199
 *       However, we cannot #include "iec_bison.hh" in this file (stage1_2_priv.hh) directly
20
81a06a308b7e *** empty log message ***
mario
parents: 15
diff changeset
   200
 *       because of the way bison ver. 2.3 is copying all declarations in the prologue
822
a7d9e0b8636b Fix build on Ubuntu 13.10
Edouard Tisserant
parents: 761
diff changeset
   201
 *       of iec.y to the iec_bison.hh file (including an #include stage1_2_priv.hh).
a7d9e0b8636b Fix build on Ubuntu 13.10
Edouard Tisserant
parents: 761
diff changeset
   202
 *       So, if we were to include "iec_bison.hh" here, we would get a circular include.
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   203
 *       All this means that whoever includes this file (stage1_2_priv.hh) will need
822
a7d9e0b8636b Fix build on Ubuntu 13.10
Edouard Tisserant
parents: 761
diff changeset
   204
 *       to take care to first inlcude iec_bison.hh !!
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   205
 */ 
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   206
/* 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
   207
/* e.g.: <function_name , function_decl>
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   208
 *       <fb_name , fb_decl>
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   209
 *       <type_name , type_decl>
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   210
 *       <program_name , program_decl>
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   211
 *       <configuration_name , configuration_decl>
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   212
 */
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   213
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
   214
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   215
/* 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
   216
 * the function currently being parsed...
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   217
 */
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   218
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
   219
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 136
diff changeset
   220
/* 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
   221
 * the function currently being parsed...
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 136
diff changeset
   222
 */
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 136
diff changeset
   223
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
   224
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   225
/* Function only called from within flex!
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
 * 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
   228
 * 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
   229
 * symbol found.
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   230
 * 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
   231
 * 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
   232
 */
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   233
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
   234
175
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 136
diff changeset
   235
/* Function only called from within flex!
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 136
diff changeset
   236
 *
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 136
diff changeset
   237
 * search for a symbol in direct variables symbol table
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 136
diff changeset
   238
 * 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
   239
 * symbol found.
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 136
diff changeset
   240
 */
dadda1b5401e Adding support for checking direct variable declared before using
lbessard
parents: 136
diff changeset
   241
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
   242
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   243
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   244
/*************************************************************/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   245
/*************************************************************/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   246
/****                                                    *****/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   247
/****  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
   248
/****                                                    *****/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   249
/****                                                    *****/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   250
/*************************************************************/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 175
diff changeset
   251
/*************************************************************/
15
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   252
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   253
/* 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
   254
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
   255
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   256
/* 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
   257
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
   258
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   259
0b472e25eb16 Adding changes to make the compiler compatible with bison ver 2.3
mario
parents:
diff changeset
   260