Page MenuHomePhabricator

Algorithms (SIMPLEXpress)
Updated 2,392 Days AgoPublic

This is our working whiteboard for algorithms relating to SIMPLEXpress [Project].

Lexing Algorithm

We may be able to better lex each character by using a system of pointers. We maintain a single isMatch pointer which points to one of many charIsX() functions. We change the pointer address using the model.

For example, we encounter ^D in the model as the next character. We make isMatch point to the charIsDigit(), and then run the char ch through that function via the pointer: (*isMatch)(ch), and then process the returned bool/tril value.

There are a few advantages to this:

  • As soon as we encounter a modifier that changes our progress through the model, we can skip updating the pointer. For example, \+ (one or more) will cause us to rewind one step in the model, back to ^D for example, and not update the pointer. This will require some careful coding, but it should work.
  • We *might* get some minor performance improvements, on account of updating a pointer every time we move to the next specifier in the model, instead of using a massive switch statement on each character. Performance gains may be debatable, however, and would need to be benchmarked heavily.
  • The code is a LOT easier to maintain - adding functions and pointers is always friendlier than adding huge cases to a mega-switch.
Last Author
Last Edited
Jan 21 2016, 1:49 PM

Event Timeline

jcmcdonald moved this document from Algorithms (SIMPLEXpress).
jcmcdonald added a subscriber: mrparkman.