Monday, October 10, 2011

Good news

Parser problem: solved. At least it seems to be. The Java output of Bison looks good, works well so far, and is much better in error reporting thatn cup. So I'm at full speed to migrate existing functionality to the new parser.

Friday, October 7, 2011

Cup problem

I again struggled 4 hours with a problem, actually parsing this correctly:
\markup \huge { asdf }

What you need to know about LilyPond parser, that \huge is interpreted in "markup" lexical state. A lexical state allows you to define a different language for parts of the source file. In LilyPond there is notes state, chords state etc. So "c4" input will mean a note in notes state, but a letter and a number in markup state.
The parser achieves this by the following:
\markup { pushMarkupState(); } \huge --> the huge should be interpreted as a markup command and not a normal escaped word (like an identifier)
But CUP, the parser I use always looks ahead one token. So instead of:
"\markup" MARKUPCOMMAND
it parses
"\markup" KEYWORD
Because the action that pushes into the markup state executed after processing the lookahead token.

That means I have to switch the parser implementation (again)... There is an experimental Java backend for Bison. It might work, we will see...

Tuesday, October 4, 2011

An important milestone

Using the new CUP/JFlex based parser, which essentially means that LilyPondTool has exactly the same grammar as LilyPond, I was able to build LilyPondTool. This is very important, as now I'm ready to fine-tune the parser to fix all pending parsing issues and support all 2.14 constructs.
The advantage of this rewrite is that I'll be able to accomodate to changes in the languages easily.