main.cc
changeset 878 89eb85bab58f
parent 873 dea39ef02847
child 924 9e824bb0c3d4
equal deleted inserted replaced
877:c25346eac788 878:89eb85bab58f
   107   exit(EXIT_FAILURE);
   107   exit(EXIT_FAILURE);
   108 }
   108 }
   109 
   109 
   110 
   110 
   111 static void printusage(const char *cmd) {
   111 static void printusage(const char *cmd) {
   112   printf("\nsyntax: %s [-h] [-v] [-f] [-s] [-c] [-I <include_directory>] [-T <target_directory>] <input_file>\n", cmd);
   112   printf("\nsyntax: %s [<options>] [-O <output_options>] [-I <include_directory>] [-T <target_directory>] <input_file>\n", cmd);
   113   printf("  h : show this help message\n");
   113   printf(" -h : show this help message\n");
   114   printf("  v : print version number\n");  
   114   printf(" -v : print version number\n");  
   115   printf("  f : display full token location on error messages\n");
   115   printf(" -f : display full token location on error messages\n");
   116       /******************************************************/
   116       /******************************************************/
   117       /* whether we are supporting safe extensions          */
   117       /* whether we are supporting safe extensions          */
   118       /* as defined in PLCopen - Technical Committee 5      */
   118       /* as defined in PLCopen - Technical Committee 5      */
   119       /* Safety Software Technical Specification,           */
   119       /* Safety Software Technical Specification,           */
   120       /* Part 1: Concepts and Function Blocks,              */
   120       /* Part 1: Concepts and Function Blocks,              */
   121       /* Version 1.0 is Official Release                    */
   121       /* Version 1.0 is Official Release                    */
   122       /******************************************************/
   122       /******************************************************/
   123   printf("  s : allow use of safe extensions (e.g. SAFExxx data types))\n");
   123   printf(" -s : allow use of safe extensions (e.g. SAFExxx data types))\n");
   124   printf("  n : allow use of nested comments (an IEC 61131-3 v3 feature)\n");
   124   printf(" -n : allow use of nested comments (an IEC 61131-3 v3 feature)\n");
   125   printf("  r : allow use of REF() operator  (an IEC 61131-3 v3 feature)\n");
   125   printf(" -r : allow use of REF() operator  (an IEC 61131-3 v3 feature)\n");
   126   printf("  c : create conversion functions for enumerated data types\n");
   126   printf(" -c : create conversion functions for enumerated data types\n");
       
   127   printf(" -O : options for output (code generation) stage. Available options for %s are...\n", cmd);
       
   128   stage4_print_options();
   127   printf("\n");
   129   printf("\n");
   128   printf("%s - Copyright (C) 2003-2014 \n"
   130   printf("%s - Copyright (C) 2003-2014 \n"
   129          "This program comes with ABSOLUTELY NO WARRANTY!\n"
   131          "This program comes with ABSOLUTELY NO WARRANTY!\n"
   130          "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);
   132          "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);
   131 }
   133 }
   148   stage1_2_options.includedir           = NULL;  /* Include directory, where included files will be searched for... */
   150   stage1_2_options.includedir           = NULL;  /* Include directory, where included files will be searched for... */
   149 
   151 
   150   /******************************************/
   152   /******************************************/
   151   /*   Parse command line options...        */
   153   /*   Parse command line options...        */
   152   /******************************************/
   154   /******************************************/
   153   while ((optres = getopt(argc, argv, ":nhvfrscI:T:")) != -1) {
   155   while ((optres = getopt(argc, argv, ":nhvfrscI:T:O:")) != -1) {
   154     switch(optres) {
   156     switch(optres) {
   155     case 'h':
   157     case 'h':
   156       printusage(argv[0]);
   158       printusage(argv[0]);
   157       return 0;
   159       return 0;
   158 
   160 
   159     case 'v':
   161     case 'v':
   160       fprintf(stdout, "%s version %s\n"
   162       fprintf(stdout, "%s version %s\n" "changeset id: %s\n", PACKAGE_NAME, PACKAGE_VERSION, HGVERSION);      
   161 		      "changeset id: %s\n", PACKAGE_NAME, PACKAGE_VERSION, HGVERSION);      
       
   162       return 0;
   163       return 0;
   163 
   164 
   164     case 'f':
   165     case 'f':
   165       stage1_2_options.full_token_loc = true;
   166       stage1_2_options.full_token_loc = true;
   166       break;
   167       break;
   197       path_len = strlen(optarg) - 1;
   198       path_len = strlen(optarg) - 1;
   198       if (optarg[path_len] == '\\') optarg[path_len]= '\0';
   199       if (optarg[path_len] == '\\') optarg[path_len]= '\0';
   199       builddir = optarg;
   200       builddir = optarg;
   200       break;
   201       break;
   201 
   202 
   202     case ':':       /* -I or -T without operand */
   203     case 'O':
       
   204       if (stage4_parse_options(optarg) < 0) errflg++;
       
   205       break;
       
   206 
       
   207     case ':':       /* -I, -T, or -O without operand */
   203       fprintf(stderr, "Option -%c requires an operand\n", optopt);
   208       fprintf(stderr, "Option -%c requires an operand\n", optopt);
   204       errflg++;
   209       errflg++;
   205       break;
   210       break;
   206 
   211 
   207     case '?':
   212     case '?':