At the start of the summer I had great plans for progress, but I found myself struggling to create momentum. As well as making progress on the software related to my PhD, I was hoping to make progress on my music sequencer project, and make various improvements to my video production tool. I think I let the pressure of having too many things to do get to me, but also there were other factors. I don’t cope well with high temperatures, and this has been the hottest summer ever in Glasgow. I also spent a week in Cornwall, which was very nice, but even hotter than Glasgow. I spent most that week trying to find dense deciduous woodlands to hide inside. Sadly it was not a great week for birdwatching, because the high temperatures also encourage the birds to hide.
One thing I did achieve before going on holiday was creating a little “Core language” parser and interpreter. The interpreter will provide a sound base for the next generation of the LePTa and LePTa template language interpreters. I’m quite pleased with this little interpreter, which I think will provide a very good, flexible, starting point for a variety of interpreter projects.
So, after a few weeks of being fairly useless, last week I started a new strategy. A sort of micro-self-management, with my day split into half hour sections, allocated to specific projects. So far it’s working reasonably well for progress on my PhD, though not for anything else. I’ve also started working out in the summerhouse where I have a lot fewer distractions than at my desk.
One of my key targets for the summer was creating a final specification for my parser definition language, LePTa, and I’m very close to getting there. One problem with the previous version of it was that it was rather harder to extend a language that had been in the previous generation of my tools. To solve this I needed to simplify the structure of the states that are the highest level of the parsing process. By making them as simple as possible, I can allow an extension to insert new match rules into a state. At the same time as simplifying the states I need to find a way to keep in the flexibility of the more structured states that I have been using. I think I probably have a solution, but I need to implement it well enough to do some testing before I can be sure that it is sufficient.
Implementing that solution has been but I have been doing for the last week and half: I created some examples, and started writing a parser for them using regular expressions. That didn’t go very well. In some ways my new structure is more complicated than the previous one, so it needs a better approach to parsing, so I have rewritten the parser using the current version of LePTa, generating PHP code. My generated PHP uses a visitor pattern, with a builder class generating the output. This is similar to the way ANTLR works, but I found it really quite cumbersome. If-else structures that can take either a block or a single statement after each part are surprisingly awkward to deal with. The solution is to have the builder having more connection to the structure of the parser, but the easiest way to do that is to have them in the same code base. This is what my first generation tool did, with a very elegant way of tracking nodes through the data structure or AST. This is something I want to bring back, but then there is the issue of combining handwritten and generated code. What I’m going to do is try and use the constrained editor plug-in for Monaco to combine generated and user code with only the user code sections being editable. I hope this will satisfy the expectation that generated code should not be edited, whilst allowing the clarity of having the two bits of code that deal with the same input adjacent to each other.