[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pygment regex question

From: Luca Fascione
Subject: Re: pygment regex question
Date: Fri, 25 Nov 2022 20:28:14 +0100

On Fri, 25 Nov 2022, 18:11 Jean Abou Samra, <> wrote:

> What makes you think Pygments can’t do this? You can do
> (?<=\w+)\d+

Nothing but my not remembering lookaheads/lookbehinds, which I may argue
aren't very commom constructs. In fact aside from PERL I'm not even sure
what precedent they have (no python doesn't count). Besides, this has
nothing to do with pygments, this is the regex matching engine that does
its thing, pygments just gratefully receives the benefit.

> and things like that. You could also arrange so that the regex parsing a
> pitch leaves you in a state of the lexer where something special will
> happen for \d+

This does sound like pygments code. Interesting, I wasn't aware you could
mess with the state of the lexer to that depth.

However, durations don’t always follow a pitch, as in
> \tuplet 3/2 8. { … }
> which is the reason why we don’t want to do that.

Does Lilypond's parser even know that's a duration? Isn't that just a bare
string that \tuplet internally interprets as a duration?

When implementing this kind of simplistic syntax highlighting (like, ones
not assisted by being aware of the semantics of the language, like you'd
have in Visual Studio or Qt Creator, say) there's always this problem of
how much of the common libraries you reimplement by hand, I'm not sure how
Frescobaldi does its thing, for example, a lot of it seems quite magic to
me (or the result of a huge labour of love... I mean, that program is just

Anyways whatever Frescobaldi does, I wonder if we could mimic for


reply via email to

[Prev in Thread] Current Thread [Next in Thread]