Esempio n. 1
0
def parse(string, language='english'):
    r'''Parses LilyPond `string`.

    ..  container:: example

        Parses LilyPond string with English note names:

        >>> container = abjad.parse("{c'4 d'4 e'4 f'4}")
        >>> abjad.show(container) # doctest: +SKIP

    ..  container:: example

        Parses LilyPond string with Dutch note names:

        >>> container = abjad.parse(
        ...     "{c'8 des' e' fis'}",
        ...     language='nederlands',
        ...     )
        >>> abjad.show(container) # doctest: +SKIP

    Returns Abjad component.
    '''
    from abjad.tools import rhythmtreetools
    from abjad.tools import lilypondparsertools
    if string.startswith('abj:'):
        return lilypondparsertools.parse_reduced_ly_syntax(string[4:])
    elif string.startswith('rtm:'):
        return rhythmtreetools.parse_rtm_syntax(string[4:])
    if language not in _lilypond_parsers_by_language:
        parser = lilypondparsertools.LilyPondParser(default_language=language)
        _lilypond_parsers_by_language[language] = parser
    return _lilypond_parsers_by_language[language](string)
Esempio n. 2
0
def parse(arg, language='english'):
    r'''Parses `arg` as LilyPond string.

    ::

        >>> parse("{c'4 d'4 e'4 f'4}")
        Container("c'4 d'4 e'4 f'4")

    ::

        >>> container = _

    ::

        >>> print(format(container))
        {
            c'4
            d'4
            e'4
            f'4
        }

    A pitch-name language may also be specified.

    ::

        >>> parse("{c'8 des' e' fis'}", language='nederlands')
        Container("c'8 df'8 e'8 fs'8")

    Returns Abjad expression.
    '''
    from abjad.tools import rhythmtreetools
    from abjad.tools import lilypondparsertools
    if arg.startswith('abj:'):
        return lilypondparsertools.parse_reduced_ly_syntax(arg[4:])
    elif arg.startswith('rtm:'):
        return rhythmtreetools.parse_rtm_syntax(arg[4:])
    if language not in _lilypond_parsers_by_language:
        parser = lilypondparsertools.LilyPondParser(default_language=language)
        _lilypond_parsers_by_language[language] = parser
    return _lilypond_parsers_by_language[language](arg)
Esempio n. 3
0
def parse(arg, language='english'):
    r'''Parses `arg` as LilyPond string.

    ::

        >>> parse("{c'4 d'4 e'4 f'4}")
        Container("c'4 d'4 e'4 f'4")

    ::

        >>> container = _

    ::

        >>> print(format(container))
        {
            c'4
            d'4
            e'4
            f'4
        }

    A pitch-name language may also be specified.

    ::

        >>> parse("{c'8 des' e' fis'}", language='nederlands')
        Container("c'8 df'8 e'8 fs'8")

    Returns Abjad expression.
    '''
    from abjad.tools import rhythmtreetools
    from abjad.tools import lilypondparsertools
    if arg.startswith('abj:'):
        return lilypondparsertools.parse_reduced_ly_syntax(arg[4:])
    elif arg.startswith('rtm:'):
        return rhythmtreetools.parse_rtm_syntax(arg[4:])
    if language not in _lilypond_parsers_by_language:
        parser = lilypondparsertools.LilyPondParser(default_language=language)
        _lilypond_parsers_by_language[language] = parser
    return _lilypond_parsers_by_language[language](arg)
Esempio n. 4
0
def parse(arg, language='english'):
    r'''Parses `arg` as LilyPond string.

    ::

        >>> parse("{c'4 d'4 e'4 f'4}")
        {c'4, d'4, e'4, f'4}

    ::

        >>> container = _

    ::

        >>> f(container)
        {
            c'4
            d'4
            e'4
            f'4
        }

    A pitch-name language may also be specified.

    ::

        >>> parse("{c'8 des' e' fis'}", language='nederlands')
        {c'8, df'8, e'8, fs'8}

    Returns Abjad expression.
    '''
    from abjad.tools import rhythmtreetools
    from abjad.tools import lilypondparsertools

    if arg.startswith('abj:'):
        return lilypondparsertools.parse_reduced_ly_syntax(arg[4:])
    elif arg.startswith('rtm:'):
        return rhythmtreetools.parse_rtm_syntax(arg[4:])
    return lilypondparsertools.LilyPondParser(default_language=language)(arg)