regex - OCaml: How to test my own regular expression library -


i made simple regular expression engine, supports concatenation, alternation, closure, , char a .. z.

the way represent nfa , dfa use record:

type state       = int sexp, compare type alphabet    = char sexp, compare type transaction = state * alphabet option * state sexp, compare type d_transaction = state * alphabet * state sexp, compare  type state_set = state_set.t type states_set = states_set.t  type nfa = {   states       : state_set.t ;   alphabets    : alphabet_set.t ;   transactions : transaction_set.t;    start_state  : state;   final_states : state_set.t; }   type dfa = {   d_states       : state_set.t ;   d_alphabets    : alphabet_set.t;   d_transactions : d_transaction_set.t ;   d_start_state  : state ;   d_final_states : state_set.t; } 

for example, string "a*" parsed closure (char 'a'), , transformed nfa: states: 0 1 2 3 alphabets: transactions: 0->e->1, 1->a>2, 2->e->3, 2->e->1, 0->e->3 start_state: 0 final_states: 3

then dfa:

states: 0 1 alphabets: transactions: 0->a->1, 1->a->1 start_state: 0 final_states: 0 1

however, use lot of recursion in code. way program generates state number each node in nfa , dfa realy unpredictable. have no idea how verify if generated dfa correct without using pen , piece of paper test myself

i trying figure out better way test code can add more features program in future.

can please give me suggestions?

one elaborate plan convert dfa regular expression, test whether result equivalent original regular expression. here page giving ways test re equivalence: regex: determine if 2 regular expressions match same input?

the hope 2 inverse conversions debug each other :-)


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -