In response to Werner’s question,
* How do you ensure that your parser stays in sync with the one
LilyPond uses?
I wanted to add a short note from the perspective of my current work on
a modular lexer and parser for LilyPond. While exploring the internals,
I ran into the same issue Werner mentioned: LilyPond has a very complete
/semantic/ layer (contexts, engravers, grobs, music types), but the
/syntax/ is only defined implicitly in |parser.yy| and |lexer.ll|. That
makes it difficult for external tools to rely on a stable description of
what is syntactically valid.
This led me to think about whether we might want a single declarative
grammar source that the community maintains together. The idea would not
be to replace the existing parser, but to have one structured
file—something simple like YAML—
SequentialMusic:
produces:
- ["{", "MusicList", "}"]
ClefCommand:
token: "\\clef"
produces: "ClefEvent"
args: ["Identifier"]
from which different representations could be generated automatically
(EBNF for documentation, JSON for tools, Trie rules for editors, etc.).
That would avoid duplicated effort and make the syntax more accessible
for tool developers.
Before I go further in this direction for my own project, I’d like to
ask whether the community sees value in such a shared grammar source and
whether this is something we might want to maintain collectively.
Best regards, C.