Day 4 Week 2 on JFLAP

I started this morning by fixing a bug in conversionExercise. There was no alert when the state label added by users is incorrect sometimes. After that I did a lot of restructuring of the code. I moved common functions such as serializeGraphToXML to a library-like js file serializableGraph.js. Declarations of functions bugged me a little. In JavaScript, if a function is defined as var x = function() then the calls of this function must be after the declaration, but if it is defined as function x() then it can be called everywhere. I also renamed some variables with regular expression search in Vim. I gave names with more practical meanings.

Then I added the multiple problem feature to conversionExercise just like what I did toFATester. The problems are loaded from an XML file using a synchronous ajax call. This gives me a warning in the console that says synchronous calls can harm user experience, but since problems are essential to the page, I ignored the warning. One thing to note is that in FATester I am using JSON files to store the problems because that exercise does not require the storage of graphs. I plan to develop an exercise editor for instructors which takes the input of graph or test cases and output json or XML files.

I also improved the performance of the right-click menu by highlighting the node chosen. “Change Label” and “Clear Label” buttons are added as well. The next step is to do the same for edge editing. It would also be nice to let users drag nodes to move them, but this will require the program to update positions of the node, labels and edges connected to it along the way. I am trying this tomorrow. Another form of exercise might also be implemented: take a malformed DFA and improve it.

Comments are closed.