anon пре 8 месеци
родитељ
комит
aa89deff8d
1 измењених фајлова са 36 додато и 5 уклоњено
  1. +36
    -5
      source/regex.c

+ 36
- 5
source/regex.c Прегледај датотеку

@@ -265,6 +265,20 @@ static int escape_1_to_N(const char c, compiler_state * cs) {
return 0;
}

static int escape_to_negative(const char c,
compiler_state * cs) {
switch (c) {
case 'D': {
const char digit_chars[] = "0123456789";
strcpy(cs->blacklist, digit_chars);
*cs->is_negative = true;
return sizeof(digit_chars)-1;
};
}

return 0;
}

//static int compile_hologram(char * hologram, char * whitelist) {
// if (hologram[0] == '\\') {
// switch (hologram[1]) {
@@ -280,14 +294,30 @@ static int escape_1_to_N(const char c, compiler_state * cs) {
// }
//}

static int compile_range(const char * const range,
char * whitelist,
bool * is_negative) {
static int compile_dot(compiler_state * cs) {
*cs->do_catch = true;
return true;
}

static int compile_escape(const char c,
compiler_state * cs) {

return escape_1_to_1(c, cs)
|| escape_1_to_N(c, cs)
|| escape_to_negative(c, cs)
//|| compile_hologram(*s, whitelist)
;
}

static int compile_range(const char * const range,
compiler_state * cs) {
assert((range[0] == '[') && "Not a range.");

char * target_list = (*cs->is_negative) ? cs->blacklist : cs->whitelist;

const char * s;
if (range[1] == '^') {
*is_negative = true;
*cs->is_negative = true;
s = range + 2;
} else {
s = range + 1;
@@ -494,7 +524,7 @@ static bool catch_(const regex_t * const regex,
static int regex_assert(const regex_t * const regex,
const char * const string,
int state,
int * width) {
int width) {
for (const char * s = string; *s != '\00'; s++) {
// delta
for (size_t i = 0; i < regex->delta_table.element_count; i++) {
@@ -509,6 +539,7 @@ static int regex_assert(const regex_t * const regex,
}

if (catch_(regex, &state)) {
width += 1;
continue;
}



Loading…
Откажи
Сачувај