main.cc
author mario
Tue, 26 May 2009 18:04:27 +0200
changeset 178 1622dc05c6ca
parent 177 697562a5da7c
child 179 a4eb4fd6b0d6
permissions -rwxr-xr-x
Starting move of search utils to their own top level directory.
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     1
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     2
 * (c) 2003 Mario de Sousa
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     3
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     4
 * Offered to the public under the terms of the GNU General Public License
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     5
 * as published by the Free Software Foundation; either version 2 of the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     6
 * License, or (at your option) any later version.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     7
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     8
 * This program is distributed in the hope that it will be useful, but
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     9
 * WITHOUT ANY WARRANTY; without even the implied warranty of
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    11
 * Public License for more details.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    12
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    13
 * This code is made available on the understanding that it will not be
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    14
 * used in safety-critical situations without a full and competent review.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    15
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    16
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    17
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    18
 * An IEC 61131-3 IL and ST compiler.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    19
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    20
 * Based on the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    21
 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    22
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    23
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    24
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    25
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    26
 ****************************************************************
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    27
 ****************************************************************
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    28
 ****************************************************************
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    29
 *********                                              *********
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    30
 *********                                              *********
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    31
 *********   O V E R A L L    A R C H I T E C T U R E   *********
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    32
 *********                                              *********
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    33
 *********                                              *********
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    34
 ****************************************************************
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    35
 ****************************************************************
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    36
 ****************************************************************
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    37
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    38
 The compiler works in 4(+1) stages:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    39
 Stage 1   - Lexical analyser      - implemented with flex (iec.flex)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    40
 Stage 2   - Syntax parser         - implemented with bison (iec.y)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    41
 Stage 3   - Semantics analyser    - not yet implemented
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    42
 Stage 4   - Code generator        - implemented in C++
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    43
 Stage 4+1 - Binary code generator - gcc, javac, etc...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    44
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    45
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    46
 Data structures passed between stages, in global variables:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    47
 1->2   : tokens (int), and token values (char *)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    48
 2->1   : symbol tables (defined in symtable.hh)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    49
 2->3   : abstract syntax tree (tree of C++ classes, in absyntax.hh file)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    50
 3->4   : Same as 2->3
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    51
 4->4+1 : file with program in c, java, etc...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    52
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    53
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    54
 The compiler works in several passes:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    55
 Pass 1: executes stages 1 and 2 simultaneously
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    56
 Pass 2: executes stage 3
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    57
 Pass 3: executes stage 4
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    58
 Pass 4: executes stage 4+1
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    59
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    60
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    61
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    62
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    63
//#include <stdio.h>   // printf()
139
668a54686827 added missing includes on some platform (gentoo/gcc-4.3.1)
etisserant
parents: 136
diff changeset
    64
#include <string.h>
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    65
#include <stdlib.h>  // EXIT_FAILURE
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    66
#include "absyntax/absyntax.hh"  // symbol_c type
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    67
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    68
/* A macro for printing out internal parser errors... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    69
#include <iostream> // required for std::cerr
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    70
#define ERROR error_exit(__FILE__,__LINE__)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    71
void error_exit(const char *file_name, int line_no) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    72
  std::cerr << "\nInternal program error in file " << file_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    73
            << " at line " << line_no << "\n\n\n";
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    74
  exit(EXIT_FAILURE);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    75
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    76
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    77
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    78
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
    79
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
    80
#include "stage1_2/stage1_2.hh"
178
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents: 177
diff changeset
    81
#include "search_utils/search_utils.hh"
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
    82
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    83
//int stage3(symbol_c *tree_root);
46
fc1b78ea6d84 Adding support for generating files into an user-defined folder
lbessard
parents: 0
diff changeset
    84
int stage4(symbol_c *tree_root, const char *builddir);
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    85
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    86
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    87
static void printusage(const char *cmd) {
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
    88
  printf("syntax: %s [-h] [-f] [-s] [-I <include_directory>] [-T <target_directory>] <input_file>\n", cmd);
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
    89
  printf("  h : show this help message\n");
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 47
diff changeset
    90
  printf("  f : full token location on error messages\n");
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
    91
      /******************************************************/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
    92
      /* whether we are suporting safe extensions           */
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
    93
      /* as defined in PLCopen - Technical Committee 5      */
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
    94
      /* Safety Software Technical Specification,           */
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
    95
      /* Part 1: Concepts and Function Blocks,              */
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
    96
      /* Version 1.0 – Official Release                     */
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
    97
      /******************************************************/
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
    98
  printf("  s : allow use of safe extensions\n");
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    99
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   100
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   101
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   102
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   103
int main(int argc, char **argv) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   104
  symbol_c *tree_root;
46
fc1b78ea6d84 Adding support for generating files into an user-defined folder
lbessard
parents: 0
diff changeset
   105
  char * builddir = NULL;
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   106
  stage1_2_options_t stage1_2_options = {false, false, NULL};
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   107
  int optres, errflg = 0;
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   108
/*
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   109
  extern char *optarg;
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   110
  extern int optind, optopt;
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   111
*/
46
fc1b78ea6d84 Adding support for generating files into an user-defined folder
lbessard
parents: 0
diff changeset
   112
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   113
  while ((optres = getopt(argc, argv, ":hfsI:T:")) != -1) {
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   114
    switch(optres) {
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   115
    case 'h':
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   116
      printusage(argv[0]);
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   117
      return 0;
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   118
      break;
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   119
    case 'f':
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   120
      stage1_2_options.full_token_loc = true;
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   121
      break;
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   122
    case 's':
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   123
      stage1_2_options.safe_extensions = true;
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   124
      break;
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   125
    case 'I':
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   126
      stage1_2_options.includedir = optarg;
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   127
      break;
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   128
    case ':':       /* -I or -T without operand */
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   129
      fprintf(stderr, "Option -%c requires an operand\n", optopt);
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   130
      errflg++;
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   131
      break;
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   132
    case '?':
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   133
    default:
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   134
      fprintf(stderr, "Unrecognized option: -%c\n", optopt);
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   135
      errflg++;
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   136
      break;
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   137
    }
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   138
  }
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   139
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   140
  if (optind == argc) {
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   141
    fprintf(stderr, "Missing input file\n");
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   142
    errflg++;
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 47
diff changeset
   143
  }
32bd7ef40897 Adding some improvements:
lbessard
parents: 47
diff changeset
   144
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   145
  if (optind > argc) {
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   146
    fprintf(stderr, "Too many input files\n");
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   147
    errflg++;
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   148
  }
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   149
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   150
  if (errflg) {
136
32bd7ef40897 Adding some improvements:
lbessard
parents: 47
diff changeset
   151
      printusage(argv[0]);
32bd7ef40897 Adding some improvements:
lbessard
parents: 47
diff changeset
   152
      return EXIT_FAILURE;
32bd7ef40897 Adding some improvements:
lbessard
parents: 47
diff changeset
   153
  }
32bd7ef40897 Adding some improvements:
lbessard
parents: 47
diff changeset
   154
32bd7ef40897 Adding some improvements:
lbessard
parents: 47
diff changeset
   155
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   156
  /* 1st Pass */
177
697562a5da7c Adding support for SAFEBOOL. Some code generation yet to do...
mario
parents: 139
diff changeset
   157
  if (stage1_2(argv[optind], &tree_root, stage1_2_options) < 0)
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   158
    return EXIT_FAILURE;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   159
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   160
  /* 2nd Pass */
178
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents: 177
diff changeset
   161
printf("loading symbol tables...\n");
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents: 177
diff changeset
   162
  search_utils_init(tree_root);
1622dc05c6ca Starting move of search utils to their own top level directory.
mario
parents: 177
diff changeset
   163
printf("loading symbol tables... DONE!\n");
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   164
  /* not yet implemented... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   165
  /*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   166
  if (stage3(tree_root) < 0)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   167
    return EXIT_FAILURE;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   168
  */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   169
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   170
  /* 3rd Pass */
46
fc1b78ea6d84 Adding support for generating files into an user-defined folder
lbessard
parents: 0
diff changeset
   171
  if (stage4(tree_root, builddir) < 0)
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   172
    return EXIT_FAILURE;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   173
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   174
  /* 4th Pass */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   175
  /* Currently implemented in the Makefile! */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   176
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   177
  return 0;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   178
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   179
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   180