Finally have a matching algorithm that is nearly working. Optional repeats cause infinite regress at the moment though. Damn those empty matches.