Re: Color variables/symbols (was: pygment regex question)

2022-11-26 Thread Lukas-Fabian Moser
Am 26.11.22 um 18:35 schrieb Lukas-Fabian Moser: Am 26.11.22 um 18:11 schrieb David Kastrup: \override NoteHead.color = red actually lowers the barrier immensely compared with \override NoteHead #'color = #red red and #red are completely different Scheme entities. Yes indeed (I suspect

Color variables/symbols (was: pygment regex question)

2022-11-26 Thread Lukas-Fabian Moser
Am 26.11.22 um 18:11 schrieb David Kastrup: \override NoteHead.color = red actually lowers the barrier immensely compared with \override NoteHead #'color = #red red and #red are completely different Scheme entities. Yes indeed (I suspect red gets parsed to #'red, no?). I never took the

Re: pygment regex question

2022-11-26 Thread David Kastrup
Lukas-Fabian Moser writes: > \override NoteHead.color = red > > actually lowers the barrier immensely compared with > > \override NoteHead #'color = #red red and #red are completely different Scheme entities. > - of course that's more than one syntax simplificiation here, but it > shows how

Re: pygment regex question

2022-11-26 Thread Lukas-Fabian Moser
Hi Jean, FWIW, the last one a4_boringly is something I wouldn't do, since a_boringly does not work Yes, d'accord. Personally, I tend to leave out # when possible for numbers, and also leave out #' for symbols when possible because it is not only shorter, but allows the syntax

Re: pygment regex question

2022-11-26 Thread David Kastrup
Jean Abou Samra writes: >> \version "2.23.10" >> >> \removeWithTag dyn \new Staff = upper { >>   \tag dyn <>\mf >>   \ottava -1 >>   a4_boringly >> } >> >> But of course there's always the danger of beginners tripping up on >> this because they do not recognise the situations where #/'/"" are >>

Re: pygment regex question,Re: pygment regex question

2022-11-26 Thread Jean Abou Samra
Le 26/11/2022 à 16:16, Werner LEMBERG a écrit : OK, but where exactly is this documented? Is this missing, or am I blind? I think it's not written anywhere. If it is missing, could a Scheme expert please write some lines that I could incorporate into an MR? Nothing complicated: If a

Re: pygment regex question,Re: pygment regex question

2022-11-26 Thread Werner LEMBERG
>>> Are there still cases where `#` is mandatory for numbers? >>> Otherwise the documentation could be updated to remove all `#`. >> >> Yes, there are: In markup, for example. >> >> \markup \fontsize 3 Hi >> >> is still illegal. OK, but where exactly is this documented? Is this missing, or am I

Re: pygment regex question

2022-11-26 Thread Jean Abou Samra
Le 26/11/2022 à 11:32, Lukas-Fabian Moser a écrit : Hi Werner, In the NR, most such functions have its argument starting with `#`, for example ``` \ottava #-2 ``` Are there still cases where `#` is mandatory for numbers? Otherwise the documentation could be updated to remove all `#`.

Re: pygment regex question

2022-11-26 Thread Lukas-Fabian Moser
Hi Werner, In the NR, most such functions have its argument starting with `#`, for example ``` \ottava #-2 ``` Are there still cases where `#` is mandatory for numbers? Otherwise the documentation could be updated to remove all `#`. Yes, there are: In markup, for example. \markup

Re: pygment regex question

2022-11-26 Thread Werner LEMBERG
>> 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, [...] > > Thanks, I didn't think of music functions. In the NR, most such functions have its argument

Re: pygment regex question,Re: pygment regex question

2022-11-25 Thread Werner LEMBERG
>> Why not. If you want to be even more precise on what you want to >> match: >> >> -\d+|((\d+|\\breve|\\longa)\.*) > > if someone really wants to touch that, please note that \maxima too > is a duration. Indeed, this is missing. I will add this to my work that will eventually result in a PR

Re: pygment regex question

2022-11-25 Thread Jean Abou Samra
Le 25/11/2022 à 20:28, Luca Fascione a écrit : 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

Re: pygment regex question,Re: pygment regex question

2022-11-25 Thread Benkő Pál
Jean Abou Samra ezt írta (időpont: 2022. nov. 25., P, 18:05): > > Le 25 nov. 2022 à 17:54, Werner LEMBERG a écrit : > > OK, but shouldn't this be rather > > (-?\d+|\\longa|\\breve)\.* > > then? > > Why not. If you want to be even more precise on what you want to match: > >

Re: pygment regex question

2022-11-25 Thread Luca Fascione
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

Re: pygment regex question

2022-11-25 Thread Werner LEMBERG
>> 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). Thanks for the correction; this makes adjusting the regular expressions simpler :-) >

Re: pygment regex question

2022-11-25 Thread Jean Abou Samra
> Le 25 nov. 2022 à 18:03, Luca Fascione a écrit : > > It's not a validation, it's an anchor, it avoids it matching other numbers. > That's why the capture. If pygments was better designed it'll let you do > semi-context-sensitive > stuff like this, so you could say "numbers, but only if the

Re: pygment regex question,Re: pygment regex question

2022-11-25 Thread Jean Abou Samra
> Le 25 nov. 2022 à 17:54, Werner LEMBERG a écrit : > >  >> >>> Note that at the time this regex is active, numbers are taken care >>> of. >> >> Floats are, integers not. > > OK, but shouldn't this be rather > > ``` > (-?\d+|\\longa|\\breve)\.* > ``` > > then? Why not. If you want to

Re: pygment regex question,Re: pygment regex question

2022-11-25 Thread Luca Fascione
I agree this would be a better regex, yes. (You still have that double re: thing in the subject going on, Werner) L On Fri, 25 Nov 2022, 17:55 Werner LEMBERG, wrote: > >> Note that at the time this regex is active, numbers are taken care > >> of. > > > > Floats are, integers not. > > OK, but

Re: pygment regex question

2022-11-25 Thread Luca Fascione
It's not a validation, it's an anchor, it avoids it matching other numbers. That's why the capture. If pygments was better designed it'll let you do semi-context-sensitive stuff like this, so you could say "numbers, but only if the follow a note name" -> durations L On Fri, 25 Nov 2022, 17:52

Re: pygment regex question

2022-11-25 Thread Jean Abou Samra
> Le 25 nov. 2022 à 17:52, Werner LEMBERG 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

Re: pygment regex question

2022-11-25 Thread Jean Abou Samra
 > Le 25 nov. 2022 à 17:16, Luca Fascione 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. > > It sucks that pygments regexes

Re: pygment regex question,Re: pygment regex question

2022-11-25 Thread Werner LEMBERG
>> Note that at the time this regex is active, numbers are taken care >> of. > > Floats are, integers not. OK, but shouldn't this be rather ``` (-?\d+|\\longa|\\breve)\.* ``` then? Werner

Re: pygment regex question

2022-11-25 Thread Werner LEMBERG
> 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. > It sucks

Re: pygment regex question

2022-11-25 Thread Luca Fascione
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. It sucks that pygments regexes are context free, though. This should be using regex capturing and be

Re: pygment regex question

2022-11-25 Thread Jean Abou Samra
Le 25/11/2022 à 14:23, Werner LEMBERG a écrit : Note that at the time this regex is active, numbers are taken care of. Floats are, integers not. Jean OpenPGP_signature Description: OpenPGP digital signature

pygment regex question

2022-11-25 Thread Werner LEMBERG
Looking into `lilypond.py` (in `pygments.zip`), I wonder what exactly this regex does: ``` # Integer, or duration with optional augmentation dots. We have no # way to distinguish these, so we highlight them all as numbers. (r"-?(\d+|\\longa|\\breve)\.*", Token.Number), ``` What is `-?` good