August 3: Stefan had a few radical suggestions on the quoting code:

  • Having a sentinel to mark the end of each parsing table. This avoids passing in the length to the expand_string() function.
  • Reducing the number of cases in the expand_string() function. This would reduce the number of fields in the parsing table strcuture.

The first one was pretty simple to do. Now, the second one needed some effort. I went through the code and realised that the four cases I had could be reduced to two: one to stop parsing at a given token, and the other to call another function. This could be done because only quotes are handled using recursion, and they have consistent behaviour. Since this represents a change from previous methods, I've put it in another branch: scripting_test_parse, and the commits are:

August 5: Started on the documentation: Features added

August 6: More changes to the expand_string function:

  • Remove the in_quotes parameter from the expand_string function. Since quotes are already handled by another function, there's no need to put it here.
  • Change the sentinel from 127 to 0. This has the advantage that it will exit the function on end of the string.

As they say, perfection is achieved not when no more can be added, but when no more can be removed. So, I'm trying to reduce the code as much as possible.

QR Code
QR Code soc:2009:lynusvaz:journal:week11 (generated for current page)