reduced

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph "cluster_abjad.parsers.base" { graph [label="abjad.parsers.base"]; node [color=1]; "abjad.parsers.base.Parser" [URL="../api/abjad/parsers/base.html#abjad.parsers.base.Parser", label=Parser, target=_top]; } subgraph "cluster_abjad.parsers.reduced" { graph [label="abjad.parsers.reduced"]; node [color=2]; "abjad.parsers.reduced.ReducedLyParser" [URL="../api/abjad/parsers/reduced.html#abjad.parsers.reduced.ReducedLyParser", color=black, fontcolor=white, label="Reduced\nLy\nParser", target=_top]; } subgraph cluster_builtins { graph [label=builtins]; node [color=3]; "builtins.object" [URL="https://docs.python.org/3.10/library/functions.html#object", label=object, target=_top]; } "abjad.parsers.base.Parser" -> "abjad.parsers.reduced.ReducedLyParser"; "builtins.object" -> "abjad.parsers.base.Parser"; }


Classes

ReducedLyParser

Parses the "reduced-ly" syntax, a modified subset of LilyPond syntax.

class abjad.parsers.reduced.ReducedLyParser(debug=False)[source]

Parses the “reduced-ly” syntax, a modified subset of LilyPond syntax.

>>> from abjad.parsers.reduced import ReducedLyParser
>>> parser = ReducedLyParser()

Understands LilyPond-like representation of notes, chords and rests:

>>> string = "c'4 r8. <b d' fs'>16"
>>> container = parser(string)
>>> abjad.show(container)  

Also parses bare duration as notes on middle-C, and negative bare durations as rests:

>>> string = "4 -8 16. -32"
>>> container = parser(string)
>>> abjad.show(container)  

Note that the leaf syntax is greedy, and therefore duration specifiers following pitch specifiers will be treated as part of the same expression. The following produces 2 leaves, rather than 3:

>>> string = "4 d' 4"
>>> container = parser(string)
>>> abjad.show(container)  

Understands LilyPond-like default durations:

>>> string = "c'4 d' e' f'"
>>> container = parser(string)
>>> abjad.show(container)  

Also understands various types of container specifications.

Can create arbitrarily nested tuplets:

>>> string = "2/3 { 4 4 3/5 { 8 8 8 } }"
>>> tuplet = parser(string)
>>> abjad.show(tuplet)  

Can create measures too:

>>> string = "| 4/4 4 4 4 4 || 3/8 8 8 8 |"
>>> container = parser(string)
>>> staff = abjad.Staff([container])
>>> score = abjad.Score([staff], name="Score")
>>> abjad.show(staff)  

Finally, understands ties, slurs and beams:

>>> string = "c16 [ ( d ~ d ) f ]"
>>> container = parser(string)
>>> abjad.show(container)  

Attributes Summary

debug

Gets debug boolean of reduced ly parser.

lexer_rules_object

Lexer rules object of reduced ly parser.

p_apostrophes__APOSTROPHE

apostrophes : APOSTROPHE

p_apostrophes__apostrophes__APOSTROPHE

apostrophes : apostrophes APOSTROPHE

p_beam__BRACKET_L

beam : BRACKET_L

p_beam__BRACKET_R

beam : BRACKET_R

p_chord_body__chord_pitches

chord_body : chord_pitches

p_chord_body__chord_pitches__positive_leaf_duration

chord_body : chord_pitches positive_leaf_duration

p_chord_pitches__CARAT_L__pitches__CARAT_R

chord_pitches : CARAT_L pitches CARAT_R

p_commas__COMMA

commas : COMMA

p_commas__commas__commas

commas : commas COMMA

p_component__container

component : container

p_component__fixed_duration_container

component : fixed_duration_container

p_component__leaf

component : leaf

p_component__tuplet

component : tuplet

p_component_list__EMPTY

component_list :

p_component_list__component_list__component

component_list : component_list component

p_container__BRACE_L__component_list__BRACE_R

container : BRACE_L component_list BRACE_R

p_dots__EMPTY

dots :

p_dots__dots__DOT

dots : dots DOT

p_error

p_fixed_duration_container__BRACE_L__FRACTION__BRACE_R

fixed_duration_container : BRACE_L FRACTION BRACE_R

p_leaf__leaf_body__post_events

leaf : leaf_body post_events

p_leaf_body__chord_body

leaf_body : chord_body

p_leaf_body__note_body

leaf_body : note_body

p_leaf_body__rest_body

leaf_body : rest_body

p_measure__PIPE__FRACTION__component_list__PIPE

measure : PIPE FRACTION component_list PIPE

p_negative_leaf_duration__INTEGER_N__dots

negative_leaf_duration : INTEGER_N dots

p_note_body__pitch

note_body : pitch

p_note_body__pitch__positive_leaf_duration

note_body : pitch positive_leaf_duration

p_note_body__positive_leaf_duration

note_body : positive_leaf_duration

p_pitch__PITCHNAME

pitch : PITCHNAME

p_pitch__PITCHNAME__apostrophes

pitch : PITCHNAME apostrophes

p_pitch__PITCHNAME__commas

pitch : PITCHNAME commas

p_pitches__pitch

pitches : pitch

p_pitches__pitches__pitch

pitches : pitches pitch

p_positive_leaf_duration__INTEGER_P__dots

positive_leaf_duration : INTEGER_P dots

p_post_event__beam

post_event : beam

p_post_event__slur

post_event : slur

p_post_event__tie

post_event : tie

p_post_events__EMPTY

post_events :

p_post_events__post_events__post_event

post_events : post_events post_event

p_rest_body__RESTNAME

rest_body : RESTNAME

p_rest_body__RESTNAME__positive_leaf_duration

rest_body : RESTNAME positive_leaf_duration

p_rest_body__negative_leaf_duration

rest_body : negative_leaf_duration

p_slur__PAREN_L

slur : PAREN_L

p_slur__PAREN_R

slur : PAREN_R

p_start__EMPTY

start :

p_start__start__component

start : start component

p_start__start__measure

start : start measure

p_tie__TILDE

tie : TILDE

p_tuplet__FRACTION__container

tuplet : FRACTION container

parser_rules_object

Parser rules object of reduced ly parser.

start

t_APOSTROPHE

t_BRACE_L

t_BRACE_R

t_BRACKET_L

t_BRACKET_R

t_CARAT_L

t_CARAT_R

t_COMMA

t_DOT

t_FRACTION

([1-9]d*/[1-9]d*)

t_INTEGER_N

(-[1-9]d*)

t_INTEGER_P

([1-9]d*)

t_PAREN_L

t_PAREN_R

t_PIPE

t_PITCHNAME

[a-g](ff|ss|f|s|tqf|tqs|qs|qf)?

t_RESTNAME

t_TILDE

t_error

t_ignore

t_newline

n+

tokens


Special methods

(Parser).__call__(string)

Parse string and return result.


Methods

p_apostrophes__APOSTROPHE(p)[source]

apostrophes : APOSTROPHE

p_apostrophes__apostrophes__APOSTROPHE(p)[source]

apostrophes : apostrophes APOSTROPHE

p_beam__BRACKET_L(p)[source]

beam : BRACKET_L

p_beam__BRACKET_R(p)[source]

beam : BRACKET_R

p_chord_body__chord_pitches(p)[source]

chord_body : chord_pitches

p_chord_body__chord_pitches__positive_leaf_duration(p)[source]

chord_body : chord_pitches positive_leaf_duration

p_chord_pitches__CARAT_L__pitches__CARAT_R(p)[source]

chord_pitches : CARAT_L pitches CARAT_R

p_commas__COMMA(p)[source]

commas : COMMA

p_commas__commas__commas(p)[source]

commas : commas COMMA

p_component__container(p)[source]

component : container

p_component__fixed_duration_container(p)[source]

component : fixed_duration_container

p_component__leaf(p)[source]

component : leaf

p_component__tuplet(p)[source]

component : tuplet

p_component_list__EMPTY(p)[source]

component_list :

p_component_list__component_list__component(p)[source]

component_list : component_list component

p_container__BRACE_L__component_list__BRACE_R(p)[source]

container : BRACE_L component_list BRACE_R

p_dots__EMPTY(p)[source]

dots :

p_dots__dots__DOT(p)[source]

dots : dots DOT

p_error(p)[source]
p_fixed_duration_container__BRACE_L__FRACTION__BRACE_R(p)[source]

fixed_duration_container : BRACE_L FRACTION BRACE_R

p_leaf__leaf_body__post_events(p)[source]

leaf : leaf_body post_events

p_leaf_body__chord_body(p)[source]

leaf_body : chord_body

p_leaf_body__note_body(p)[source]

leaf_body : note_body

p_leaf_body__rest_body(p)[source]

leaf_body : rest_body

p_measure__PIPE__FRACTION__component_list__PIPE(p)[source]

measure : PIPE FRACTION component_list PIPE

p_negative_leaf_duration__INTEGER_N__dots(p)[source]

negative_leaf_duration : INTEGER_N dots

p_note_body__pitch(p)[source]

note_body : pitch

p_note_body__pitch__positive_leaf_duration(p)[source]

note_body : pitch positive_leaf_duration

p_note_body__positive_leaf_duration(p)[source]

note_body : positive_leaf_duration

p_pitch__PITCHNAME(p)[source]

pitch : PITCHNAME

p_pitch__PITCHNAME__apostrophes(p)[source]

pitch : PITCHNAME apostrophes

p_pitch__PITCHNAME__commas(p)[source]

pitch : PITCHNAME commas

p_pitches__pitch(p)[source]

pitches : pitch

p_pitches__pitches__pitch(p)[source]

pitches : pitches pitch

p_positive_leaf_duration__INTEGER_P__dots(p)[source]

positive_leaf_duration : INTEGER_P dots

p_post_event__beam(p)[source]

post_event : beam

p_post_event__slur(p)[source]

post_event : slur

p_post_event__tie(p)[source]

post_event : tie

p_post_events__EMPTY(p)[source]

post_events :

p_post_events__post_events__post_event(p)[source]

post_events : post_events post_event

p_rest_body__RESTNAME(p)[source]

rest_body : RESTNAME

p_rest_body__RESTNAME__positive_leaf_duration(p)[source]

rest_body : RESTNAME positive_leaf_duration

p_rest_body__negative_leaf_duration(p)[source]

rest_body : negative_leaf_duration

p_slur__PAREN_L(p)[source]

slur : PAREN_L

p_slur__PAREN_R(p)[source]

slur : PAREN_R

p_start__EMPTY(p)[source]

start :

p_start__start__component(p)[source]

start : start component

p_start__start__measure(p)[source]

start : start measure

p_tie__TILDE(p)[source]

tie : TILDE

p_tuplet__FRACTION__container(p)[source]

tuplet : FRACTION container

t_FRACTION(t)[source]

([1-9]d*/[1-9]d*)

t_INTEGER_N(t)[source]

(-[1-9]d*)

t_INTEGER_P(t)[source]

([1-9]d*)

t_PITCHNAME(t)[source]

[a-g](ff|ss|f|s|tqf|tqs|qs|qf)?

t_error(t)[source]
t_newline(t)[source]

n+

(Parser).tokenize(string)

Tokenize string and print results.


Read-only properties

overridden debug

Gets debug boolean of reduced ly parser.

Returns true or false.

(Parser).lexer

Gets parser’s PLY Lexer instance.

lexer_rules_object

Lexer rules object of reduced ly parser.

(Parser).logger

Gets parser’s logger.

(Parser).logger_path

Gets parser’s logfile output path.

(Parser).output_path

Gets output path for files associated with the parser.

(Parser).parser

Gets parser’s PLY LRParser instance.

parser_rules_object

Parser rules object of reduced ly parser.

(Parser).pickle_path

Gets output path for the parser’s pickled parsing tables.


Functions

parse_reduced_ly_syntax

Parse the reduced LilyPond rhythmic syntax:

abjad.parsers.reduced.parse_reduced_ly_syntax(string)[source]

Parse the reduced LilyPond rhythmic syntax:

>>> string = "4 -4. 8.. 5/3 { } 4"
>>> container = abjad.parsers.reduced.parse_reduced_ly_syntax(string)
>>> container
Container("c'4 r4. c'8.. { 5/3 } c'4")
>>> for component in container:
...     component
... 
Note("c'4")
Rest('r4.')
Note("c'8..")
Tuplet('3:5', '')
Note("c'4")
Return type:

Container