absyntax/absyntax.hh
author Mario de Sousa <msousa@fe.up.pt>
Mon, 03 Apr 2017 22:18:22 +0100
changeset 1041 56ebe2a31b5b
parent 1000 556b74055518
child 1043 4165b7189c32
permissions -rw-r--r--
Access elements[] in list_c through a new get_element() method.
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
/*
261
db2ad6541d92 Updating licensing information.
Mario de Sousa <msousa@fe.up.pt>
parents: 69
diff changeset
     2
 *  matiec - a compiler for the programming languages defined in IEC 61131-3
db2ad6541d92 Updating licensing information.
Mario de Sousa <msousa@fe.up.pt>
parents: 69
diff changeset
     3
 *  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: 261
diff changeset
     4
 *  Copyright (C) 2007-2011  Laurent Bessard and Edouard Tisserant
261
db2ad6541d92 Updating licensing information.
Mario de Sousa <msousa@fe.up.pt>
parents: 69
diff changeset
     5
 *
db2ad6541d92 Updating licensing information.
Mario de Sousa <msousa@fe.up.pt>
parents: 69
diff changeset
     6
 *  This program is free software: you can redistribute it and/or modify
db2ad6541d92 Updating licensing information.
Mario de Sousa <msousa@fe.up.pt>
parents: 69
diff changeset
     7
 *  it under the terms of the GNU General Public License as published by
db2ad6541d92 Updating licensing information.
Mario de Sousa <msousa@fe.up.pt>
parents: 69
diff changeset
     8
 *  the Free Software Foundation, either version 3 of the License, or
db2ad6541d92 Updating licensing information.
Mario de Sousa <msousa@fe.up.pt>
parents: 69
diff changeset
     9
 *  (at your option) any later version.
db2ad6541d92 Updating licensing information.
Mario de Sousa <msousa@fe.up.pt>
parents: 69
diff changeset
    10
 *
db2ad6541d92 Updating licensing information.
Mario de Sousa <msousa@fe.up.pt>
parents: 69
diff changeset
    11
 *  This program is distributed in the hope that it will be useful,
db2ad6541d92 Updating licensing information.
Mario de Sousa <msousa@fe.up.pt>
parents: 69
diff changeset
    12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
db2ad6541d92 Updating licensing information.
Mario de Sousa <msousa@fe.up.pt>
parents: 69
diff changeset
    13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
db2ad6541d92 Updating licensing information.
Mario de Sousa <msousa@fe.up.pt>
parents: 69
diff changeset
    14
 *  GNU General Public License for more details.
db2ad6541d92 Updating licensing information.
Mario de Sousa <msousa@fe.up.pt>
parents: 69
diff changeset
    15
 *
db2ad6541d92 Updating licensing information.
Mario de Sousa <msousa@fe.up.pt>
parents: 69
diff changeset
    16
 *  You should have received a copy of the GNU General Public License
db2ad6541d92 Updating licensing information.
Mario de Sousa <msousa@fe.up.pt>
parents: 69
diff changeset
    17
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
db2ad6541d92 Updating licensing information.
Mario de Sousa <msousa@fe.up.pt>
parents: 69
diff changeset
    18
 *
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    19
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    20
 * This code is made available on the understanding that it will not be
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    21
 * used in safety-critical situations without a full and competent review.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    22
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    23
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    24
/*
261
db2ad6541d92 Updating licensing information.
Mario de Sousa <msousa@fe.up.pt>
parents: 69
diff changeset
    25
 * An 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
    26
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    27
 * 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
    28
 * 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
    29
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    30
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    31
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    32
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    33
 * Declaration of the Abstract Syntax data structure components
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    34
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    35
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    36
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    37
 * ABSYNTAX.H
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    38
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    39
 * This generates the parse tree structure used to bind the components
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    40
 * identified by Bison in the correct syntax order. At the end of the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    41
 * Bison analysis the tree is walked in a sequential fashion generating
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    42
 * the relavent code.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    43
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    44
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    45
#ifndef _ABSYNTAX_HH
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    46
#define _ABSYNTAX_HH
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    47
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    48
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    49
#include <stdio.h> // required for NULL
417
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents: 350
diff changeset
    50
#include <vector>
738
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
    51
#include <map>
564
dabffc3086dc Start constant_folding class.
Manuele Conti <conti.ma@alice.it>
parents: 459
diff changeset
    52
#include <string>
565
8acbddf75333 Fix a few bugs of previous commit.
Mario de Sousa <msousa@fe.up.pt>
parents: 564
diff changeset
    53
#include <stdint.h>  // required for uint64_t, etc...
607
be9ba3531afb cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents: 572
diff changeset
    54
#include "../main.hh" // required for uint8_t, real_64_t, ..., and the macros INT8_MAX, REAL32_MAX, ... */
be9ba3531afb cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents: 572
diff changeset
    55
be9ba3531afb cleaning up code. Changing HUGE_VAL to INFINITY.
Mario de Sousa <msousa@fe.up.pt>
parents: 572
diff changeset
    56
568
5f79478142d7 make the compiler platform independent (i.e. no longer assume sizeof(double)==8).
Mario de Sousa <msousa@fe.up.pt>
parents: 565
diff changeset
    57
5f79478142d7 make the compiler platform independent (i.e. no longer assume sizeof(double)==8).
Mario de Sousa <msousa@fe.up.pt>
parents: 565
diff changeset
    58
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    59
/* Forward declaration of the visitor interface
564
dabffc3086dc Start constant_folding class.
Manuele Conti <conti.ma@alice.it>
parents: 459
diff changeset
    60
 * declared in the visitor.hh file
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    61
 * We cannot include the visitor.hh file, as it will
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    62
 * include this same file first, as it too requires references
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    63
 * to the abstract syntax classes defined here.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    64
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    65
class visitor_c; // forward declaration
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    66
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    67
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    68
class symbol_c; // forward declaration
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
569
0d1ab9e78574 Add data structure for storing overflow of constant values.
Mario de Sousa <msousa@fe.up.pt>
parents: 568
diff changeset
    71
0d1ab9e78574 Add data structure for storing overflow of constant values.
Mario de Sousa <msousa@fe.up.pt>
parents: 568
diff changeset
    72
0d1ab9e78574 Add data structure for storing overflow of constant values.
Mario de Sousa <msousa@fe.up.pt>
parents: 568
diff changeset
    73
0d1ab9e78574 Add data structure for storing overflow of constant values.
Mario de Sousa <msousa@fe.up.pt>
parents: 568
diff changeset
    74
0d1ab9e78574 Add data structure for storing overflow of constant values.
Mario de Sousa <msousa@fe.up.pt>
parents: 568
diff changeset
    75
738
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
    76
/* Case insensitive string compare */
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
    77
  /* Case insensitive string compare copied from
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
    78
   * "The C++ Programming Language" - 3rd Edition
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
    79
   * by Bjarne Stroustrup, ISBN 0201889544.
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
    80
   */
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
    81
class nocasecmp_c {
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
    82
    public:
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
    83
      bool operator() (const std::string& x, const std::string& y) const {
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
    84
        std::string::const_iterator ix = x.begin();
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
    85
        std::string::const_iterator iy = y.begin();
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
    86
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
    87
        for(; (ix != x.end()) && (iy != y.end()) && (toupper(*ix) == toupper(*iy)); ++ix, ++iy);
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
    88
        if (ix == x.end()) return (iy != y.end());
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
    89
        if (iy == y.end()) return false;
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
    90
        return (toupper(*ix) < toupper(*iy));
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
    91
      };
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
    92
  };
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
    93
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
    94
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
    95
965
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
    96
/*** constant folding ***/
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
    97
/* During stage 3 (semantic analysis/checking) we will be doing constant folding.
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
    98
 * That algorithm will anotate the abstract syntax tree with the result of operations
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
    99
 * on literals (i.e. 44 + 55 will store the result 99).
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   100
 * Since the same source code (e.g. 1 + 0) may actually be a BOOL or an ANY_INT,
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   101
 * or an ANY_BIT, we need to handle all possibilities, and determine the result of the
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   102
 * operation assuming each type.
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   103
 * For this reason, we have one entry for each possible type, with some expressions
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   104
 * having more than one entry filled in!
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   105
 */    
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   106
class const_value_c {
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   107
  public:
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   108
    typedef enum { cs_undefined,   /* not defined/not yet evaluated --> const_value is not valid! */
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   109
                   cs_non_const,   /* we have determined that expression is not a const value --> const_value is not valid! */
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   110
                   cs_const_value, /* const value is valid */
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   111
                   cs_overflow     /* result produced overflow or underflow --> const_value is not valid! */
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   112
                 } const_status_t;
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   113
 
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   114
    template<typename value_type> class const_value__ {
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   115
      const_status_t status;  
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   116
      value_type     value;
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   117
      
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   118
      public:
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   119
      const_value__(void): status(cs_undefined), value(0) {};
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   120
      
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   121
      value_type get(void)              {return value;}
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   122
      void       set(value_type value_) {status = cs_const_value; value = value_;}
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   123
      void       set_overflow(void)     {status = cs_overflow   ;}
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   124
      void       set_nonconst(void)     {status = cs_non_const  ;}
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   125
      bool       is_valid    (void)     {return (status == cs_const_value);}
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   126
      bool       is_overflow (void)     {return (status == cs_overflow   );}
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   127
      bool       is_nonconst (void)     {return (status == cs_non_const  );}
978
efab3a94d3c0 Add is_undefined() method to const_value_c
mjsousa
parents: 965
diff changeset
   128
      bool       is_undefined(void)     {return (status == cs_undefined  );}
965
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   129
      bool       is_zero     (void)     {return (is_valid() && (get() == 0));}
983
ead554e12195 Add check whether the same constant var_external variable is initialised with two (or more) different constant values.
mjsousa
parents: 978
diff changeset
   130
ead554e12195 Add check whether the same constant var_external variable is initialised with two (or more) different constant values.
mjsousa
parents: 978
diff changeset
   131
      /* comparison operator */
ead554e12195 Add check whether the same constant var_external variable is initialised with two (or more) different constant values.
mjsousa
parents: 978
diff changeset
   132
      bool operator==(const const_value__ cv) {
ead554e12195 Add check whether the same constant var_external variable is initialised with two (or more) different constant values.
mjsousa
parents: 978
diff changeset
   133
        return (    ((status!=cs_const_value) && (status==cv.status)) 
ead554e12195 Add check whether the same constant var_external variable is initialised with two (or more) different constant values.
mjsousa
parents: 978
diff changeset
   134
                 || ((status==cs_const_value) && (value ==cv.value )));
ead554e12195 Add check whether the same constant var_external variable is initialised with two (or more) different constant values.
mjsousa
parents: 978
diff changeset
   135
      }
ead554e12195 Add check whether the same constant var_external variable is initialised with two (or more) different constant values.
mjsousa
parents: 978
diff changeset
   136
965
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   137
    };
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   138
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   139
    const_value__< int64_t>  _int64; /* status is initialised to UNDEFINED */
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   140
    const_value__<uint64_t> _uint64; /* status is initialised to UNDEFINED */
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   141
    const_value__<real64_t> _real64; /* status is initialised to UNDEFINED */
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   142
    const_value__<bool    >   _bool; /* status is initialised to UNDEFINED */
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   143
    
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   144
    /* default constructor and destructor */
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   145
     const_value_c(void) {};
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   146
    ~const_value_c(void) {};
983
ead554e12195 Add check whether the same constant var_external variable is initialised with two (or more) different constant values.
mjsousa
parents: 978
diff changeset
   147
    
ead554e12195 Add check whether the same constant var_external variable is initialised with two (or more) different constant values.
mjsousa
parents: 978
diff changeset
   148
    /* comparison operator */
ead554e12195 Add check whether the same constant var_external variable is initialised with two (or more) different constant values.
mjsousa
parents: 978
diff changeset
   149
    bool operator==(const const_value_c cv)
ead554e12195 Add check whether the same constant var_external variable is initialised with two (or more) different constant values.
mjsousa
parents: 978
diff changeset
   150
      {return ((_int64==cv._int64) && (_uint64==cv._uint64) && (_real64==cv._real64) && (_bool==cv._bool));}                                                     
1000
556b74055518 Add check for repeated elements in a CASE statement. Emit warnings (and not errors) if found.
mjsousa
parents: 983
diff changeset
   151
      
556b74055518 Add check for repeated elements in a CASE statement. Emit warnings (and not errors) if found.
mjsousa
parents: 983
diff changeset
   152
    /* return true if at least one of the const values (int, real, ...) is a valid const value */
556b74055518 Add check for repeated elements in a CASE statement. Emit warnings (and not errors) if found.
mjsousa
parents: 983
diff changeset
   153
    bool is_const(void) 
556b74055518 Add check for repeated elements in a CASE statement. Emit warnings (and not errors) if found.
mjsousa
parents: 983
diff changeset
   154
      {return (_int64.is_valid() || _uint64.is_valid() || _real64.is_valid() || _bool.is_valid());}   
965
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   155
};
569
0d1ab9e78574 Add data structure for storing overflow of constant values.
Mario de Sousa <msousa@fe.up.pt>
parents: 568
diff changeset
   156
0d1ab9e78574 Add data structure for storing overflow of constant values.
Mario de Sousa <msousa@fe.up.pt>
parents: 568
diff changeset
   157
0d1ab9e78574 Add data structure for storing overflow of constant values.
Mario de Sousa <msousa@fe.up.pt>
parents: 568
diff changeset
   158
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   159
/* The base class of all symbols */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   160
class symbol_c {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   161
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   162
  public:
659
165aa7b87e0d add method for printing class_name. USE ONLY FOR DEBUGING!
Mario de Sousa <msousa@fe.up.pt>
parents: 655
diff changeset
   163
    /* WARNING: only use this method for debugging purposes!! */
165aa7b87e0d add method for printing class_name. USE ONLY FOR DEBUGING!
Mario de Sousa <msousa@fe.up.pt>
parents: 655
diff changeset
   164
    virtual const char *absyntax_cname(void) {return "symbol_c";};
165aa7b87e0d add method for printing class_name. USE ONLY FOR DEBUGING!
Mario de Sousa <msousa@fe.up.pt>
parents: 655
diff changeset
   165
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   166
    /*
913
1c74da17cb61 Implicitly defined array datatypes use new naming method (greatly simplifies stage 4 code).
mjsousa
parents: 889
diff changeset
   167
     * Annotations produced during stage 1_2
1c74da17cb61 Implicitly defined array datatypes use new naming method (greatly simplifies stage 4 code).
mjsousa
parents: 889
diff changeset
   168
     */    
936
0f7bcc160568 Fix bug: Add support for de-referencing pointers to struct (struct_ptr^.elem1) when used inside FB.
mjsousa
parents: 913
diff changeset
   169
    /* Points to the parent symbol in the AST, i.e. the symbol in the AST that will contain the current symbol */
0f7bcc160568 Fix bug: Add support for de-referencing pointers to struct (struct_ptr^.elem1) when used inside FB.
mjsousa
parents: 913
diff changeset
   170
    symbol_c *parent; 
0f7bcc160568 Fix bug: Add support for de-referencing pointers to struct (struct_ptr^.elem1) when used inside FB.
mjsousa
parents: 913
diff changeset
   171
    
913
1c74da17cb61 Implicitly defined array datatypes use new naming method (greatly simplifies stage 4 code).
mjsousa
parents: 889
diff changeset
   172
    /* Line number for the purposes of error checking.  */
69
41cb5b80416e Adding basic error checking.
mario
parents: 0
diff changeset
   173
    int first_line;
41cb5b80416e Adding basic error checking.
mario
parents: 0
diff changeset
   174
    int first_column;
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   175
    const char *first_file;  /* filename referenced by first line/column */
287
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   176
    long int first_order;    /* relative order in which it is read by lexcial analyser */
69
41cb5b80416e Adding basic error checking.
mario
parents: 0
diff changeset
   177
    int last_line;
41cb5b80416e Adding basic error checking.
mario
parents: 0
diff changeset
   178
    int last_column;
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   179
    const char *last_file;  /* filename referenced by last line/column */
287
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   180
    long int last_order;    /* relative order in which it is read by lexcial analyser */
569
0d1ab9e78574 Add data structure for storing overflow of constant values.
Mario de Sousa <msousa@fe.up.pt>
parents: 568
diff changeset
   181
0d1ab9e78574 Add data structure for storing overflow of constant values.
Mario de Sousa <msousa@fe.up.pt>
parents: 568
diff changeset
   182
0d1ab9e78574 Add data structure for storing overflow of constant values.
Mario de Sousa <msousa@fe.up.pt>
parents: 568
diff changeset
   183
    /*
0d1ab9e78574 Add data structure for storing overflow of constant values.
Mario de Sousa <msousa@fe.up.pt>
parents: 568
diff changeset
   184
     * Annotations produced during stage 3
738
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
   185
     */    
569
0d1ab9e78574 Add data structure for storing overflow of constant values.
Mario de Sousa <msousa@fe.up.pt>
parents: 568
diff changeset
   186
    /*** Data type analysis ***/
417
d48f53715f77 Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents: 350
diff changeset
   187
    std::vector <symbol_c *> candidate_datatypes; /* All possible data types the expression/literal/etc. may take. Filled in stage3 by fill_candidate_datatypes_c class */
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 438
diff changeset
   188
    /* Data type of the expression/literal/etc. Filled in stage3 by narrow_candidate_datatypes_c 
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 438
diff changeset
   189
     * If set to NULL, it means it has not yet been evaluated.
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 438
diff changeset
   190
     * If it points to an object of type invalid_type_name_c, it means it is invalid.
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 438
diff changeset
   191
     * Otherwise, it points to an object of the apropriate data type (e.g. int_type_name_c, bool_type_name_c, ...)
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 438
diff changeset
   192
     */
564
dabffc3086dc Start constant_folding class.
Manuele Conti <conti.ma@alice.it>
parents: 459
diff changeset
   193
    symbol_c *datatype;
889
5f380b99e95e Correctly handle structured variables that include FB and external FBs (example: FB1.FB2.extFB3.FB4.extFB5.extFB6.structvar.field1 := 42;) (this commit fixes only ST code. TODO: IL and SFC)
mjsousa
parents: 775
diff changeset
   194
    /* The POU in which the symbolic variable (or structured variable, or array variable, or located variable, - any more?)
5f380b99e95e Correctly handle structured variables that include FB and external FBs (example: FB1.FB2.extFB3.FB4.extFB5.extFB6.structvar.field1 := 42;) (this commit fixes only ST code. TODO: IL and SFC)
mjsousa
parents: 775
diff changeset
   195
     * was declared. This will point to a Configuration, Resource, Program, FB, or Function.
938
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 936
diff changeset
   196
     * This is set in stage 3 by the datatype analyser algorithm (fill/narrow) for the symbols:
31e3b3f2eff1 Do the full fill_candidate/narrow_datatype algorithm for all fields of a structured variable in the fill_candidate_datatypes_c
mjsousa
parents: 936
diff changeset
   197
     *  symbolic_variable_c, array_variable_c, structured_variable_c
889
5f380b99e95e Correctly handle structured variables that include FB and external FBs (example: FB1.FB2.extFB3.FB4.extFB5.extFB6.structvar.field1 := 42;) (this commit fixes only ST code. TODO: IL and SFC)
mjsousa
parents: 775
diff changeset
   198
     */
5f380b99e95e Correctly handle structured variables that include FB and external FBs (example: FB1.FB2.extFB3.FB4.extFB5.extFB6.structvar.field1 := 42;) (this commit fixes only ST code. TODO: IL and SFC)
mjsousa
parents: 775
diff changeset
   199
    symbol_c *scope;    
564
dabffc3086dc Start constant_folding class.
Manuele Conti <conti.ma@alice.it>
parents: 459
diff changeset
   200
569
0d1ab9e78574 Add data structure for storing overflow of constant values.
Mario de Sousa <msousa@fe.up.pt>
parents: 568
diff changeset
   201
    /*** constant folding ***/
965
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   202
    /* If the symbol has a constant numerical value, this will be set to that value by constant_folding_c */
c9eeb67ba939 Small code re-organization of how const values are stored in symbol_c (can now be accessed through member functions, instead of macros)
mjsousa
parents: 958
diff changeset
   203
    const_value_c const_value;
569
0d1ab9e78574 Add data structure for storing overflow of constant values.
Mario de Sousa <msousa@fe.up.pt>
parents: 568
diff changeset
   204
    
738
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
   205
    /*** Enumeration datatype checking ***/    
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
   206
    /* Not all symbols will contain the following anotations, which is why they are not declared here in symbol_c
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
   207
     * They will be declared only inside the symbols that require them (have a look at absyntax.def)
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
   208
     */
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
   209
    typedef std::multimap<std::string, symbol_c *, nocasecmp_c> enumvalue_symtable_t;
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
   210
    
913
1c74da17cb61 Implicitly defined array datatypes use new naming method (greatly simplifies stage 4 code).
mjsousa
parents: 889
diff changeset
   211
    /*
1c74da17cb61 Implicitly defined array datatypes use new naming method (greatly simplifies stage 4 code).
mjsousa
parents: 889
diff changeset
   212
     * Annotations produced during stage 4
1c74da17cb61 Implicitly defined array datatypes use new naming method (greatly simplifies stage 4 code).
mjsousa
parents: 889
diff changeset
   213
     */
1c74da17cb61 Implicitly defined array datatypes use new naming method (greatly simplifies stage 4 code).
mjsousa
parents: 889
diff changeset
   214
    /* Since we support several distinct stage_4 implementations, having explicit entries for each
1c74da17cb61 Implicitly defined array datatypes use new naming method (greatly simplifies stage 4 code).
mjsousa
parents: 889
diff changeset
   215
     * possible use would quickly get out of hand.
1c74da17cb61 Implicitly defined array datatypes use new naming method (greatly simplifies stage 4 code).
mjsousa
parents: 889
diff changeset
   216
     * We therefore simply add a map, that each stage 4 may use for all its needs.
1c74da17cb61 Implicitly defined array datatypes use new naming method (greatly simplifies stage 4 code).
mjsousa
parents: 889
diff changeset
   217
     */
1c74da17cb61 Implicitly defined array datatypes use new naming method (greatly simplifies stage 4 code).
mjsousa
parents: 889
diff changeset
   218
    typedef std::map<std::string, symbol_c *> anotations_map_t;
1c74da17cb61 Implicitly defined array datatypes use new naming method (greatly simplifies stage 4 code).
mjsousa
parents: 889
diff changeset
   219
    anotations_map_t anotations_map;
1c74da17cb61 Implicitly defined array datatypes use new naming method (greatly simplifies stage 4 code).
mjsousa
parents: 889
diff changeset
   220
    
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   221
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   222
  public:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   223
    /* default constructor */
287
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   224
    symbol_c(int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0, /* order in which it is read by lexcial analyser */
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   225
             int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0  /* order in which it is read by lexcial analyser */
69
41cb5b80416e Adding basic error checking.
mario
parents: 0
diff changeset
   226
            );
0
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
    /* default destructor */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   229
    /* must be virtual so compiler does not complain... */ 
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   230
    virtual ~symbol_c(void) {return;};
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
    virtual void *accept(visitor_c &visitor) {return NULL;};
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   233
};
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
738
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
   236
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
   237
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   238
class token_c: public symbol_c {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   239
  public:
659
165aa7b87e0d add method for printing class_name. USE ONLY FOR DEBUGING!
Mario de Sousa <msousa@fe.up.pt>
parents: 655
diff changeset
   240
    /* WARNING: only use this method for debugging purposes!! */
165aa7b87e0d add method for printing class_name. USE ONLY FOR DEBUGING!
Mario de Sousa <msousa@fe.up.pt>
parents: 655
diff changeset
   241
    virtual const char *absyntax_cname(void) {return "token_c";};
165aa7b87e0d add method for printing class_name. USE ONLY FOR DEBUGING!
Mario de Sousa <msousa@fe.up.pt>
parents: 655
diff changeset
   242
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   243
    /* the value of the symbol. */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   244
    const char *value;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   245
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   246
  public:
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   247
    token_c(const char *value, 
287
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   248
            int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0, /* order in which it is read by lexcial analyser */
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   249
            int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0  /* order in which it is read by lexcial analyser */
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   250
           );
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   251
};
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   252
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   253
738
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
   254
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
   255
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   256
 /* a list 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
   257
class list_c: public symbol_c {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   258
  public:
659
165aa7b87e0d add method for printing class_name. USE ONLY FOR DEBUGING!
Mario de Sousa <msousa@fe.up.pt>
parents: 655
diff changeset
   259
    /* WARNING: only use this method for debugging purposes!! */
165aa7b87e0d add method for printing class_name. USE ONLY FOR DEBUGING!
Mario de Sousa <msousa@fe.up.pt>
parents: 655
diff changeset
   260
    virtual const char *absyntax_cname(void) {return "list_c";};
165aa7b87e0d add method for printing class_name. USE ONLY FOR DEBUGING!
Mario de Sousa <msousa@fe.up.pt>
parents: 655
diff changeset
   261
655
a77514dd0040 Adjust coding style.
Mario de Sousa <msousa@fe.up.pt>
parents: 654
diff changeset
   262
    int c,n; /* c: current capacity of list (malloc'd memory);  n: current number of elements in list */
1041
56ebe2a31b5b Access elements[] in list_c through a new get_element() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 1000
diff changeset
   263
  private:
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   264
    symbol_c **elements;
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
  public:
287
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   267
    list_c(int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0, /* order in which it is read by lexcial analyser */
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   268
           int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0  /* order in which it is read by lexcial analyser */
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   269
          );
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   270
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   271
    list_c(symbol_c *elem, 
287
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   272
           int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0, /* order in which it is read by lexcial analyser */
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   273
           int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0  /* order in which it is read by lexcial analyser */
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   274
          );
1041
56ebe2a31b5b Access elements[] in list_c through a new get_element() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 1000
diff changeset
   275
     /* get element in position pos of the list */
56ebe2a31b5b Access elements[] in list_c through a new get_element() method.
Mario de Sousa <msousa@fe.up.pt>
parents: 1000
diff changeset
   276
    virtual symbol_c *get_element(int pos);
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   277
     /* append a new element to the end of the list */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   278
    virtual void add_element(symbol_c *elem);
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   279
     /* insert a new element before position pos. */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   280
     /* To insert into the begining of list, call with pos=0  */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   281
     /* To insert into the end of list, call with pos=list->n */
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   282
    virtual void insert_element(symbol_c *elem, int pos = 0);
438
744b125d911e Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
   283
     /* remove element at position pos. */
744b125d911e Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents: 417
diff changeset
   284
    virtual void remove_element(int pos = 0);
958
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 938
diff changeset
   285
     /* remove all elements from list. Does not delete the elements in the list! */ 
7474d2cd1d6e Add a new pou_typename_c object to the AST to store references to previously declared Functions, FB, and Programs.
mjsousa
parents: 938
diff changeset
   286
    virtual void clear(void);
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   287
};
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   288
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   289
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   290
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   291
738
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
   292
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
   293
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
   294
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
   295
e47cc8c954db Start to move enumeration declaration checking to its own class.
Mario de Sousa <msousa@fe.up.pt>
parents: 659
diff changeset
   296
568
5f79478142d7 make the compiler platform independent (i.e. no longer assume sizeof(double)==8).
Mario de Sousa <msousa@fe.up.pt>
parents: 565
diff changeset
   297
#define SYM_LIST(class_name_c, ...)											\
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   298
class class_name_c:	public list_c {											\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   299
  public:														\
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   300
    __VA_ARGS__														\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   301
  public:														\
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   302
    class_name_c(													\
287
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   303
                 int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   304
                 int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   305
    class_name_c(symbol_c *elem, 											\
287
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   306
                 int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   307
                 int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   308
    virtual void *accept(visitor_c &visitor);										\
659
165aa7b87e0d add method for printing class_name. USE ONLY FOR DEBUGING!
Mario de Sousa <msousa@fe.up.pt>
parents: 655
diff changeset
   309
    /* WARNING: only use this method for debugging purposes!! */							\
165aa7b87e0d add method for printing class_name. USE ONLY FOR DEBUGING!
Mario de Sousa <msousa@fe.up.pt>
parents: 655
diff changeset
   310
    virtual const char *absyntax_cname(void) {return #class_name_c;};							\
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   311
};
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   312
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   313
568
5f79478142d7 make the compiler platform independent (i.e. no longer assume sizeof(double)==8).
Mario de Sousa <msousa@fe.up.pt>
parents: 565
diff changeset
   314
#define SYM_TOKEN(class_name_c, ...)											\
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   315
class class_name_c: 	public token_c {										\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   316
  public:														\
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   317
    __VA_ARGS__														\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   318
  public:														\
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   319
    class_name_c(const char *value, 											\
287
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   320
                 int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   321
                 int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   322
    virtual void *accept(visitor_c &visitor);										\
659
165aa7b87e0d add method for printing class_name. USE ONLY FOR DEBUGING!
Mario de Sousa <msousa@fe.up.pt>
parents: 655
diff changeset
   323
    /* WARNING: only use this method for debugging purposes!! */							\
165aa7b87e0d add method for printing class_name. USE ONLY FOR DEBUGING!
Mario de Sousa <msousa@fe.up.pt>
parents: 655
diff changeset
   324
    virtual const char *absyntax_cname(void) {return #class_name_c;};							\
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   325
};
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   326
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   327
568
5f79478142d7 make the compiler platform independent (i.e. no longer assume sizeof(double)==8).
Mario de Sousa <msousa@fe.up.pt>
parents: 565
diff changeset
   328
#define SYM_REF0(class_name_c, ...)											\
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   329
class class_name_c: public symbol_c {											\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   330
  public:														\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   331
    __VA_ARGS__														\
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   332
  public:														\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   333
    class_name_c(		 											\
287
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   334
                 int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   335
                 int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   336
    virtual void *accept(visitor_c &visitor);										\
659
165aa7b87e0d add method for printing class_name. USE ONLY FOR DEBUGING!
Mario de Sousa <msousa@fe.up.pt>
parents: 655
diff changeset
   337
    /* WARNING: only use this method for debugging purposes!! */							\
165aa7b87e0d add method for printing class_name. USE ONLY FOR DEBUGING!
Mario de Sousa <msousa@fe.up.pt>
parents: 655
diff changeset
   338
    virtual const char *absyntax_cname(void) {return #class_name_c;};							\
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   339
};
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   340
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   341
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   342
#define SYM_REF1(class_name_c, ref1, ...)										\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   343
class class_name_c: public symbol_c {											\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   344
  public:														\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   345
    symbol_c *ref1;													\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   346
    __VA_ARGS__														\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   347
  public:														\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   348
    class_name_c(symbol_c *ref1,											\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   349
                 int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   350
                 int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   351
    virtual void *accept(visitor_c &visitor);										\
659
165aa7b87e0d add method for printing class_name. USE ONLY FOR DEBUGING!
Mario de Sousa <msousa@fe.up.pt>
parents: 655
diff changeset
   352
    /* WARNING: only use this method for debugging purposes!! */							\
165aa7b87e0d add method for printing class_name. USE ONLY FOR DEBUGING!
Mario de Sousa <msousa@fe.up.pt>
parents: 655
diff changeset
   353
    virtual const char *absyntax_cname(void) {return #class_name_c;};							\
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   354
};
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   355
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   356
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   357
#define SYM_REF2(class_name_c, ref1, ref2, ...)										\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   358
class class_name_c: public symbol_c {											\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   359
  public:														\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   360
    symbol_c *ref1;													\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   361
    symbol_c *ref2;													\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   362
    __VA_ARGS__														\
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   363
  public:														\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   364
    class_name_c(symbol_c *ref1,											\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   365
		 symbol_c *ref2 = NULL,											\
287
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   366
                 int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   367
                 int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   368
    virtual void *accept(visitor_c &visitor);										\
659
165aa7b87e0d add method for printing class_name. USE ONLY FOR DEBUGING!
Mario de Sousa <msousa@fe.up.pt>
parents: 655
diff changeset
   369
    /* WARNING: only use this method for debugging purposes!! */							\
165aa7b87e0d add method for printing class_name. USE ONLY FOR DEBUGING!
Mario de Sousa <msousa@fe.up.pt>
parents: 655
diff changeset
   370
    virtual const char *absyntax_cname(void) {return #class_name_c;};							\
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   371
};
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   372
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   373
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   374
#define SYM_REF3(class_name_c, ref1, ref2, ref3, ...)									\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   375
class class_name_c: public symbol_c {											\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   376
  public:														\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   377
    symbol_c *ref1;													\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   378
    symbol_c *ref2;													\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   379
    symbol_c *ref3;													\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   380
    __VA_ARGS__														\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   381
  public:														\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   382
    class_name_c(symbol_c *ref1,											\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   383
		 symbol_c *ref2,											\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   384
		 symbol_c *ref3,											\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   385
                 int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   386
                 int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   387
    virtual void *accept(visitor_c &visitor);										\
659
165aa7b87e0d add method for printing class_name. USE ONLY FOR DEBUGING!
Mario de Sousa <msousa@fe.up.pt>
parents: 655
diff changeset
   388
    /* WARNING: only use this method for debugging purposes!! */							\
165aa7b87e0d add method for printing class_name. USE ONLY FOR DEBUGING!
Mario de Sousa <msousa@fe.up.pt>
parents: 655
diff changeset
   389
    virtual const char *absyntax_cname(void) {return #class_name_c;};							\
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   390
};
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   391
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   392
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   393
#define SYM_REF4(class_name_c, ref1, ref2, ref3, ref4, ...)								\
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   394
class class_name_c: public symbol_c {											\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   395
  public:														\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   396
    symbol_c *ref1;													\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   397
    symbol_c *ref2;													\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   398
    symbol_c *ref3;													\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   399
    symbol_c *ref4;													\
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   400
    __VA_ARGS__														\
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   401
  public:														\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   402
    class_name_c(symbol_c *ref1,											\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   403
		 symbol_c *ref2,											\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   404
		 symbol_c *ref3,											\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   405
		 symbol_c *ref4 = NULL,											\
287
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   406
                 int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   407
                 int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   408
    virtual void *accept(visitor_c &visitor);										\
659
165aa7b87e0d add method for printing class_name. USE ONLY FOR DEBUGING!
Mario de Sousa <msousa@fe.up.pt>
parents: 655
diff changeset
   409
    /* WARNING: only use this method for debugging purposes!! */							\
165aa7b87e0d add method for printing class_name. USE ONLY FOR DEBUGING!
Mario de Sousa <msousa@fe.up.pt>
parents: 655
diff changeset
   410
    virtual const char *absyntax_cname(void) {return #class_name_c;};							\
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   411
};
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   412
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   413
568
5f79478142d7 make the compiler platform independent (i.e. no longer assume sizeof(double)==8).
Mario de Sousa <msousa@fe.up.pt>
parents: 565
diff changeset
   414
#define SYM_REF5(class_name_c, ref1, ref2, ref3, ref4, ref5, ...)							\
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   415
class class_name_c: public symbol_c {											\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   416
  public:														\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   417
    symbol_c *ref1;													\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   418
    symbol_c *ref2;													\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   419
    symbol_c *ref3;													\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   420
    symbol_c *ref4;													\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   421
    symbol_c *ref5;													\
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   422
    __VA_ARGS__														\
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   423
  public:														\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   424
    class_name_c(symbol_c *ref1,											\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   425
		 symbol_c *ref2,											\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   426
		 symbol_c *ref3,											\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   427
		 symbol_c *ref4,											\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   428
		 symbol_c *ref5,											\
287
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   429
                 int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   430
                 int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   431
    virtual void *accept(visitor_c &visitor);										\
659
165aa7b87e0d add method for printing class_name. USE ONLY FOR DEBUGING!
Mario de Sousa <msousa@fe.up.pt>
parents: 655
diff changeset
   432
    /* WARNING: only use this method for debugging purposes!! */							\
165aa7b87e0d add method for printing class_name. USE ONLY FOR DEBUGING!
Mario de Sousa <msousa@fe.up.pt>
parents: 655
diff changeset
   433
    virtual const char *absyntax_cname(void) {return #class_name_c;};							\
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   434
};
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   435
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   436
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   437
#define SYM_REF6(class_name_c, ref1, ref2, ref3, ref4, ref5, ref6, ...)							\
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   438
class class_name_c: public symbol_c {											\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   439
  public:														\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   440
    symbol_c *ref1;													\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   441
    symbol_c *ref2;													\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   442
    symbol_c *ref3;													\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   443
    symbol_c *ref4;													\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   444
    symbol_c *ref5;													\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   445
    symbol_c *ref6;													\
350
2c3c4dc34979 Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents: 287
diff changeset
   446
    __VA_ARGS__														\
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   447
  public:														\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   448
    class_name_c(symbol_c *ref1,											\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   449
		 symbol_c *ref2,											\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   450
		 symbol_c *ref3,											\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   451
		 symbol_c *ref4,											\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   452
		 symbol_c *ref5,											\
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   453
		 symbol_c *ref6 = NULL,											\
287
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   454
                 int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0,			\
9df7fcb9bde5 Added tracking of order by which tokens are processed by lexical analyser.
Mario de Sousa <msousa@fe.up.pt>
parents: 286
diff changeset
   455
                 int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0);			\
286
a4f4990d5c66 Adding tracking of filename in which token is located.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   456
    virtual void *accept(visitor_c &visitor);										\
659
165aa7b87e0d add method for printing class_name. USE ONLY FOR DEBUGING!
Mario de Sousa <msousa@fe.up.pt>
parents: 655
diff changeset
   457
    /* WARNING: only use this method for debugging purposes!! */							\
165aa7b87e0d add method for printing class_name. USE ONLY FOR DEBUGING!
Mario de Sousa <msousa@fe.up.pt>
parents: 655
diff changeset
   458
    virtual const char *absyntax_cname(void) {return #class_name_c;};							\
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   459
};
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   460
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   461
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   462
#include "absyntax.def"
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
#undef SYM_LIST
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   467
#undef SYM_TOKEN
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   468
#undef SYM_REF0
69
41cb5b80416e Adding basic error checking.
mario
parents: 0
diff changeset
   469
#undef SYM_REF1
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   470
#undef SYM_REF2
69
41cb5b80416e Adding basic error checking.
mario
parents: 0
diff changeset
   471
#undef SYM_REF3
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   472
#undef SYM_REF4
69
41cb5b80416e Adding basic error checking.
mario
parents: 0
diff changeset
   473
#undef SYM_REF5
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   474
#undef SYM_REF6
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   475
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   476
#endif /*  _ABSYNTAX_HH */