Re: [GSoC] Proposal: Modular LilyPond Parser (C++)
Carl Sorensen <[email protected]> Fri, 5 Jun 2026 15:21:02 -0600
| Newsgroups | gmane.comp.gnu.lilypond.devel |
|---|---|
| Message-ID | <CACEw7i-fB_Zeq2wEspKPy6nP8yvgkyYi0HYK5v5Q0vP7C=JL5g@mail.gmail.com> |
On Fri, Jun 5, 2026 at 2:28=E2=80=AFPM C. Stroppel <[email protected]> wrot= e: > > The parsing done by available Emacs modes right now is dissatisfactory. > > Other IDE support also would benefit from good and fast parsing. > > Frescobaldi does a comparatively nice job but that does not mean that > > there isn't potential for improvement. > > > First of all, I want to say that I use Frescobaldi a lot and with great > gratitude! > Nevertheless, I have managed to add some features to my own highlighter > in the meantime. For instance, it displays errors if a command is used > in the wrong context, or if expected arguments are missing. > > > The problem with your project is that you want it to land in a space > > where it is thoroughly used by a community that always has a large > > interest in keeping its development going. That is tricky to plan for > > in a reliable manner, so there is always the question how to move best > > such that your project's fate evolves from being bound to a single > > person. Not all factors here are easy to plan for. > > > > > > > Maintenance seems incredibly easy to me when it comes to adding new > commands or limited syntax changes. > Through the specification, the smart lexer reads something like > this:Literal Allowed Context Expected Arguments > Musik-Event > -------------------------------------------------------------------------= ----------- > > "\time" Voice number slash number > time-signature-event "\key" Voice _n_ame scale > key-change-event "\times" Voice Nnumber slash number > music time-scaled-music "\override" Score, Staff... [ context > . ] object property =3D value override-property > But, you see, \time is not limited to a Voice context. By default, the time_signature_engraver is in the Staff context, not the Voice context. But it can be moved within the code. So your "smart lexer" is on its input specification inconsistent with actual LilyPond behavior. %%% \version "2.24" \new Staff << \time 6/8 \new Voice {\voiceOne a'1 b'1 c''1} \new Voice {\voiceTwo d'1 e'1 f'1} >> %%% Furthermore, there are a range of different possible arguments to the \time command; your preliminary specification is incomplete, although I don't know enough about the proposed specification to know if that's planned for being fixed. It appears to me that you are proposing to replace an intentionally flexible (and therefore complex) lexer with a simplified lexer that will not have the same flexibility. The flexibility in LilyPond is one of its greatest assets -- it allows the engraving of music that wasn't explicitly planned for (AFAICT) in the original design; but because of the flexibility inherent in the lexer the types of music to be engraved can be readily expanded. I do not believe there will be a lot of support in the LilyPond community for decreasing the flexibility of the lexer. HTH, Carl