main.cc
changeset 362 6482d83fadee
parent 350 2c3c4dc34979
child 370 f3cec8694f65
equal deleted inserted replaced
361:e0c2f01251dc 362:6482d83fadee
    85   exit(EXIT_FAILURE);
    85   exit(EXIT_FAILURE);
    86 }
    86 }
    87 
    87 
    88 
    88 
    89 
    89 
    90 
    90 #include "config/config.h"
    91 #include "stage1_2/stage1_2.hh"
    91 #include "stage1_2/stage1_2.hh"
    92 #include "absyntax_utils/absyntax_utils.hh"
    92 #include "absyntax_utils/absyntax_utils.hh"
    93 
    93 
    94 int stage3(symbol_c *tree_root);
    94 int stage3(symbol_c *tree_root);
    95 int stage4(symbol_c *tree_root, const char *builddir);
    95 int stage4(symbol_c *tree_root, const char *builddir);
    96 
    96 
    97 
    97 
    98 static void printusage(const char *cmd) {
    98 static void printusage(const char *cmd) {
    99   printf("syntax: %s [-h] [-f] [-s] [-I <include_directory>] [-T <target_directory>] <input_file>\n", cmd);
    99   printf("syntax: %s [-h] [-v] [-f] [-s] [-I <include_directory>] [-T <target_directory>] <input_file>\n", cmd);
   100   printf("  h : show this help message\n");
   100   printf("  h : show this help message\n");
   101   printf("  f : full token location on error messages\n");
   101   printf("  v : print version number\n");  
       
   102   printf("  f : display full token location on error messages\n");
   102       /******************************************************/
   103       /******************************************************/
   103       /* whether we are suporting safe extensions           */
   104       /* whether we are suporting safe extensions           */
   104       /* as defined in PLCopen - Technical Committee 5      */
   105       /* as defined in PLCopen - Technical Committee 5      */
   105       /* Safety Software Technical Specification,           */
   106       /* Safety Software Technical Specification,           */
   106       /* Part 1: Concepts and Function Blocks,              */
   107       /* Part 1: Concepts and Function Blocks,              */
   108       /******************************************************/
   109       /******************************************************/
   109   printf("  s : allow use of safe extensions\n");
   110   printf("  s : allow use of safe extensions\n");
   110   printf("\n");
   111   printf("\n");
   111   printf("%s - Copyright (C) 2003-2011 \n"
   112   printf("%s - Copyright (C) 2003-2011 \n"
   112          "This program comes with ABSOLUTELY NO WARRANTY!\n"
   113          "This program comes with ABSOLUTELY NO WARRANTY!\n"
   113          "This is free software licensed under GPL v3, and you are welcome to redistribute it under the conditions specified by this license.\n", cmd);
   114          "This is free software licensed under GPL v3, and you are welcome to redistribute it under the conditions specified by this license.\n", PACKAGE_NAME);
   114 }
   115 }
   115 
   116 
   116 
   117 
   117 
   118 
   118 int main(int argc, char **argv) {
   119 int main(int argc, char **argv) {
   126 */
   127 */
   127 
   128 
   128   /******************************************/
   129   /******************************************/
   129   /*   Parse command line options...        */
   130   /*   Parse command line options...        */
   130   /******************************************/
   131   /******************************************/
   131   while ((optres = getopt(argc, argv, ":hfsI:T:")) != -1) {
   132   while ((optres = getopt(argc, argv, ":hvfsI:T:")) != -1) {
   132     switch(optres) {
   133     switch(optres) {
   133     case 'h':
   134     case 'h':
   134       printusage(argv[0]);
   135       printusage(argv[0]);
   135       return 0;
   136       return 0;
   136       break;
   137     case 'v':
       
   138       fprintf(stdout, "%s version %s\n", PACKAGE_NAME, PACKAGE_VERSION);      
       
   139       return 0;        
   137     case 'f':
   140     case 'f':
   138       stage1_2_options.full_token_loc = true;
   141       stage1_2_options.full_token_loc = true;
   139       break;
   142       break;
   140     case 's':
   143     case 's':
   141       stage1_2_options.safe_extensions = true;
   144       stage1_2_options.safe_extensions = true;
   170     fprintf(stderr, "Too many input files\n");
   173     fprintf(stderr, "Too many input files\n");
   171     errflg++;
   174     errflg++;
   172   }
   175   }
   173 
   176 
   174   if (errflg) {
   177   if (errflg) {
       
   178       printf("\n");
   175       printusage(argv[0]);
   179       printusage(argv[0]);
   176       return EXIT_FAILURE;
   180       return EXIT_FAILURE;
   177   }
   181   }
   178 
   182 
   179 
   183