Hi,

find attached the files for the LilyPond language.
It's not perfect but it's a good start.

I didn't make a Git patch, including the changes needed in Makefile.am and lang.map
But I can do it, if you want me to.

BTW, I can't understand why Git "complains" about this "No newline at end of file":

-tml = tml.lang
\ No newline at end of file
+tml = tml.lang
+ly = lilypond.lang

I've googled a bit but I couldn't find any good answer.

Cheers,
Federico
# LilyPond v2.16.0

string delim "\"" "\"" multiline

comment delim "%{" "%}" multiline nested
comment start "%"

# Scheme
environment scheme delim '#\'?\(' ")" multiline nested begin
  string delim "\"" "\"" multiline
  comment start ";"
  environment scheme delim "(" ")" multiline nested begin
    string delim "\"" "\"" multiline
    comment start ";"
  end
end

vardef SCHEME_VALUE = '##(t|f)', '#{1,2}\'?[[:alnum:]\.:+-]+'
scheme_value = $SCHEME_VALUE


# Symbols
vardef CBRACKET = "{|}|<<|>>"
cbracket = $CBRACKET

symbol = "(|)|~|^|_"
dynamic = '\\(<|>|!|f{1,5}|p{1,5}|m(f|p)|fp|(r|s)fz|s(f|p){1,2})(?!\w)'

# Numbers
specialchar = '(?<!#)-[1-5]\b', '\\[0-9]\b' # strings and fingerings
note_duration = '(?<=[a-zR\',!?>\*])(1|2|4|8|16|32|64|128)(\.+|\b)'
value = '[[:digit:]/]+'

# Markup commands (any \command inside \markup{})
environment markup delim '\\markup\s*\{' "}" multiline nested begin
  # definitions I want to preserve in this environment
  cbracket = $CBRACKET
  string delim "\"" "\"" multiline
  comment delim "%{" "%}" multiline nested
  comment start "%"
  scheme_value = $SCHEME_VALUE
  environment scheme delim '#\'?\(' ")" multiline nested begin
    string delim "\"" "\"" multiline
    comment start ";"
    environment scheme delim "(" ")" multiline nested begin
      string delim "\"" "\"" multiline
      comment start ";"
    end
  end
  # actual definition
  markup_command = '\\[[:alpha:]-]+'

  # needed for nested blocks inside \markup{}
  environment markup delim "{" "}" multiline nested begin
    cbracket = $CBRACKET
    string delim "\"" "\"" multiline
    comment delim "%{" "%}" multiline nested
    comment start "%"
    scheme_value = $SCHEME_VALUE
    environment scheme delim '#\'?\(' ")" multiline nested begin
      string delim "\"" "\"" multiline
      comment start ";"
      environment scheme delim "(" ")" multiline nested begin
        string delim "\"" "\"" multiline
        comment start ";"
      end
    end
    markup_command = '\\[[:alpha:]-]+'
  end
end

lyric_command = '\\(lyricmode|lyrics(to)?)'

# Main commands
preproc = '\\(book(part)?|context|consists|header|include|language|layout',
    'midi|once|override(Property)?|paper|remove(WithTag)?',
    'revert|score|(un)?set|version|with)\b'

# Variables of music functions
variable = '(alto|baritone|bass|french|mezzosoprano|percussion',
    'soprano|subbass|tenor|treble|varbaritone',
    'percent|tremolo|unfold|volta',
    
'\\(aeolian|dorian|ionian|lydian|locrian|minor|major|mixolydian|phrygian))\b'

header_variable = 'arranger', 'breakbefore', 'composer', 'copyright', 'date',
    'dedication', 'enteredby', 'filename', 'footer', 'instrument\b', 
'lastupdated',
    'maintainer(Email|Web)?', 'meter', 'moreInfo',
    'mutopia(composer|instrument|opus|poet|title)?',
    'opus', 'poet', 'piece', 'source(url)?', 'style', '(sub){0,2}title',
    'tagline', 'texidoc'

# Contexts
# old regexp: '([A-Z][a-z]+){2,}' <-- too greedy, a list is better
context = '\\?(ChoirStaff|ChordNames|CueVoice|Devnull|Drum(Staff|Voice)',
    'Dynamics|FiguredBass|FretBoards|Global|GrandStaff',
    'GregorianTranscription(Staff|Voice)|Lyrics|Mensural(Staff|Voice)',
    'NoteNames|PianoStaff|RhythmicStaff|Score|Staff(Group)?',
    'Tab(Staff|Voice)|Vaticana(Staff|Voice)|Voice)\b'

# Layout objects
layout_object = 'Accidental(Cautionary|Placement|Suggestion)?',
    'Ambitus(Accidental|Line|NoteHead)?', 'Arpeggio', 'BalloonTextItem',
    'Bar(Line|Number)?', 
'BassFigure(Alignment(Positioning)?|Bracket|Continuation|Line)?',
    'Beam', 'BendAfter', 'Break(AlignGroup|Alignment)?', 'BreathingSign',
    'ChordName', 'Clef', 'Cluster(Spanner(Beacon)?)', 'CombineTextScript',
    'Cue(Clef|EndClef)?', 'Custos', 'Dot(Column|s)?',
    'Double(PercentRepeat(Counter)?|RepeatSlash)?',
    'Dynamic(LineSpanner|Text|TextSpanner)?\b', 'Episema', 'Fingering', 'Flag',
    'Footnote(Item|Spanner)', 'FretBoard', 'Glissando', 'GraceSpacing',
    'Grid(Line|Point)', 'Hairpin', 'HorizontalBracket',
    'Instrument(Name|Switch)', 'Key(Cancellation|Signature)',
    'Laissez(VibrerTie(Column)?)', 'LedgerLineSpanner',
    'LeftEdge', 'LigatureBracket',
    'Lyric(Extender|Hyphen|Space|Text)', 'MeasureGrouping',
    'MelodyItem', 'MensuralLigature', 'MetronomeMark',
    'MultiMeasureRest(Number|Text)?', 'NonMusicalPaperColumn',
    'Note(Collision|Column|Head|Name|Spacing)', 'OctavateEight',
    'OttavaBracket', 'PaperColumn', 'ParenthesesItem',
    'Percent(Repeat(Counter)?)', 'PhrasingSlur', 'PianoPedalBracket',
    'RehearsalMark', 'Repeat(Slash|Tie(Column)?)', 'Rest(Collision)?',
    'Script(Column|Row)?', 'Slur', 'Sostenuto(Pedal(LineSpanner)?)',
    'SpacingSpanner', 'SpanBar', 'Staff(Grouper|Spacing|Symbol)',
    'StanzaNumber', 'Stem(Tremolo)?', 'StringNumber', 'StrokeFinger',
    'SustainPedal(LineSpanner)?',
    'System(StartBar|StartBrace|StartBracket|StartSquare)?',
    'TabNoteHead', 'Text(Script|Spanner)', 'Tie(Column)?', 'TimeSignature',
    'TrillPitch(Accidental|Group|Head)', 'TrillSpanner',
    'Tuplet(Bracket|Number)', 'UnaCordaPedal(LineSpanner)?',
    'VaticanaLigature', 'Vertical(Alignment|AxisGroup)', 'VoiceFollower',
    'VoltaBracket(Spanner)?'

# Context properties
context_property = '\b[a-z]+([A-Z]+[a-z]+)+',
                   'ottavation|output|stanza|timing|tonic'

# Layout properties
layout_property = '\b[a-z]+(-[a-z]+)+', 'indent'

# All the other commands (including variables defined by users).
# It must be at the end, otherwise the other \command definitions are 
overwritten.
function = '\\[[:alpha:]-]+'

symbol "#C000C0" b ;
cbracket, preproc black b ;
dynamic "#FF8000" b ;

string "#C20F0F" ;
scheme, scheme_value "#A04900" ;
comment gray i ;

note_duration teal ;
value "#808000" ;
specialchar "#FF8000" ;

function "#0000C0" b ;
markup_command "#008000" ;
lyric_command "#006000" b ;

header_variable, variable blue ;
context "#C000C0" b ;
layout_object "#C000C0" ;
context_property, layout_property blue ;

\version "2.14.2"

#(define (naturalize-pitch p)
  "Strings should be read"
   (let ((o (ly:pitch-octave p))
         (a (* 4 (ly:pitch-alteration p)))
         ;; alteration, a, in quarter tone steps,
         ;; for historical reasons
         (n (ly:pitch-notename p)))
     (cond
      ((and (> a 1) (or (eq? n 6) (eq? n 2)))
       (set! a (- a 2))
       (set! n (+ n 1)))
      ((and (< a -1) (or (eq? n 0) (eq? n 3)))
       (set! a (+ a 2))
       (set! n (- n 1))))
     (cond
      ((> a 2) (set! a (- a 4)) (set! n (+ n 1)))
      ((< a -2) (set! a (+ a 4)) (set! n (- n 1))))
     (if (< n 0) (begin (set! o (- o 1)) (set! n (+ n 7))))
     (if (> n 6) (begin (set! o (+ o 1)) (set! n (- n 7))))
     (ly:make-pitch o n (/ a 4))))

\header {
  title = "Maple Leaf Rag"
  composer = "Scott Joplin"
  piece = "Tempo di marcia"
  tagline =
    \markup {
      \override #'(box-padding . 1.0) \override #'(baseline-skip . 2.7) \box
      \center-column {
        \small \line { Sheet music from \with-url #"http://www.MutopiaProject.org";
          \line { \teeny www. \hspace #-0.5 MutopiaProject \hspace #-0.5 \teeny .org \hspace #0.5 } 
        }
      }
    }
}

\paper {
  top-margin = 15
  ragged-right = ##t
  system-system-spacing #'padding = #8
  score-system-spacing =
    #'((basic-distance . 12)
       (minimum-distance . 6)
       (padding . 1)
       (stretchability . 12))
}

top =  \relative c' {
 \override TextScript   #'padding = #2
 
 \key as \major
 \time 2/4
 \clef treble
 \partial 8
 r8 \f |
 \repeat volta 2 {
  r16 as' <es' es,> as, c <es es,>8 g,16 |
  <es' es,>16 g, bes <es es,> ~ <es es,>4 |
  r16 as, <es' es,> as, c <es es,>8 g,16 |
  <es' es,>16 g, bes <es es,> ~ <es es,>8 r16 <es es,> |
  r16 as, ces <fes fes,> r16 <es es,> r16 <es es,> |
  r16 as, ces <fes fes,> r16 <es es,> r8 |
  \change Staff = "down"
   \stemUp r16^\p as,,,-( ces as'-) r as-( ces as'-) \stemNeutral |
  \change Staff = "up"
  r16 as-( ces as'-) r as-( ces as'-) |
  }
}

bottom =  \relative c {
 \key as \major
 \time 2/4
 \clef bass
 \partial 8
 <es es,>8 |
 \repeat volta 2 {
  <as as,> <c as es> <c as es> <a a,> |
  <bes bes,> <des g, es> <des g, es> <es, es,> |
  <as as,> <c as es> <c as es> <a a,> |
  <bes bes,> <des g, es> <des g, es> <es, es,> |
  <fes fes,>4 <es es,>8 <es es,> |
  <fes fes,>4 <es es,>8 r |
  \stemDown as,, r as' r \stemNeutral |
  as' r as' r \clef treble |
  }
}

\score {
  \context PianoStaff <<
  \context Staff = "up"
   \applyMusic #unfold-repeats \top 
  \context Staff = "down"
   \applyMusic #unfold-repeats \bottom
 >>
 
  \midi {
    \context {
      \Score tempoWholesPerMinute = #(ly:make-moment 120 4)
    }
    \context {
      \Voice
      \remove Dynamic_performer
    }
  }
  \layout{}
}

_______________________________________________
Help-source-highlight mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-source-highlight

Reply via email to