absyntax_utils/search_il_operand_type.hh
author Mario de Sousa <msousa@fe.up.pt>
Thu, 14 Apr 2011 18:12:59 +0100
changeset 287 9df7fcb9bde5
parent 279 c0453b7f99df
child 294 aae14da3c296
permissions -rwxr-xr-x
Added tracking of order by which tokens are processed by lexical analyser.
This helps in correctly formating error messages when constructs begin in one file, and end in another.
201
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
     1
/*
265
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
     2
 *  matiec - a compiler for the programming languages defined in IEC 61131-3
201
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
     3
 *
265
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 202
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: 265
diff changeset
     5
 *  Copyright (C) 2007-2011  Laurent Bessard and Edouard Tisserant
201
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
     6
 *
265
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
     7
 *  This program is free software: you can redistribute it and/or modify
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
     8
 *  it under the terms of the GNU General Public License as published by
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
     9
 *  the Free Software Foundation, either version 3 of the License, or
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
    10
 *  (at your option) any later version.
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
    11
 *
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
    12
 *  This program is distributed in the hope that it will be useful,
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
    13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
    14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
    15
 *  GNU General Public License for more details.
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
    16
 *
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
    17
 *  You should have received a copy of the GNU General Public License
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
    18
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
    19
 *
201
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    20
 *
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    21
 * This code is made available on the understanding that it will not be
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    22
 * used in safety-critical situations without a full and competent review.
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    23
 */
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    24
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    25
/*
265
4d222f46f8cc Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents: 202
diff changeset
    26
 * An IEC 61131-3 compiler.
201
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    27
 *
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    28
 * Based on the
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    29
 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    30
 *
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    31
 */
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    32
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    33
/* Returns the data type of an il_operand.
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    34
 *
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    35
 * Note that the il_operand may be a variable, in which case
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    36
 * we return the type of the variable instance.
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    37
 * The il_operand may also be a constant, in which case
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    38
 * we return the data type of that constant.
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    39
 *
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    40
 * The variable instance may be a member of a structured variable,
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    41
 * or an element in an array, or any combination of the two.
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    42
 *
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    43
 * The class constructor must be given the search scope
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    44
 * (function, function block or program within which
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    45
 * the possible il_operand variable instance was declared).
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    46
 */
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    47
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    48
class search_il_operand_type_c {
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    49
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    50
  private:
202
da1a8186f86f Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents: 201
diff changeset
    51
  search_varfb_instance_type_c::search_varfb_instance_type_c search_varfb_instance_type;
201
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    52
    search_constant_type_c search_constant_type;
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    53
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    54
  public:
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    55
    search_il_operand_type_c(symbol_c *search_scope): search_varfb_instance_type(search_scope) {}
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    56
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    57
  public:
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    58
    symbol_c *get_type(symbol_c *il_operand);
e657008f43d0 Introducing the search_il_operand_type files in the absyntax_utils folder.
Catarina Boucinha <ccb@fe.up.pt>
parents:
diff changeset
    59
};