10 void error (
const char * fmt, ...)
12 fprintf (stderr,
"re2c: error: ");
16 vfprintf (stderr, fmt, args);
19 fprintf (stderr,
"\n");
24 error (
"only one of switches -e, -w, -x, -u and -8 must be set");
29 error (
"expected argument to option %s", option);
34 static const char * msg = error ?
"error" :
"warning";
35 fprintf (stderr,
"re2c: %s: line %u: ", msg, line);
42 const char * prefix = error ?
"error-" :
"";
43 fprintf (stderr,
" [-W%s%s]", prefix, type);
45 fprintf (stderr,
"\n");
48 void warning (
const char * type, uint32_t line,
bool error,
const char * fmt, ...)
54 vfprintf (stderr, fmt, args);
63 "usage: re2c [-bcdDefFghirsuvVwx18] [-o of] [-t th] file\n"
65 "-? -h --help Display this info.\n"
67 "-b --bit-vectors Implies -s. Use bit vectors as well in the attempt to\n"
68 " coax better code out of the compiler. Most useful for\n"
69 " specifications with more than a few keywords (e.g. for\n"
70 " most programming languages).\n"
72 "-c --conditions Require start conditions.\n"
74 "-d --debug-output Creates a parser that dumps information during\n"
75 " about the current position and in which state the\n"
78 "-D --emit-dot Emit a Graphviz dot view of the DFA graph\n"
80 "-e --ecb Generate a parser that supports EBCDIC. The generated code\n"
81 " can deal with any character up to 0xFF. In this mode re2c\n"
82 " assumes that input character size is 1 byte. This switch is\n"
83 " incompatible with -w, -u, -x and -8\n"
85 "-f --storable-state Generate a scanner that supports storable states.\n"
87 "-F --flex-syntax Partial support for flex syntax.\n"
89 "-g --computed-gotos Implies -b. Generate computed goto code (only useable\n"
92 "-i --no-debug-info Do not generate '#line' info (useful for versioning).\n"
94 "-o of --output=of Specify the output file (of) instead of stdout\n"
96 "-r --reusable Allow reuse of scanner definitions.\n"
98 "-s --nested-ifs Generate nested ifs for some switches. Many compilers\n"
99 " need this assist to generate better code.\n"
101 "-t th --type-header=th Generate a type header file (th) with type definitions.\n"
103 "-u --unicode Generate a parser that supports UTF-32. The generated code\n"
104 " can deal with any valid Unicode character up to 0x10FFFF.\n"
105 " In this mode re2c assumes that input character size is 4 bytes.\n"
106 " This switch is incompatible with -e, -w, -x and -8. It implies -s.\n"
108 "-v --version Show version information.\n"
110 "-V --vernum Show version as one number.\n"
112 "-w --wide-chars Generate a parser that supports UCS-2. The generated code can\n"
113 " deal with any valid Unicode character up to 0xFFFF. In this mode\n"
114 " re2c assumes that input character size is 2 bytes. This switch is\n"
115 " incompatible with -e, -x, -u and -8. It implies -s."
117 "-x --utf-16 Generate a parser that supports UTF-16. The generated code can\n"
118 " deal with any valid Unicode character up to 0x10FFFF. In this mode\n"
119 " re2c assumes that input character size is 2 bytes. This switch is\n"
120 " incompatible with -e, -w, -u and -8. It implies -s."
122 "-8 --utf-8 Generate a parser that supports UTF-8. The generated code can\n"
123 " deal with any valid Unicode character up to 0x10FFFF. In this mode\n"
124 " re2c assumes that input character size is 1 byte. This switch is\n"
125 " incompatible with -e, -w, -x and -u."
127 "--no-generation-date Suppress date output in the generated file.\n"
129 "--no-version Suppress version output in the generated file.\n"
131 "--case-insensitive All strings are case insensitive, so all \"-expressions\n"
132 " are treated in the same way '-expressions are.\n"
134 "--case-inverted Invert the meaning of single and double quoted strings.\n"
135 " With this switch single quotes are case sensitive and\n"
136 " double quotes are case insensitive.\n"
138 "--encoding-policy ep Specify what re2c should do when given bad code unit.\n"
139 " ep can be one of the following: fail, substitute, ignore.\n"
141 "--input i Specify re2c input API.\n"
142 " i can be one of the following: default, custom.\n"
144 "--skeleton Instead of embedding re2c-generated code into C/C++ source,\n"
145 " generate a self-contained program for the same DFA.\n"
146 " Most useful for correctness and performance testing.\n"
148 "--empty-class policy What to do if user inputs empty character class. policy can be\n"
149 " one of the following: 'match-empty' (match empty input, default),\n"
150 " 'match-none' (fail to match on any input), 'error' (compilation\n"
151 " error). Note that there are various ways to construct empty class,\n"
152 " e.g: [], [^\\x00-\\xFF], [\\x00-\\xFF]\\[\\x00-\\xFF].\n"
154 "--dfa-minimization <table | moore>\n"
155 " Internal algorithm used by re2c to minimize DFA (defaults to\n"
156 " 'moore'). Both table filling and Moore's algorithms should\n"
157 " produce identical DFA (up to states relabelling). Table filling\n"
158 " algorithm is much simpler and slower; it serves as a reference\n"
161 "-1 --single-pass Deprecated and does nothing (single pass is by default now).\n"
163 "-W Turn on all warnings.\n"
165 "-Werror Turn warnings into errors. Note that this option along doesn't\n"
166 " turn on any warnings, it only affects those warnings that have\n"
167 " been turned on so far or will be turned on later.\n"
169 "-W<warning> Turn on individual warning.\n"
171 "-Wno-<warning> Turn off individual warning.\n"
173 "-Werror-<warning> Turn on individual warning and treat it as error (this implies\n"
176 "-Wno-error-<warning> Don't treat this particular warning as error. This doesn't turn\n"
177 " off the warning itself.\n"
181 "-Wcondition-order Warn if the generated program makes implicit assumptions about\n"
182 " condition numbering. One should use either '-t, --type-header'\n"
183 " option or '/*!types:re2c*/' directive to generate mapping of\n"
184 " condition names to numbers and use autogenerated condition names.\n"
186 "-Wempty-character-class Warn if regular expression contains empty character class. From\n"
187 " the rational point of view trying to match empty character class\n"
188 " makes no sense: it should always fail. However, for backwards\n"
189 " compatibility reasons re2c allows empty character class and treats\n"
190 " it as empty string. Use '--empty-class' option to change default\n"
193 "-Wmatch-empty-string Warn if regular expression in a rule is nullable (matches empty\n"
194 " string). If DFA runs in a loop and empty match is unintentional\n"
195 " (input position in not advanced manually), lexer may get stuck\n"
196 " in eternal loop.\n"
198 "-Wswapped-range Warn if range lower bound is greater that upper bound. Default\n"
199 " re2c behaviour is to silently swap range bounds.\n"
201 "-Wundefined-control-flow\n"
202 " Warn if some input strings cause undefined control flow in lexer\n"
203 " (the faulty patterns are reported). This is the most dangerous\n"
204 " and common mistake. It can be easily fixed by adding default rule\n"
205 " '*' (this rule has the lowest priority, matches any code unit\n"
206 " and consumes exactly one code unit).\n"
208 "-Wuseless-escape Warn if a symbol is escaped when it shouldn't be. By default re2c\n"
209 " silently ignores escape, but this may as well indicate a typo\n"
210 " or an error in escape sequence.\n"
217 std::string
vernum (PACKAGE_VERSION);
218 if (vernum[1] ==
'.')
220 vernum.insert(0,
"0");
223 if (vernum[3] ==
'.')
225 vernum.insert(2,
"0");
228 if (vernum.length() < 6 || vernum[5] <
'0' || vernum[5] >
'9')
230 vernum.insert(4,
"0");
232 vernum.resize(6,
'0');
234 printf (
"%s\n", vernum.c_str ());
239 printf (
"re2c %s\n", PACKAGE_VERSION);
242 std::string
incond (
const std::string & cond)
247 s +=
"in condition '";
void error(const char *fmt,...)
void warning_start(uint32_t line, bool error)
void error_arg(const char *option)
void warning(const char *type, uint32_t line, bool error, const char *fmt,...)
void warning_end(const char *type, bool error)
std::string incond(const std::string &cond)