From aaa12504c6095b2cdfa213a3d4b269bbd5e7038a Mon Sep 17 00:00:00 2001 From: JSDurand Date: Sun, 6 Feb 2022 23:35:42 +0800 Subject: dfa: add the type of "ranged dfas" Strictly speaking, they are not DFA's at all. They contain ranges which can determine whether or not a character belongs to the specified predicate terminal. --- src/test/check_pred.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/test/check_pred.c') diff --git a/src/test/check_pred.c b/src/test/check_pred.c index 14081d5..8a3e613 100644 --- a/src/test/check_pred.c +++ b/src/test/check_pred.c @@ -1,3 +1,4 @@ +#include "limits.h" #include "time.h" #include "../cnp.h" @@ -88,7 +89,7 @@ main(int UNUSED argc, char ** UNUSED argv) *(user_name+4) = 'i'; *(user_name+5) = 0; - user_name_s = new_utf8(user_name, 5); + user_name_s = (str *) new_utf8(user_name, 5); SAFE_MALLOC(char, raw_name, 8, return 1;); @@ -101,7 +102,7 @@ main(int UNUSED argc, char ** UNUSED argv) *(raw_name+6) = 'Z'; *(raw_name+7) = 0; - raw_name_s = new_utf8(raw_name, 6); + raw_name_s = (str *) new_utf8(raw_name, 6); SAFE_MALLOC(NUM, pred_bytes, 52, return 1;); @@ -111,9 +112,11 @@ main(int UNUSED argc, char ** UNUSED argv) for (int i = 0; i < 26; i++) *(pred_bytes+pred_bytes_len++) = 'A' + i; - if (add_to_list(preds, new_ptd(user_name_s, raw_name_s, - dfa_from_bytes_neg - (pred_bytes_len, pred_bytes)))) { + if (add_to_list(preds, + new_ptd(user_name_s, raw_name_s, + dfa_from_ranges_both + (2, (NUM[]) { 'a', 'z', 'A', 'Z' }, + 2, (NUM[]) { 'b', 'w', 'B', 'W' })))) { fleprintf0("Fail to add a predicate\n"); return 1; } @@ -126,7 +129,7 @@ main(int UNUSED argc, char ** UNUSED argv) print_grammar(g); - utf8 *string = new_utf8("++--__,.(){}><|", 15); + utf8 *string = new_utf8("aaaxxxxaaaaaaaa", 15); printf("\nPrinting the input...\n%s\n", get_data((str *) string)); -- cgit v1.2.3-18-g5258