absyntax_utils/decompose_var_instance_name.hh
changeset 181 38d6eb056260
child 202 da1a8186f86f
equal deleted inserted replaced
180:64334c5a00b1 181:38d6eb056260
       
     1 /*
       
     2  * (c) 2003 Mario de Sousa
       
     3  *
       
     4  * Offered to the public under the terms of the GNU General Public License
       
     5  * as published by the Free Software Foundation; either version 2 of the
       
     6  * License, or (at your option) any later version.
       
     7  *
       
     8  * This program is distributed in the hope that it will be useful, but
       
     9  * WITHOUT ANY WARRANTY; without even the implied warranty of
       
    10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
       
    11  * Public License for more details.
       
    12  *
       
    13  * 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.
       
    15  */
       
    16 
       
    17 /*
       
    18  * An IEC 61131-3 IL and ST compiler.
       
    19  *
       
    20  * Based on the
       
    21  * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
       
    22  *
       
    23  */
       
    24 
       
    25 
       
    26 
       
    27 /* Decomposes a variable instance name into its constituents,
       
    28  * example:
       
    29  *    window.points[1].coordinate.x
       
    30  *
       
    31  *  will succesfully return
       
    32  *        - window
       
    33  *        - points
       
    34  *        - coordinate
       
    35  *        - x
       
    36  * on succesive calls to decompose_var_instance_name_c::next_part()
       
    37  */
       
    38 
       
    39 
       
    40 
       
    41 #include "../absyntax/visitor.hh"
       
    42 
       
    43 
       
    44 
       
    45 class decompose_var_instance_name_c: null_visitor_c {
       
    46 
       
    47   private:
       
    48     symbol_c *variable_name;
       
    49     symbol_c *next_variable_name;
       
    50     symbol_c *current_recursive_variable_name;
       
    51     symbol_c *previously_returned_variable_name;
       
    52 
       
    53   public:
       
    54     decompose_var_instance_name_c(symbol_c *variable_instance_name);
       
    55 
       
    56     symbol_c *next_part(void);
       
    57 
       
    58   private:
       
    59   /*********************/
       
    60   /* B 1.4 - Variables */
       
    61   /*********************/
       
    62     void *visit(symbolic_variable_c *symbol);
       
    63   
       
    64   /********************************************/
       
    65   /* B.1.4.1   Directly Represented Variables */
       
    66   /********************************************/
       
    67     void *visit(direct_variable_c *symbol);
       
    68   
       
    69   /*************************************/
       
    70   /* B.1.4.2   Multi-element Variables */
       
    71   /*************************************/
       
    72   /*  subscripted_variable '[' subscript_list ']' */
       
    73   // SYM_REF2(array_variable_c, subscripted_variable, subscript_list)
       
    74     void *visit(array_variable_c *symbol);
       
    75   
       
    76   /*  record_variable '.' field_selector */
       
    77   /*  WARNING: input and/or output variables of function blocks
       
    78    *           may be accessed as fields of a tructured variable!
       
    79    *           Code handling a structured_variable_c must take
       
    80    *           this into account!
       
    81    */
       
    82   //SYM_REF2(structured_variable_c, record_variable, field_selector)
       
    83     void *visit(structured_variable_c *symbol);
       
    84 
       
    85 }; // decompose_var_instance_name_c
       
    86 
       
    87 
       
    88 
       
    89