37 lines
1.3 KiB
C++
37 lines
1.3 KiB
C++
#include <libregexis024sol/expr_parse_functions/command_recognition.h>
|
|
#include <libregexis024sol/utils.h>
|
|
#include <libregexis024sol/expr_compiler.h>
|
|
#include <libregexis024sol/sol_misc_base.h>
|
|
|
|
#define aux_ERROR_CHECK do { if (ctx.error) { return; } } while (0)
|
|
#define aux_THROW(str) do { report(ctx, "regex: " str); return; } while (0)
|
|
|
|
namespace regexis024 {
|
|
const char* header_command_dfa_names[] = {"dfa", "determinize", NULL};
|
|
|
|
const char* header_command_select_names[] = {"s", "select", "selarr", "selectional", NULL};
|
|
|
|
bool is_header_cmd(const Command &cmd) {
|
|
return cmd.tilda || is_header_dfa_cmd(cmd), is_header_dfa_cmd(cmd);
|
|
}
|
|
|
|
bool is_header_dfa_cmd(const Command &cmd) {
|
|
return is_string_in_stringset(cmd.name.c_str(), header_command_dfa_names);
|
|
}
|
|
|
|
bool is_header_select_cmd(const Command &cmd) {
|
|
return is_string_in_stringset(cmd.name.c_str(), header_command_select_names);
|
|
}
|
|
|
|
void int_parse_with_limit_concern(const std::string &str, REGEX_IS024_MeaningContext &ctx, size_t &res, int lim) {
|
|
res = 0;
|
|
for (char ch: str){
|
|
if (!('0' <= ch && ch <= '9'))
|
|
aux_THROW("bad integer argument");
|
|
res = res * 10 + (ch - '0');
|
|
if (res > (size_t)lim)
|
|
aux_THROW("integer is too big");
|
|
}
|
|
}
|
|
}
|