stage3/stage3.cc
changeset 270 f1674941c3ad
parent 267 0a1204bcc9af
child 279 c0453b7f99df
equal deleted inserted replaced
256:101c7f148b9a 270:f1674941c3ad
     1 /*
     1 /*
     2  * (c) 20099 Catarina da Costa Boucinha
     2  *  matiec - a compiler for the programming languages defined in IEC 61131-3
     3  *
     3  *
     4  * Offered to the public under the terms of the GNU General Public License
     4  *  Copyright (C) 2009-2011  Mario de Sousa (msousa@fe.up.pt)
     5  * as published by the Free Software Foundation; either version 2 of the
       
     6  * License, or (at your option) any later version.
       
     7  *
     5  *
     8  * This program is distributed in the hope that it will be useful, but
     6  *  This program is free software: you can redistribute it and/or modify
     9  * WITHOUT ANY WARRANTY; without even the implied warranty of
     7  *  it under the terms of the GNU General Public License as published by
    10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
     8  *  the Free Software Foundation, either version 3 of the License, or
    11  * Public License for more details.
     9  *  (at your option) any later version.
       
    10  *
       
    11  *  This program is distributed in the hope that it will be useful,
       
    12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    14  *  GNU General Public License for more details.
       
    15  *
       
    16  *  You should have received a copy of the GNU General Public License
       
    17  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
       
    18  *
    12  *
    19  *
    13  * This code is made available on the understanding that it will not be
    20  * This code is made available on the understanding that it will not be
    14  * used in safety-critical situations without a full and competent review.
    21  * used in safety-critical situations without a full and competent review.
    15  */
    22  */
    16 
    23 
    17 /*
    24 /*
    18  * An IEC 61131-3 IL and ST compiler.
    25  * An IEC 61131-3 compiler.
    19  *
    26  *
    20  * Based on the
    27  * Based on the
    21  * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2009-04-24)
    28  * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
    22  *
    29  *
    23  */
    30  */
    24 
    31 
    25 #include "stage3.hh"
    32 #include "stage3.hh"
    26 
    33 
    27 int type_safety(symbol_c *tree_root){
    34 int type_safety(symbol_c *tree_root){
    28 	visit_expression_type_c visit_expression_type(tree_root);
    35 	visit_expression_type_c visit_expression_type(tree_root);
    29 
    36 
    30 	(*tree_root).accept(visit_expression_type);
    37 	(*tree_root).accept(visit_expression_type);
    31 
    38 
       
    39 	if (visit_expression_type.get_error_found())
       
    40 	  return -1;
       
    41 	
    32 	return 0;
    42 	return 0;
    33 }
    43 }
    34 
    44 
    35 int stage3(symbol_c *tree_root){
    45 int stage3(symbol_c *tree_root){
    36 	return type_safety(tree_root);
    46 	return type_safety(tree_root);