I know regular expressions syntax, but I really don't know how I would manage to make an mml parser that actually works. Turn o4l8cdefg into octave 4, length 8, and c d e f g notes with an 8th note length since no length is specified. Then there's c4., which is c4^c8... Just bla... On 9/5/2016 8:46 AM, Vasilij Schneidermann wrote:
Hello Colton,
I've written a Lisp interpreter in ChucK [1] and went through the parsing stage, among other obstacles. String manipulation is indeed a bit weird, perhaps you're running into a bug where a substring cannot be cut out until the end of a string [2].
If you can get away with it, I recommend using regular expressions to capture a single token, add it to an array of tokens and move forward in the input by its length until the end of input. In this case you might be able to reuse my code. Otherwise you'll need to write a lexer from scratch, for this Jack Crenshaw's compiler tutorial [3] might be useful. Good luck with your endeavor!
[1]: https://lists.cs.princeton.edu/pipermail/chuck-users/2016-August/008110.html [2]: https://github.com/ccrma/chuck/issues/55 [3]: http://www.compilers.iecc.com/crenshaw/ _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users