stage3/forced_narrow_candidate_datatypes.hh
author mjsousa
Sat, 07 May 2016 21:17:49 +0100
changeset 1010 242907849850
parent 691 958454e9e40f
child 1054 57c08195c962
permissions -rw-r--r--
Correctly identify errors when parsing erroneous code (make sure flex goes back to INITIAL state when code contains errors that do not allow determining whether ST or IL is being parsed)
677
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     1
/*
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     2
 *  matiec - a compiler for the programming languages defined in IEC 61131-3
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     3
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     4
 *  Copyright (C) 2012  Mario de Sousa (msousa@fe.up.pt)
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     5
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     6
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     7
 *  This program is free software: you can redistribute it and/or modify
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     8
 *  it under the terms of the GNU General Public License as published by
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     9
 *  the Free Software Foundation, either version 3 of the License, or
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    10
 *  (at your option) any later version.
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    11
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    12
 *  This program is distributed in the hope that it will be useful,
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    15
 *  GNU General Public License for more details.
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    16
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    17
 *  You should have received a copy of the GNU General Public License
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    18
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    19
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    20
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    21
 * This code is made available on the understanding that it will not be
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    22
 * used in safety-critical situations without a full and competent review.
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    23
 */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    24
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    25
/*
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    26
 * An IEC 61131-3 compiler.
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    27
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    28
 * Based on the
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    29
 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    30
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    31
 */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    32
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    33
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    34
/*
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    35
 *  forced_narrow_candidate_datatypes_c
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    36
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    37
 */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    38
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    39
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    40
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    41
#include "../absyntax_utils/absyntax_utils.hh"
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    42
#include "narrow_candidate_datatypes.hh"
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    43
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    44
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    45
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    46
class forced_narrow_candidate_datatypes_c: public narrow_candidate_datatypes_c {
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    47
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    48
  private:
691
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 681
diff changeset
    49
    void forced_narrow_il_instruction(symbol_c *symbol, std::vector <symbol_c *> &next_il_instruction);
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 681
diff changeset
    50
    
677
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    51
  public:
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    52
    forced_narrow_candidate_datatypes_c(symbol_c *ignore);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    53
    virtual ~forced_narrow_candidate_datatypes_c(void);
691
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 681
diff changeset
    54
   
677
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    55
    /****************************************/
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    56
    /* B.2 - Language IL (Instruction List) */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    57
    /****************************************/
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    58
    /***********************************/
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    59
    /* B 2.1 Instructions and Operands */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    60
    /***********************************/
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    61
    void *visit(instruction_list_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    62
    void *visit(il_instruction_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    63
//  void *visit(il_simple_operation_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    64
//  void *visit(il_function_call_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    65
//  void *visit(il_expression_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    66
//  void *visit(il_jump_operation_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    67
//  void *visit(il_fb_call_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    68
//  void *visit(il_formal_funct_call_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    69
//  void *visit(il_operand_list_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    70
//  void *visit(simple_instr_list_c *symbol);
691
958454e9e40f Also force_narrow IL instructions inside IL expressions, i.e. inside parenthesis.
Mario de Sousa <msousa@fe.up.pt>
parents: 681
diff changeset
    71
    void *visit(il_simple_instruction_c*symbol);
677
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    72
//  void *visit(il_param_list_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    73
//  void *visit(il_param_assignment_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    74
//  void *visit(il_param_out_assignment_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    75
//  void *visit(il_assign_operator_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    76
//  void *visit(il_assign_operator_c *symbol);
681
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 677
diff changeset
    77
 
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 677
diff changeset
    78
    /***************************************/
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 677
diff changeset
    79
    /* B.3 - Language ST (Structured Text) */
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 677
diff changeset
    80
    /***************************************/
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 677
diff changeset
    81
    void *visit(statement_list_c *symbol);
677
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    82
}; // forced_narrow_candidate_datatypes_c
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    83
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    84
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    85
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    86
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    87
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    88
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    89
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    90
681
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 677
diff changeset
    91