-/* Generated by re2c 0.14.3 on Sun Jul 19 12:06:48 2015 */
+/* Generated by re2c 0.14.3 on Tue Jul 21 12:00:08 2015 */
#include <stdio.h>
#include "src/conf/msg.h"
{ goto opt_long; }
yy9:
++YYCURSOR;
- { opts.source ("<stdin>"); goto opt; }
+ { if (!opts.source ("<stdin>")) return EXIT_FAIL; goto opt; }
yy11:
++YYCURSOR;
{ goto end; }
goto yy13;
}
++YYCURSOR;
- { opts.source (*argv); goto opt; }
+ { if (!opts.source (*argv)) return EXIT_FAIL; goto opt; }
}
yych = *++YYCURSOR;
if (yych >= 0x01) goto yy89;
++YYCURSOR;
- { goto opt_header; }
+ { YYCURSOR = *++argv; goto opt_header; }
yy143:
yych = *++YYCURSOR;
if (yych == 'n') goto yy184;
yych = *++YYCURSOR;
if (yych >= 0x01) goto yy89;
++YYCURSOR;
- { goto opt_output; }
+ { YYCURSOR = *++argv; goto opt_output; }
yy211:
yych = *++YYCURSOR;
if (yych == '-') goto yy223;
goto yy386;
}
++YYCURSOR;
- { opts.output (*argv); goto opt; }
+ { if (!opts.output (*argv)) return EXIT_FAIL; goto opt; }
}
goto yy395;
}
++YYCURSOR;
- { opts.type_header (*argv); goto opt; }
+ { if (!opts.type_header (*argv)) return EXIT_FAIL; goto opt; }
}
end:
+ if (!opts.source_file)
+ {
+ error ("no source file\n");
+ return EXIT_FAIL;
+ }
if (!cFlag && opts.header_file)
{
error ("can only output a header file when using -c switch\n");
bool OutputFile::open ()
{
- if (strcmp (file_name, "<stdout>") == 0)
+ if (file_name == NULL)
{
+ file_name = "<stdout>";
file = stdout;
}
else
+#include "src/conf/msg.h"
#include "src/conf/opt.h"
namespace re2c
flag_skeleton = true;
}
-void Opt::source (const char * s)
-{
- source_file = s;
-}
-
-void Opt::output (const char * s)
-{
- output_file = s;
-}
-
-void Opt::type_header (const char * s)
-{
- tFlag = true;
- header_file = s;
-}
-
void Opt::encoding_policy (Enc::policy_t p)
{
encoding.setPolicy (p);
empty_class_policy = p;
}
+bool Opt::source (const char * s)
+{
+ if (source_file)
+ {
+ error ("multiple source files: %s, %s\n", source_file, s);
+ return false;
+ }
+ else
+ {
+ source_file = s;
+ return true;
+ }
+}
+
+bool Opt::output (const char * s)
+{
+ if (output_file)
+ {
+ error ("multiple output files: %s, %s\n", output_file, s);
+ return false;
+ }
+ else
+ {
+ output_file = s;
+ return true;
+ }
+}
+
+bool Opt::type_header (const char * s)
+{
+ if (header_file)
+ {
+ error ("multiple header files: %s, %s\n", header_file, s);
+ return false;
+ }
+ else
+ {
+ tFlag = true;
+ header_file = s;
+ return true;
+ }
+}
+
bool Opt::ecb ()
{
return encoding.set (Enc::EBCDIC);
Opt ()
: source_file (NULL)
- , output_file ("<stdout>")
+ , output_file (NULL)
, header_file (NULL)
{}
void case_insensitive ();
void case_inverted ();
void skeleton ();
- void source (const char * s);
- void output (const char * s);
- void type_header (const char * s);
void encoding_policy (Enc::policy_t);
void input (InputAPI::type_t);
void empty_class (empty_class_policy_t);
+ bool source (const char * s);
+ bool output (const char * s);
+ bool type_header (const char * s);
bool ecb ();
bool unicode ();
bool wide_chars ();
"--" end { goto end; }
- "-" end { opts.source ("<stdin>"); goto opt; }
- filename end { opts.source (*argv); goto opt; }
+ "-" end { if (!opts.source ("<stdin>")) return EXIT_FAIL; goto opt; }
+ filename end { if (!opts.source (*argv)) return EXIT_FAIL; goto opt; }
"-" { goto opt_short; }
"--" { goto opt_long; }
"wide-chars" end { if (!opts.wide_chars ()) { error_encoding (); return EXIT_FAIL; } goto opt; }
"utf-16" end { if (!opts.utf_16 ()) { error_encoding (); return EXIT_FAIL; } goto opt; }
"utf-8" end { if (!opts.utf_8 ()) { error_encoding (); return EXIT_FAIL; } goto opt; }
- "output" end { goto opt_output; }
- "type-header" end { goto opt_header; }
+ "output" end { YYCURSOR = *++argv; goto opt_output; }
+ "type-header" end { YYCURSOR = *++argv; goto opt_header; }
"encoding-policy" end { goto opt_encoding_policy; }
"input" end { goto opt_input; }
"empty-class" end { goto opt_empty_class; }
error ("bad argument to option -o, --output: %s\n", *argv);
return EXIT_FAIL;
}
- filename end { opts.output (*argv); goto opt; }
+ filename end { if (!opts.output (*argv)) return EXIT_FAIL; goto opt; }
*/
opt_header:
error ("bad argument to option -t, --type-header: %s\n", *argv);
return EXIT_FAIL;
}
- filename end { opts.type_header (*argv); goto opt; }
+ filename end { if (!opts.type_header (*argv)) return EXIT_FAIL; goto opt; }
*/
opt_encoding_policy:
*/
end:
+ if (!opts.source_file)
+ {
+ error ("no source file\n");
+ return EXIT_FAIL;
+ }
if (!cFlag && opts.header_file)
{
error ("can only output a header file when using -c switch\n");