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(" -i : allow POUs with no in out and inout parameters (a non-standard extension!)\n"); |
|
125 printf(" -b : allow functions returning VOID (a non-standard extension!)\n"); |
|
126 printf(" -e : disable generation of implicit EN and ENO parameters.\n"); |
123 printf(" -c : create conversion functions for enumerated data types\n"); |
127 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); |
128 printf(" -O : options for output (code generation) stage. Available options for %s are...\n", cmd); |
|
129 runtime_options.allow_missing_var_in = false; /* disable: allow definition and invocation of POUs with no input, output and in_out parameters! */ |
125 stage4_print_options(); |
130 stage4_print_options(); |
126 printf("\n"); |
131 printf("\n"); |
127 printf("%s - Copyright (C) 2003-2014 \n" |
132 printf("%s - Copyright (C) 2003-2014 \n" |
128 "This program comes with ABSOLUTELY NO WARRANTY!\n" |
133 "This program comes with ABSOLUTELY NO WARRANTY!\n" |
129 "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); |
134 "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); |
139 char * builddir = NULL; |
144 char * builddir = NULL; |
140 int optres, errflg = 0; |
145 int optres, errflg = 0; |
141 int path_len; |
146 int path_len; |
142 |
147 |
143 /* Default values for the command line options... */ |
148 /* 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) */ |
149 runtime_options.allow_void_datatype = false; /* disable: allow declaration of functions returning VOID */ |
145 runtime_options.safe_extensions = false; /* allow use of SAFExxx datatypes */ |
150 runtime_options.allow_missing_var_in = false; /* disable: allow definition and invocation of POUs with no input, output and in_out parameters! */ |
146 runtime_options.full_token_loc = false; /* error messages specify full token location */ |
151 runtime_options.disable_implicit_en_eno = false; /* disable: do not generate EN and ENO parameters */ |
147 runtime_options.conversion_functions = false; /* Create a conversion function for derived datatype */ |
152 runtime_options.pre_parsing = false; /* disable: allow use of forward references (run pre-parsing phase before the definitive parsing phase that builds the AST) */ |
148 runtime_options.nested_comments = false; /* Allow the use of nested comments. */ |
153 runtime_options.safe_extensions = false; /* disable: allow use of SAFExxx datatypes */ |
149 runtime_options.ref_standard_extensions = false; /* Allow the use of REFerences (keywords REF_TO, REF, DREF, ^, NULL). */ |
154 runtime_options.full_token_loc = false; /* disable: error messages specify full token location */ |
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! */ |
155 runtime_options.conversion_functions = false; /* disable: create a conversion function for derived datatype */ |
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) */ |
156 runtime_options.nested_comments = false; /* disable: Allow the use of nested comments. */ |
|
157 runtime_options.ref_standard_extensions = false; /* disable: Allow the use of REFerences (keywords REF_TO, REF, DREF, ^, NULL). */ |
|
158 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! */ |
|
159 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... */ |
160 runtime_options.includedir = NULL; /* Include directory, where included files will be searched for... */ |
153 |
161 |
154 /* Default values for the command line options... */ |
162 /* Default values for the command line options... */ |
155 runtime_options.relaxed_datatype_model = false; /* by default use the strict datatype equivalence model */ |
163 runtime_options.relaxed_datatype_model = false; /* by default use the strict datatype equivalence model */ |
156 |
164 |
157 /******************************************/ |
165 /******************************************/ |
158 /* Parse command line options... */ |
166 /* Parse command line options... */ |
159 /******************************************/ |
167 /******************************************/ |
160 while ((optres = getopt(argc, argv, ":nhvfplsrRacI:T:O:")) != -1) { |
168 while ((optres = getopt(argc, argv, ":nehvfplsrRabicI:T:O:")) != -1) { |
161 switch(optres) { |
169 switch(optres) { |
162 case 'h': |
170 case 'h': |
163 printusage(argv[0]); |
171 printusage(argv[0]); |
164 return 0; |
172 return 0; |
165 case 'v': |
173 case 'v': |
171 case 's': runtime_options.safe_extensions = true; break; |
179 case 's': runtime_options.safe_extensions = true; break; |
172 case 'R': runtime_options.ref_standard_extensions = true; /* use of REF_TO ANY implies activating support for REF extensions! */ |
180 case 'R': runtime_options.ref_standard_extensions = true; /* use of REF_TO ANY implies activating support for REF extensions! */ |
173 runtime_options.ref_nonstand_extensions = true; break; |
181 runtime_options.ref_nonstand_extensions = true; break; |
174 case 'r': runtime_options.ref_standard_extensions = true; break; |
182 case 'r': runtime_options.ref_standard_extensions = true; break; |
175 case 'a': runtime_options.nonliteral_in_array_size = true; break; |
183 case 'a': runtime_options.nonliteral_in_array_size = true; break; |
|
184 case 'b': runtime_options.allow_void_datatype = true; break; |
|
185 case 'i': runtime_options.allow_missing_var_in = true; break; |
176 case 'c': runtime_options.conversion_functions = true; break; |
186 case 'c': runtime_options.conversion_functions = true; break; |
177 case 'n': runtime_options.nested_comments = true; break; |
187 case 'n': runtime_options.nested_comments = true; break; |
|
188 case 'e': runtime_options.disable_implicit_en_eno = true; break; |
178 case 'I': |
189 case 'I': |
179 /* NOTE: To improve the usability under windows: |
190 /* NOTE: To improve the usability under windows: |
180 * We delete last char's path if it ends with "\". |
191 * We delete last char's path if it ends with "\". |
181 * In this way compiler front-end accepts paths with or without |
192 * In this way compiler front-end accepts paths with or without |
182 * slash terminator. |
193 * slash terminator. |