Write a program in C that takes two command line arguments d
Write a program in C that takes two command line arguments (do not prompt the user). The first is the filename for an NFA file, and the second is the filename of a strings file. Your program will convert the NFA to an equivalent DFA and determine whether each string in the strings file is in the language of the NFA or not.
The NFA file has the following contents: The first line identifies the number of states (N) from 0 to N-1 The second line identifies the alphabet as a string of lowercase letters in no particular order, without spaces between the letters. Epsilon isn\'t identified here but is essentially a member of the alphabet. The third line identifies the initial state The fourth line is a list of final states by state number, in no particular order, with one space between each state number The remainder of the file contains one line for each of the N states from 0 to N-1. These lines indicate the destination states for transitions on alphabet members with the last entry for epsilon transitions. Each set of target states per alphabet member is a no-whitespace, comma-delimited list of states by number. -1 indicates no transition on the character. E.g., given an alphabet line (the second line) with the string \"ca\", the line \"2 -1 1,4\" indicates this state transitions to 2 on \'c\', nowhere on \'a\', and to states 1 or 4 on epsilon.
Example NFA file
4
ab
0
2
-1 1 -1
-1 1 2
0,2 3 -1
-1 3 1
The strings file contains one string per line to be tested against the given NFA. A line with only the string \"E\" is the same as the empty string. Your program should determine whether each string is accepted by the NFA by print \"good\" or \"fail\" followed by a space character and the string tested.
Example string file
aab
ba
b
E
aaabbbaba
baaabbaaaa
abbaaba
Solution
#include