diff --git a/external/lilypond-builtins-generator.ly b/external/lilypond-builtins-generator.ly index 57023e9b31..6fafca355f 100644 --- a/external/lilypond-builtins-generator.ly +++ b/external/lilypond-builtins-generator.ly @@ -28,26 +28,29 @@ #(format port "~a" output-preamble) -% We don't want builtins with special characters in this list since -% matching them as names in the lexer could cause problems. For example, -% \= is not included, because accepting ^ in names would cause the = -% in \set tieWaitForNote=##t to be potentially consumed. -% So we exclude them here and list them exhaustively in the lexer. -#(define valid-regexp (make-regexp "^[-_:?!>a-zA-Z]+$")) - #(define (dump-py-list name vals) (let* ((string-vals (map symbol->string vals)) - (filtered-vals - (filter - (lambda (val) - (regexp-exec valid-regexp val)) + (fixed-vals + (filter-map + (lambda (str) + ; To avoid conflicts with Scheme builtins, + ; a leading backslash is prepended to \<, + ; \= and a few others. The lexer finds it + ; itself, so remove it here. + (cond + ((equal? str "\\\\") + #f) + ((string-startswith str "\\") + (string-drop str 1)) + (else + str))) string-vals)) (sorted-vals ; reproducibility ; Avoid duplicates (e.g., identical pitches ; in different languages) (uniq-list - (sort filtered-vals stringstring (car entry))) (match (regexp-exec markup-name-regexp string-name))) (string->symbol (match:substring match 1)))) - markup-commands))) - (dump-py-list 'markup_commands markup-command-names)) + markup-commands)) + (markup-words + (append '(markup markuplist) + markup-command-names))) + (dump-py-list 'markup_commands markup-words)) %% GROBS diff --git a/pygments/lexers/_lilypond_builtins.py b/pygments/lexers/_lilypond_builtins.py index 6391095ed9..6cf911c80f 100644 --- a/pygments/lexers/_lilypond_builtins.py +++ b/pygments/lexers/_lilypond_builtins.py @@ -37,24 +37,14 @@ "layout", "lyricmode", "lyricsto", - "markup", - "markuplist", "midi", "name", "new", "notemode", - "once", - "override", "paper", "remove", - "revert", "score", - "set", - "temporary", - "tweak", "type", - "undo", - "unset", "version", "with", ] @@ -63,6 +53,7 @@ "C", "F", "G", + "G2", "GG", "alto", "altovarC", @@ -70,16 +61,52 @@ "baritonevarC", "baritonevarF", "bass", + "blackmensural-c1", + "blackmensural-c2", + "blackmensural-c3", + "blackmensural-c4", + "blackmensural-c5", "french", "hufnagel-do-fa", + "hufnagel-do1", + "hufnagel-do2", + "hufnagel-do3", + "hufnagel-fa1", + "hufnagel-fa2", "kievan-do", + "medicaea-do1", + "medicaea-do2", + "medicaea-do3", + "medicaea-fa1", + "medicaea-fa2", + "mensural-c1", + "mensural-c2", + "mensural-c3", + "mensural-c4", + "mensural-c5", "mensural-f", "mensural-g", "mezzosoprano", "moderntab", + "neomensural-c1", + "neomensural-c2", + "neomensural-c3", + "neomensural-c4", + "neomensural-c5", "percussion", + "petrucci-c1", + "petrucci-c2", + "petrucci-c3", + "petrucci-c4", + "petrucci-c5", "petrucci-f", + "petrucci-f2", + "petrucci-f3", + "petrucci-f4", + "petrucci-f5", "petrucci-g", + "petrucci-g1", + "petrucci-g2", "soprano", "subbass", "tab", @@ -90,6 +117,11 @@ "varC", "varbaritone", "varpercussion", + "vaticana-do1", + "vaticana-do2", + "vaticana-do3", + "vaticana-fa1", + "vaticana-fa2", "violin", ] @@ -787,6 +819,7 @@ ] music_functions = [ + "=", "absolute", "acciaccatura", "accidentalStyle", @@ -876,6 +909,7 @@ "omit", "once", "ottava", + "override", "overrideProperty", "overrideTimeSignatureSettings", "pageBreak", @@ -910,9 +944,11 @@ "repeat", "resetRelativeOctave", "retrograde", + "revert", "revertTimeSignatureSettings", "rightHandFinger", "scaleDurations", + "set", "settingsFrom", "shape", "shiftDurations", @@ -943,14 +979,19 @@ "undo", "unfoldRepeats", "unfolded", + "unset", "voices", "void", "volta", + "vshape", "withMusicProperty", "xNote", ] dynamics = [ + "!", + "<", + ">", "cr", "cresc", "decr", @@ -986,6 +1027,12 @@ ] articulations = [ + "(", + ")", + "-", + "[", + "]", + "^", "accent", "arpeggio", "breakDynamicSpan", @@ -1064,9 +1111,12 @@ "verylongfermata", "veryshortfermata", "vowelTransition", + "~", ] music_commands = [ + "[", + "]", "aikenHeads", "aikenHeadsMinor", "aikenThinHeads", @@ -1243,6 +1293,8 @@ "walkerHeadsMinor", "xNotesOff", "xNotesOn", + "|", + "~", ] markup_commands = [ @@ -1322,6 +1374,8 @@ "map-markup-commands", "markalphabet", "markletter", + "markup", + "markuplist", "medium", "multi-measure-rest-by-number", "musicglyph", @@ -1349,6 +1403,7 @@ "parenthesize", "path", "pattern", + "polygon", "postscript", "property-recursive", "put-adjacent", @@ -1453,6 +1508,10 @@ "ClusterSpanner", "ClusterSpannerBeacon", "CombineTextScript", + "ControlPointItem", + "ControlPointSpanner", + "ControlPolygonItem", + "ControlPolygonSpanner", "CueClef", "CueEndClef", "Custos", @@ -1725,6 +1784,7 @@ "Script_engraver", "Script_row_engraver", "Separating_line_group_engraver", + "Show_control_points_engraver", "Slash_repeat_engraver", "Slur_engraver", "Slur_performer", @@ -1762,6 +1822,9 @@ ] scheme_functions = [ + "!=", + "*location*", + "*parser*", "Alteration_glyph_engraver", "Bend_spanner_engraver", "Centered_bar_number_align_engraver", @@ -1771,6 +1834,7 @@ "Measure_spanner_engraver", "Merge_mmrest_numbers_engraver", "Merge_rests_engraver", + "Show_control_points_engraver", "Span_stem_engraver", "Spanner_tracking_engraver", "_", @@ -1798,6 +1862,7 @@ "adjust-slash-stencil", "aligned-text-stencil-function", "alist->hash-table", + "aliststencil", "epsfile-markup", @@ -2273,6 +2348,7 @@ "horizontal-slash-interval", "hspace-markup", "huge-markup", + "ice9-format", "ignatzek-chord-names", "index-cell", "index?", @@ -2500,6 +2576,7 @@ "ly:duration-log", "ly:duration-scale", "ly:duration::less?", + "ly:durationpfa", "ly:unit", "ly:unpure-call", "ly:unpure-pure-container-pure-part", @@ -3084,11 +3168,13 @@ "ly:vowel-transition::set-spacing-rods", "ly:warning", "ly:warning-located", + "ly:wide-char->utf-8", "lyric-text::print", "magnification->font-size", "magnify-markup", "magnifyStaff-is-set?", "magstep", + "maj7-modifier", "make-abs-fontsize-markup", "make-accidental-dodecaphonic-rule", "make-accidental-markup", @@ -3253,6 +3339,7 @@ "make-path-stencil", "make-pattern-markup", "make-percent-set", + "make-polygon-markup", "make-postscript-markup", "make-property-recursive-markup", "make-property-set", @@ -3408,6 +3495,7 @@ "moment->fraction", "moment-min", "moment-pair?", + "moment<=?", "move-chord-note", "multi-fork", "multi-measure-rest-by-number-markup", @@ -3547,6 +3635,7 @@ "pitch-of-note", "pitch-step", "polar->rectangular", + "polygon-markup", "position-true-endpoint", "postprocess-output", "postscript->pdf", @@ -3599,6 +3688,7 @@ "rest-markup", "retrieve-glyph-flag", "retrograde-music", + "return-1", "reverse-interval", "revert-fontSize", "revert-head-style", @@ -3611,6 +3701,10 @@ "rhythmic-location->string", "rhythmic-location-bar-number", "rhythmic-location-measure-position", + "rhythmic-location<=?", + "rhythmic-location=?", "rhythmic-location>?", "rhythmic-location?", "rich-bassoon-uber-key-stencil", @@ -3776,9 +3870,11 @@ "sus-modifier", "symbol-concatenate", "symbol-footnotes", + "symbol-key^_!.\-+]", Token.Name.Builtin.Articulation), - # Other articulations whose name is not alphabetic. - (r"[\-_^]?\\[\-^]", Token.Name.Builtin.Articulation), - - # One music function whose name is not alphabetic. - (r"\\=", Token.Name.Builtin.MusicFunction), - - # Dynamics whose name is not alphabetic. - (r"[\-_^]?\\[<>!]", Token.Name.Builtin.Dynamic), - # Fingering numbers, string numbers. (r"[\-_^]?\\?\d+", Token.Name.Builtin.Articulation), - # Any name or unquoted string, possibly referenced via the backslash, - # possibly preceded with a direction specifier. Let - # get_tokens_unprocessed() recognize builtins. [^\W\d_] with - # re.UNICODE is a trick to match any Unicode letter or underscore. - (r"([\-_^]?\\)?(-|[^\W\d])*[^\W\d_]", Token.Name), + # Builtins. + (builtin_backslashed_words(keywords), Token.Keyword), + (builtin_words(clefs), Token.Name.Builtin.Clef), + (builtin_words(scales), Token.Name.Builtin.Scale), + (builtin_words(repeat_types), Token.Name.Builtin.RepeatType), + (builtin_backslashed_words(music_functions), Token.Name.Builtin.MusicFunction), + (builtin_backslashed_words(dynamics), Token.Name.Builtin.Dynamic), + (builtin_backslashed_words(articulations), Token.Name.Builtin.Articulation), + (builtin_backslashed_words(music_commands), Token.Name.Builtin.MusicCommand), + (builtin_backslashed_words(markup_commands), Token.Name.Builtin.MarkupCommand), + (builtin_words(grobs), Token.Name.Builtin.Grob), + (builtin_words(translators), Token.Name.Builtin.Translator), + (builtin_words(contexts), Token.Name.Builtin.Context), + (builtin_words(context_properties), Token.Name.Builtin.ContextProperty), + (builtin_words(grob_properties), Token.Name.Builtin.GrobProperty), + (builtin_words(paper_variables), Token.Name.Builtin.PaperVariable), + (builtin_words(header_variables), Token.Name.Builtin.HeaderVariable), + + # Other backslashed-escaped names (like dereferencing a + # music variable.) Dashes (as in markup commands) and underscores + # (as in engravers) are allowed, but not at the end, to avoid + # matching the direction specifier of the next element. + (r"[\-_^]?\\(-|[^\W\d])*[^\W\d_]", Token.Name.BackslashReference), # Virtually everything can appear in markup mode, so we highlight # as text. diff --git a/pygments/styles/lilypond.py b/pygments/styles/lilypond.py index 222e746a55..a0b4608276 100644 --- a/pygments/styles/lilypond.py +++ b/pygments/styles/lilypond.py @@ -22,7 +22,7 @@ class LilypondStyle(Style): Token.Keyword: "bold", Token.Comment: "italic #A3AAB2", Token.String: "#C7290A", - Token.Pitch: "#911520", + ### Token.Pitch: "#911520", Token.Number: "#976806", # also durations and chord modifiers Token.ChordModifier: "#C0870E", Token.Name.BackslashReference: "bold #08547A",