lilypond-devel
[Top][All Lists]
Advanced

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

Re: pygment regex question


From: Jean Abou Samra
Subject: Re: pygment regex question
Date: Fri, 25 Nov 2022 18:00:34 +0100


> Le 25 nov. 2022 à 17:52, Werner LEMBERG <wl@gnu.org> a écrit :
> 
> 
>> well -3 seems to be matching it, (say in a-3, I'm aware this is a
>> fingering/articulation mark, not a duration).  It appears to be an
>> attempt to match a signed integer followed by zero or more dots.
> 
> The thing is that the regular expressions match both LilyPond and
> Scheme syntax.



Uh? No they don’t, look at SchemeLexer and its horrendous regexes to parse 
numbers (also written by yours truly).

However,

\musicFunction 4

could be an integer or a duration, and

\musicFunction -4

could be an integer or a fingering, depending on how musicFunction is defined, 
which is the reason why no attempt is made to distinguish between integers and 
durations, and -\d+ is treated like that as well for lack of a good way to know 
if it was actually a fingering.



>> It sucks that pygments regexes are context free, though.  This
>> should be using regex capturing and be more like
>> `[a-g]((?:\d+|\\longa|\\breve)\.*)` or better yet be more like
>> `[a-g]((?:2|4|8|16|32|64|128|\\longa|\\breve)\.*)`, it's not like a5
>> is a valid token...
> 
> I don't think stuff like `ag` is a problem – it's not the job of
> pygments to validate LilyPond input.

Indeed.



reply via email to

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