main.cc
changeset 1011 76175defb87b
parent 980 9ed5aff159db
child 1012 1f2af384fb1f
equal deleted inserted replaced
1010:242907849850 1011:76175defb87b
   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(" -p : allow use of forward references                (a non-standard extension?)\n");  
   117   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");  
   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(" -s : allow use of safe datatypes (SAFEBOOL, etc.)   (defined in PLCOpen Safety)\n"); // PLCopen TC5 "Safety Software Technical Specification - Part 1" v1.0
       
   119   printf(" -n : allow use of nested comments                   (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");
   120   printf(" -r : allow use of references (REF_TO, REF, ^, NULL) (an IEC 61131-3 v3 feature)\n");
   120   printf(" -R : allow use of REF_TO ANY datatypes              (a non-standard extension!)\n");
   121   printf(" -R : allow use of REF_TO ANY datatypes              (a non-standard extension!)\n");
   121   printf("        as well as REF_TO in ARRAYs and STRUCTs      (a non-standard extension!)\n");
   122   printf("        as well as REF_TO in ARRAYs and STRUCTs      (a non-standard extension!)\n");
   122   printf(" -a : allow use of non-literals in array size limits (a non-standard extension!)\n");
   123   printf(" -a : allow use of non-literals in array size limits (a non-standard extension!)\n");
       
   124   printf(" -e : disable generation of implicit EN and ENO parameters.\n");
   123   printf(" -c : create conversion functions for enumerated data types\n");
   125   printf(" -c : create conversion functions for enumerated data types\n");
   124   printf(" -O : options for output (code generation) stage. Available options for %s are...\n", cmd);
   126   printf(" -O : options for output (code generation) stage. Available options for %s are...\n", cmd);
   125   stage4_print_options();
   127   stage4_print_options();
   126   printf("\n");
   128   printf("\n");
   127   printf("%s - Copyright (C) 2003-2014 \n"
   129   printf("%s - Copyright (C) 2003-2014 \n"
   139   char * builddir = NULL;
   141   char * builddir = NULL;
   140   int optres, errflg = 0;
   142   int optres, errflg = 0;
   141   int path_len;
   143   int path_len;
   142 
   144 
   143   /* Default values for the command line options... */
   145   /* Default values for the command line options... */
   144   runtime_options.pre_parsing             = false; /* allow use of forward references (run pre-parsing phase before the definitive parsing phase that builds the AST) */
   146   runtime_options.disable_implicit_en_eno = false; /* disable: do not generate EN and ENO parameters */
   145   runtime_options.safe_extensions         = false; /* allow use of SAFExxx datatypes */
   147   runtime_options.pre_parsing             = false; /* disable: allow use of forward references (run pre-parsing phase before the definitive parsing phase that builds the AST) */
   146   runtime_options.full_token_loc          = false; /* error messages specify full token location */
   148   runtime_options.safe_extensions         = false; /* disable: allow use of SAFExxx datatypes */
   147   runtime_options.conversion_functions    = false; /* Create a conversion function for derived datatype */
   149   runtime_options.full_token_loc          = false; /* disable: error messages specify full token location */
   148   runtime_options.nested_comments         = false; /* Allow the use of nested comments. */
   150   runtime_options.conversion_functions    = false; /* disable: create a conversion function for derived datatype */
   149   runtime_options.ref_standard_extensions = false; /* Allow the use of REFerences (keywords REF_TO, REF, DREF, ^, NULL). */
   151   runtime_options.nested_comments         = false; /* disable: Allow the use of nested comments. */
   150   runtime_options.ref_nonstand_extensions = false; /* Allow the use of non-standard extensions to REF_TO datatypes: REF_TO ANY, and REF_TO in struct elements! */
   152   runtime_options.ref_standard_extensions = false; /* disable: Allow the use of REFerences (keywords REF_TO, REF, DREF, ^, NULL). */
   151   runtime_options.nonliteral_in_array_size= false; /* Allow the use of constant non-literals when specifying size of arrays (ARRAY [1..max] OF INT) */
   153   runtime_options.ref_nonstand_extensions = false; /* disable: Allow the use of non-standard extensions to REF_TO datatypes: REF_TO ANY, and REF_TO in struct elements! */
       
   154   runtime_options.nonliteral_in_array_size= false; /* disable: Allow the use of constant non-literals when specifying size of arrays (ARRAY [1..max] OF INT) */
   152   runtime_options.includedir              = NULL;  /* Include directory, where included files will be searched for... */
   155   runtime_options.includedir              = NULL;  /* Include directory, where included files will be searched for... */
   153 
   156 
   154   /* Default values for the command line options... */
   157   /* Default values for the command line options... */
   155   runtime_options.relaxed_datatype_model    = false; /* by default use the strict datatype equivalence model */
   158   runtime_options.relaxed_datatype_model    = false; /* by default use the strict datatype equivalence model */
   156   
   159   
   157   /******************************************/
   160   /******************************************/
   158   /*   Parse command line options...        */
   161   /*   Parse command line options...        */
   159   /******************************************/
   162   /******************************************/
   160   while ((optres = getopt(argc, argv, ":nhvfplsrRacI:T:O:")) != -1) {
   163   while ((optres = getopt(argc, argv, ":nehvfplsrRacI:T:O:")) != -1) {
   161     switch(optres) {
   164     switch(optres) {
   162     case 'h':
   165     case 'h':
   163       printusage(argv[0]);
   166       printusage(argv[0]);
   164       return 0;
   167       return 0;
   165     case 'v':
   168     case 'v':
   173               runtime_options.ref_nonstand_extensions  = true;  break;
   176               runtime_options.ref_nonstand_extensions  = true;  break;
   174     case 'r': runtime_options.ref_standard_extensions  = true;  break;
   177     case 'r': runtime_options.ref_standard_extensions  = true;  break;
   175     case 'a': runtime_options.nonliteral_in_array_size = true;  break;
   178     case 'a': runtime_options.nonliteral_in_array_size = true;  break;
   176     case 'c': runtime_options.conversion_functions     = true;  break;
   179     case 'c': runtime_options.conversion_functions     = true;  break;
   177     case 'n': runtime_options.nested_comments          = true;  break;
   180     case 'n': runtime_options.nested_comments          = true;  break;
       
   181     case 'e': runtime_options.disable_implicit_en_eno  = true;  break;
   178     case 'I':
   182     case 'I':
   179       /* NOTE: To improve the usability under windows:
   183       /* NOTE: To improve the usability under windows:
   180        *       We delete last char's path if it ends with "\".
   184        *       We delete last char's path if it ends with "\".
   181        *       In this way compiler front-end accepts paths with or without
   185        *       In this way compiler front-end accepts paths with or without
   182        *       slash terminator.
   186        *       slash terminator.