main.cc
changeset 956 513809fbfaf9
parent 946 c012a64dc2fa
child 959 8bfcc8e62bd6
equal deleted inserted replaced
955:5e2e7707f770 956:513809fbfaf9
   111 static void printusage(const char *cmd) {
   111 static void printusage(const char *cmd) {
   112   printf("\nsyntax: %s [<options>] [-O <output_options>] [-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   printf(" -p : allow use of forward references                (a non-standard extension?)\n");  
   116   printf(" -l : use a relaxed datatype equivalence model       (a non-standard extension?)\n");  
   117   printf(" -l : use a relaxed datatype equivalence model       (a non-standard extension?)\n");  
   117   printf(" -s : allow use of safe datatypes (SAFEBOOL, etc.)   (defined in PLCOpen Safety)\n"); // PLCopen TC5 "Safety Software Technical Specification - Part 1" v1.0
   118   printf(" -s : allow use of safe datatypes (SAFEBOOL, etc.)   (defined in PLCOpen Safety)\n"); // PLCopen TC5 "Safety Software Technical Specification - Part 1" v1.0
   118   printf(" -r : allow use of references (REF_TO, REF, ^, NULL) (an IEC 61131-3 v3 feature)\n");
   119   printf(" -r : allow use of references (REF_TO, REF, ^, NULL) (an IEC 61131-3 v3 feature)\n");
   119   printf(" -R : allow use of REF_TO ANY datatypes              (a non-standard extension!)\n");
   120   printf(" -R : allow use of REF_TO ANY datatypes              (a non-standard extension!)\n");
   120   printf("        as well as REF_TO in ARRAYs and STRUCTs      (a non-standard extension!)\n");
   121   printf("        as well as REF_TO in ARRAYs and STRUCTs      (a non-standard extension!)\n");
   137   char * builddir = NULL;
   138   char * builddir = NULL;
   138   int optres, errflg = 0;
   139   int optres, errflg = 0;
   139   int path_len;
   140   int path_len;
   140 
   141 
   141   /* Default values for the command line options... */
   142   /* Default values for the command line options... */
       
   143   runtime_options.pre_parsing             = false; /* allow use of forward references (run pre-parsing phase before the definitive parsing phase that builds the AST) */
   142   runtime_options.safe_extensions         = false; /* allow use of SAFExxx datatypes */
   144   runtime_options.safe_extensions         = false; /* allow use of SAFExxx datatypes */
   143   runtime_options.full_token_loc          = false; /* error messages specify full token location */
   145   runtime_options.full_token_loc          = false; /* error messages specify full token location */
   144   runtime_options.conversion_functions    = false; /* Create a conversion function for derived datatype */
   146   runtime_options.conversion_functions    = false; /* Create a conversion function for derived datatype */
   145   runtime_options.nested_comments         = false; /* Allow the use of nested comments. */
   147   runtime_options.nested_comments         = false; /* Allow the use of nested comments. */
   146   runtime_options.ref_standard_extensions = false; /* Allow the use of REFerences (keywords REF_TO, REF, DREF, ^, NULL). */
   148   runtime_options.ref_standard_extensions = false; /* Allow the use of REFerences (keywords REF_TO, REF, DREF, ^, NULL). */
   151   runtime_options.relaxed_datatype_model    = false; /* by default use the strict datatype equivalence model */
   153   runtime_options.relaxed_datatype_model    = false; /* by default use the strict datatype equivalence model */
   152   
   154   
   153   /******************************************/
   155   /******************************************/
   154   /*   Parse command line options...        */
   156   /*   Parse command line options...        */
   155   /******************************************/
   157   /******************************************/
   156   while ((optres = getopt(argc, argv, ":nhvflsrRcI:T:O:")) != -1) {
   158   while ((optres = getopt(argc, argv, ":nhvfplsrRcI:T:O:")) != -1) {
   157     switch(optres) {
   159     switch(optres) {
   158     case 'h':
   160     case 'h':
   159       printusage(argv[0]);
   161       printusage(argv[0]);
   160       return 0;
   162       return 0;
   161     case 'v':
   163     case 'v':
   162       fprintf(stdout, "%s version %s\n" "changeset id: %s\n", PACKAGE_NAME, PACKAGE_VERSION, HGVERSION);      
   164       fprintf(stdout, "%s version %s\n" "changeset id: %s\n", PACKAGE_NAME, PACKAGE_VERSION, HGVERSION);      
   163       return 0;
   165       return 0;
   164     case 'l':
   166     case 'l':
   165       runtime_options.relaxed_datatype_model = true;
   167       runtime_options.relaxed_datatype_model = true;
   166       break;
   168       break;
   167   
   169     case 'p':
       
   170       runtime_options.pre_parsing = true;
       
   171       break;
   168     case 'f':
   172     case 'f':
   169       runtime_options.full_token_loc = true;
   173       runtime_options.full_token_loc = true;
   170       break;
   174       break;
   171     case 's':
   175     case 's':
   172       runtime_options.safe_extensions = true;
   176       runtime_options.safe_extensions = true;