#include "src/codegen/code_names.h"
#include "src/codegen/input_api.h"
#include "src/ir/regexp/encoding/enc.h"
+#include "src/ir/regexp/empty_class_policy.h"
#include "src/util/c99_stdint.h"
namespace re2c
extern Enc encoding;
extern InputAPI input_api;
+extern empty_class_policy_t empty_class_policy;
+
} // end namespace re2c
#endif // _RE2C_GLOBALS_
--- /dev/null
+#ifndef _RE2C_IR_REGEXP_EMPTY_CLASS_POLICY_
+#define _RE2C_IR_REGEXP_EMPTY_CLASS_POLICY_
+
+namespace re2c {
+
+enum empty_class_policy_t
+{
+ EMPTY_CLASS_MATCH_EMPTY, // match on empty input
+ EMPTY_CLASS_MATCH_NONE, // fail to match on any input
+ EMPTY_CLASS_ERROR // compilation error
+};
+
+} // namespace re2c
+
+#endif // _RE2C_IR_REGEXP_EMPTY_CLASS_POLICY_
Enc encoding;
InputAPI input_api;
+empty_class_policy_t empty_class_policy = EMPTY_CLASS_MATCH_EMPTY;
+
uint32_t last_fill_index = 0;
CodeNames mapCodeName;
mbo_opt_struct(13, 1, "encoding-policy"),
mbo_opt_struct(14, 1, "input"),
mbo_opt_struct(15, 0, "skeleton"),
+ mbo_opt_struct(16, 1, "empty-class"),
mbo_opt_struct('-', 0, NULL) /* end of args */
};
"--skeleton Instead of embedding re2c-generated code into C/C++ source,\n"
" generate a self-contained program for the same DFA.\n"
" Most useful for correctness and performance testing.\n"
+ "\n"
+ "--empty-class policy What to do if user inputs empty character class. policy can be\n"
+ " one of the following: 'match-empty' (match empty input, default),\n"
+ " 'match-none' (fail to match on any input), 'error' (compilation\n"
+ " error). Note that there are various ways to construct empty class,\n"
+ " e.g: [], [^\\x00-\\xFF], [\\x00-\\xFF]\\[\\x00-\\xFF].\n"
;
}
flag_skeleton = true;
input_api.set (InputAPI::CUSTOM);
break;
+
+ case 16:
+ if (strcmp(opt_arg, "match-empty") == 0)
+ empty_class_policy = EMPTY_CLASS_MATCH_EMPTY;
+ else if (strcmp(opt_arg, "match-none") == 0)
+ empty_class_policy = EMPTY_CLASS_MATCH_NONE;
+ else if (strcmp(opt_arg, "error") == 0)
+ empty_class_policy = EMPTY_CLASS_ERROR;
+ else
+ {
+ std::cerr << "re2c: error: Invalid empty class policy: \"" << opt_arg << "\"\n";
+ return 1;
+ }
+ break;
}
}