absyntax_utils/spec_init_separator.hh
author Edouard Tisserant
Fri, 01 Apr 2011 11:10:06 +0200
changeset 256 101c7f148b9a
parent 181 38d6eb056260
child 265 4d222f46f8cc
permissions -rw-r--r--
Changed packing declaration in iec_types
181
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
     1
/*
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
     2
 * (c) 2003 Mario de Sousa
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
     3
 *
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
     4
 * Offered to the public under the terms of the GNU General Public License
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
     5
 * as published by the Free Software Foundation; either version 2 of the
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
     6
 * License, or (at your option) any later version.
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
     7
 *
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
     8
 * This program is distributed in the hope that it will be useful, but
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
     9
 * WITHOUT ANY WARRANTY; without even the implied warranty of
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    11
 * Public License for more details.
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    12
 *
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    13
 * This code is made available on the understanding that it will not be
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    14
 * used in safety-critical situations without a full and competent review.
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    15
 */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    16
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    17
/*
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    18
 * An IEC 61131-3 IL and ST compiler.
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    19
 *
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    20
 * Based on the
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    21
 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    22
 *
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    23
 */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    24
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    25
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    26
/*
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    27
 * Separation of type specification and default value constructs
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    28
 * (for e.g. simple_spec_init_c), into a type specificiation part,
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    29
 * and a default value part.
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    30
 */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    31
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    32
#include "../absyntax/absyntax.hh"
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    33
#include "../absyntax/visitor.hh"
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    34
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    35
class spec_init_sperator_c: public null_visitor_c {
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    36
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    37
  private:
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    38
    /* this is a singleton class... */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    39
    static spec_init_sperator_c *class_instance;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    40
    static spec_init_sperator_c *get_class_instance(void);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    41
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    42
  private:
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    43
    typedef enum {search_spec, search_init} search_what_t;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    44
    static search_what_t search_what;
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    45
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    46
  public:
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    47
    /* the only two public functions... */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    48
    static symbol_c *get_spec(symbol_c *spec_init);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    49
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    50
    static symbol_c *get_init(symbol_c *spec_init);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    51
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    52
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    53
  private:
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    54
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    55
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    56
  /*******************************************/
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    57
  /* B 1.1 - Letters, digits and identifiers */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    58
  /*******************************************/
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    59
  // SYM_TOKEN(identifier_c)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    60
  void *visit(identifier_c *symbol);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    61
  
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    62
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    63
  /********************************/
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    64
  /* B 1.3.3 - Derived data types */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    65
  /********************************/
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    66
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    67
  /* simple_specification ASSIGN constant */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    68
  void *visit(simple_spec_init_c *symbol);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    69
  
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    70
  /* subrange_specification ASSIGN signed_integer */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    71
  void *visit(subrange_spec_init_c *symbol);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    72
  
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    73
  /*  integer_type_name '(' subrange')' */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    74
  void *visit(subrange_specification_c *symbol);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    75
  
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    76
  /* array_specification [ASSIGN array_initialization} */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    77
  /* array_initialization may be NULL ! */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    78
  void *visit(array_spec_init_c *symbol);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    79
  
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    80
  /* enumerated_specification ASSIGN enumerated_value */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    81
  void *visit(enumerated_spec_init_c *symbol);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    82
  
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    83
  /* structure_type_name ASSIGN structure_initialization */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    84
  /* structure_initialization may be NULL ! */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    85
  //SYM_REF2(initialized_structure_c, structure_type_name, structure_initialization)
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    86
  void *visit(initialized_structure_c *symbol);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    87
  
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    88
  
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    89
  /******************************************/
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    90
  /* B 1.4.3 - Declaration & Initialisation */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    91
  /******************************************/
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    92
  
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    93
  /* fb_name_list ':' function_block_type_name ASSIGN structure_initialization */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    94
  /* structure_initialization -> may be NULL ! */
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    95
  void *visit(fb_name_decl_c *symbol);
38d6eb056260 Moving absyntax utility files out from stage4/generate_c
mario
parents:
diff changeset
    96
};   /* class spec_init_sperator_c */