main.cc
changeset 924 9e824bb0c3d4
parent 878 89eb85bab58f
child 932 061824c45a5b
equal deleted inserted replaced
923:0ad7843d3790 924:9e824bb0c3d4
   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 datatypes (SAFEBOOL, etc.)   (defined in PLCOpen Safety)\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 references (REF_TO, REF, NULL)    (an IEC 61131-3 v3 feature)\n");
       
   126   printf(" -R : allow use of REF_TO ANY datatypes (implies -r) (a non-standard extension!)\n");
   126   printf(" -c : create conversion functions for enumerated data types\n");
   127   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   printf(" -O : options for output (code generation) stage. Available options for %s are...\n", cmd);
   128   stage4_print_options();
   129   stage4_print_options();
   129   printf("\n");
   130   printf("\n");
   130   printf("%s - Copyright (C) 2003-2014 \n"
   131   printf("%s - Copyright (C) 2003-2014 \n"
   145   stage1_2_options.safe_extensions      = false; /* allow use of SAFExxx datatypes */
   146   stage1_2_options.safe_extensions      = false; /* allow use of SAFExxx datatypes */
   146   stage1_2_options.full_token_loc       = false; /* error messages specify full token location */
   147   stage1_2_options.full_token_loc       = false; /* error messages specify full token location */
   147   stage1_2_options.conversion_functions = false; /* Create a conversion function for derived datatype */
   148   stage1_2_options.conversion_functions = false; /* Create a conversion function for derived datatype */
   148   stage1_2_options.nested_comments      = false; /* Allow the use of nested comments. */
   149   stage1_2_options.nested_comments      = false; /* Allow the use of nested comments. */
   149   stage1_2_options.ref_operator         = false; /* Allow the use of REF() operator. */
   150   stage1_2_options.ref_operator         = false; /* Allow the use of REF() operator. */
       
   151   stage1_2_options.ref_to_any           = false; /* Allow the use of REF_TO ANY datatype. */
   150   stage1_2_options.includedir           = NULL;  /* Include directory, where included files will be searched for... */
   152   stage1_2_options.includedir           = NULL;  /* Include directory, where included files will be searched for... */
   151 
   153 
   152   /******************************************/
   154   /******************************************/
   153   /*   Parse command line options...        */
   155   /*   Parse command line options...        */
   154   /******************************************/
   156   /******************************************/
   155   while ((optres = getopt(argc, argv, ":nhvfrscI:T:O:")) != -1) {
   157   while ((optres = getopt(argc, argv, ":nhvfrRscI:T:O:")) != -1) {
   156     switch(optres) {
   158     switch(optres) {
   157     case 'h':
   159     case 'h':
   158       printusage(argv[0]);
   160       printusage(argv[0]);
   159       return 0;
   161       return 0;
   160 
       
   161     case 'v':
   162     case 'v':
   162       fprintf(stdout, "%s version %s\n" "changeset id: %s\n", PACKAGE_NAME, PACKAGE_VERSION, HGVERSION);      
   163       fprintf(stdout, "%s version %s\n" "changeset id: %s\n", PACKAGE_NAME, PACKAGE_VERSION, HGVERSION);      
   163       return 0;
   164       return 0;
   164 
       
   165     case 'f':
   165     case 'f':
   166       stage1_2_options.full_token_loc = true;
   166       stage1_2_options.full_token_loc = true;
   167       break;
   167       break;
   168 
       
   169     case 's':
   168     case 's':
   170       stage1_2_options.safe_extensions = true;
   169       stage1_2_options.safe_extensions = true;
   171       break;
   170       break;
   172 
   171     case 'R':
       
   172       stage1_2_options.ref_operator = true; /* use of REF_TO ANY implies activating support for REF extensions! */
       
   173       stage1_2_options.ref_to_any   = true;
       
   174       break;
   173     case 'r':
   175     case 'r':
   174       stage1_2_options.ref_operator = true;
   176       stage1_2_options.ref_operator = true;
   175       break;
   177       break;
   176 
       
   177     case 'c':
   178     case 'c':
   178       stage1_2_options.conversion_functions = true;
   179       stage1_2_options.conversion_functions = true;
   179       break;
   180       break;
   180 
       
   181     case 'n':
   181     case 'n':
   182       stage1_2_options.nested_comments = true;
   182       stage1_2_options.nested_comments = true;
   183       break;
   183       break;
   184 
       
   185     case 'I':
   184     case 'I':
   186       /* NOTE: To improve the usability under windows:
   185       /* NOTE: To improve the usability under windows:
   187        *       We delete last char's path if it ends with "\".
   186        *       We delete last char's path if it ends with "\".
   188        *       In this way compiler front-end accepts paths with or without
   187        *       In this way compiler front-end accepts paths with or without
   189        *       slash terminator.
   188        *       slash terminator.
   190        */
   189        */
   191       path_len = strlen(optarg) - 1;
   190       path_len = strlen(optarg) - 1;
   192       if (optarg[path_len] == '\\') optarg[path_len]= '\0';
   191       if (optarg[path_len] == '\\') optarg[path_len]= '\0';
   193       stage1_2_options.includedir = optarg;
   192       stage1_2_options.includedir = optarg;
   194       break;
   193       break;
   195 
       
   196     case 'T':
   194     case 'T':
   197       /* NOTE: see note above */
   195       /* NOTE: see note above */
   198       path_len = strlen(optarg) - 1;
   196       path_len = strlen(optarg) - 1;
   199       if (optarg[path_len] == '\\') optarg[path_len]= '\0';
   197       if (optarg[path_len] == '\\') optarg[path_len]= '\0';
   200       builddir = optarg;
   198       builddir = optarg;
   201       break;
   199       break;
   202 
       
   203     case 'O':
   200     case 'O':
   204       if (stage4_parse_options(optarg) < 0) errflg++;
   201       if (stage4_parse_options(optarg) < 0) errflg++;
   205       break;
   202       break;
   206 
       
   207     case ':':       /* -I, -T, or -O without operand */
   203     case ':':       /* -I, -T, or -O without operand */
   208       fprintf(stderr, "Option -%c requires an operand\n", optopt);
   204       fprintf(stderr, "Option -%c requires an operand\n", optopt);
   209       errflg++;
   205       errflg++;
   210       break;
   206       break;
   211 
       
   212     case '?':
   207     case '?':
   213       fprintf(stderr, "Unrecognized option: -%c\n", optopt);
   208       fprintf(stderr, "Unrecognized option: -%c\n", optopt);
   214       errflg++;
   209       errflg++;
   215       break;
   210       break;
   216 
       
   217     default:
   211     default:
   218       fprintf(stderr, "Unknown error while parsing command line options.");
   212       fprintf(stderr, "Unknown error while parsing command line options.");
   219       errflg++;
   213       errflg++;
   220       break;
   214       break;
   221     }
   215     }