lilypondparsertools.LilyPondParser

Inheritance diagram of abjad.tools.lilypondparsertools.LilyPondParser.LilyPondParser.LilyPondParser

class abjad.tools.lilypondparsertools.LilyPondParser.LilyPondParser.LilyPondParser(default_language='english', debug=False)[source]

Parses a subset of LilyPond input syntax:

abjad> from abjad.tools.lilypondparsertools import LilyPondParser
abjad> parser = LilyPondParser( )
abjad> input = r"\new Staff { c'4 ( d'8 e' fs'2) \fermata }"
abjad> result = parser(input)
abjad> f(result)
\new Staff {
    c'4 (
    d'8
    e'8
    fs'2 -\fermata )
}

LilyPondParser defaults to English note names, but any of the other languages supported by LilyPond may be used:

abjad> parser = LilyPondParser('nederlands')
abjad> input = '{ c des e fis }'
abjad> result = parser(input)
abjad> f(result)
{
    c4
    df4
    e4
    fs4
}

Briefly, LilyPondParser understands theses aspects of LilyPond syntax:

  • Notes, chords, rests, skips and multi-measure rests

  • Durations, dots, and multipliers

  • All pitchnames, and octave ticks

  • Simple markup (i.e. c'4 ^ "hello!")

  • Most articulations

  • Most spanners, including beams, slurs, phrasing slurs, ties, and glissandi

  • Most context types via \new and \context, as well as context ids (i.e. \new Staff = "foo" { })

  • Variable assignment (i.e. global = { \time 3/4 } \new Staff { \global })

  • Many music functions:
    • \acciaccatura
    • \appoggiatura
    • \bar
    • \breathe
    • \clef
    • \grace
    • \key
    • \transpose
    • \language
    • \makeClusters
    • \mark
    • \oneVoice
    • \relative
    • \skip
    • \slashedGrace
    • \time
    • \times
    • \transpose
    • \voiceOne, \voiceTwo, \voiceThree, \voiceFour

LilyPondParser currently DOES NOT understand many other aspects of LilyPond syntax:

  • \markup
  • \book, \bookpart, \header, \layout, \midi and \paper
  • \repeat and \alternative
  • Lyrics
  • \chordmode, \drummode or \figuremode
  • Property operations, such as \override, \revert, \set, \unset, and \once
  • Music functions which generate or extensively mutate musical structures
  • Embedded Scheme statements (anything beginning with #)

Returns LilyPondParser instance.

Read-only Properties

LilyPondParser.available_languages[source]

Tuple of pitch-name languages supported by LilyPondParser:

abjad> from abjad.tools.lilypondparsertools import LilyPondParser
abjad> parser = LilyPondParser( )
abjad> parser.available_languages
('catalan', 'deutsch', 'english', 'espanol', 'italiano', 'nederlands', 'norsk', 'portugues', 'suomi', 'svenska', 'vlaams')

Return tuple.

Read/write Properties

LilyPondParser.default_language[source]

Read/write attribute to set parser’s default pitch-name language:

abjad> from abjad.tools.lilypondparsertools import LilyPondParser
abjad> parser = LilyPondParser( )
abjad> parser.default_language
'english'
abjad> parser('{ c df e fs }')
{c4, df4, e4, fs4}
abjad> parser.default_language = 'nederlands'
abjad> parser.default_language
'nederlands'
abjad> parser('{ c des e fis }')
{c4, df4, e4, fs4}

Special Methods

LilyPondParser.__call__(input_string)[source]
LilyPondParser.__delattr__()

x.__delattr__(‘name’) <==> del x.name

Note

Inherited from __builtin__.object

LilyPondParser.__eq__(arg)

True when id(self) equals id(arg).

Return boolean.

Note

Inherited from abctools.AbjadObject

LilyPondParser.__ge__(arg)

Abjad objects by default do not implement this method.

Raise exception.

Note

Inherited from abctools.AbjadObject

LilyPondParser.__gt__(arg)

Abjad objects by default do not implement this method.

Raise exception

Note

Inherited from abctools.AbjadObject

LilyPondParser.__hash__() <==> hash(x)

Note

Inherited from __builtin__.object

LilyPondParser.__le__(arg)

Abjad objects by default do not implement this method.

Raise exception.

Note

Inherited from abctools.AbjadObject

LilyPondParser.__lt__(arg)

Abjad objects by default do not implement this method.

Raise exception.

Note

Inherited from abctools.AbjadObject

LilyPondParser.__ne__(arg)

True when id(self) does not equal id(arg).

Return boolean.

Note

Inherited from abctools.AbjadObject

LilyPondParser.__repr__()

Interpreter representation of Abjad object defaulting to class name, mandatory arguments, keyword arguments.

Return string.

Note

Inherited from abctools.AbjadObject

LilyPondParser.__setattr__()

x.__setattr__(‘name’, value) <==> x.name = value

Note

Inherited from __builtin__.object

LilyPondParser.__str__() <==> str(x)

Note

Inherited from __builtin__.object

Table Of Contents

This Page