Today, a night has been finished, it feels like to say the experience it ... In fact, the course itself has provided the relevant algorithm pseudo-code, then there should be no problem in the thinking, then finally I used a night to complete the final Hopcroft algorithm ... In fact, the difficulty lies in the use of data structures, this side of the graph theory algorithm familiar words should feel relaxed some ... (Unfortunately I have not yet learned the algorithm ...) In terms of the specific code implementation itself, the first difficulty lies in how to split the existing state, compared to say that it is a splitting, but the actual operation is a bunch of DFA, I just started to prepare a state (for the third question of the representation of the data structure, Similar to the 12th step of Nfastate and dfastate) in the detection process will belong to a different state set of nodes to save, and then to guide the different states of the node in a different state node (actually here is a string instead of one), In a node that directs the same state, it is saved with next in Dfastate, and then I overlook a problem that was the fatal flaw in my original design that directly led me to debug for 2 hours, that is, if I save it this way, Then the information of next in the node will change, because in the final state it still depends on saving the first dfastate by the Dfastate's next to connect the other dfastate to connect the whole node graph, then two places actually use next to save the information, The result of the conflict is an infinite loop, and I debug for 2 hours in a baffling wireless-based cycle ... My tears fell when I found this problem ... Finally I used the ArrayList to save the 2 nodes I'm going to split ... Another difficulty is that you have to constantly in the 3, 4 layers of nested loops to stay awake, my advice is to draw the analysis side of the writing, otherwise it is easy to come back to the toilet of their own confused forced ... The reason that can be done so quickly thanks to the Java GC mechanism, I feel that if it is C or C + +, then I this program, OH da ...
Finally, attach the code link and test results:
Https://github.com/zhang77595103/lexerGenerator
Read the Book of Dragons compilation Principle hand-written lexical generator (3) ...