abjad.reduced

abjad.parsers.reduced.parse_reduced_ly_syntax(string)

Parse the reduced LilyPond rhythmic syntax:

abjad.parsers.reduced.ReducedLyParser([debug])

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

abjad.parsers.reduced.parse_reduced_ly_syntax(string) Container[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.. { 3:5 } c'4")
>>> for component in container:
...     component
... 
Note("c'4")
Rest('r4.')
Note("c'8..")
Tuplet('3:5', '')
Note("c'4")
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.makers.tweak_tuplet_bracket_edge_height(tuplet)
>>> abjad.tweak(tuplet[-1], r"\tweak text #tuplet-number::calc-fraction-text")
>>> 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)  

debug

Gets debug boolean of reduced ly parser.

lexer_rules_object

Lexer rules object of reduced ly parser.

p_apostrophes__APOSTROPHE(p)

apostrophes : APOSTROPHE

p_apostrophes__apostrophes__APOSTROPHE(p)

apostrophes : apostrophes APOSTROPHE

p_beam__BRACKET_L(p)

beam : BRACKET_L

p_beam__BRACKET_R(p)

beam : BRACKET_R

p_chord_body__chord_pitches(p)

chord_body : chord_pitches

p_chord_body__chord_pitches__positive_leaf_duration(p)

chord_body : chord_pitches positive_leaf_duration

p_chord_pitches__CARAT_L__pitches__CARAT_R(p)

chord_pitches : CARAT_L pitches CARAT_R

p_commas__COMMA(p)

commas : COMMA

p_commas__commas__commas(p)

commas : commas COMMA

p_component__container(p)

component : container

p_component__fixed_duration_container(p)

component : fixed_duration_container

p_component__leaf(p)

component : leaf

p_component__tuplet(p)

component : tuplet

p_component_list__EMPTY(p)

component_list :

p_component_list__component_list__component(p)

component_list : component_list component

p_container__BRACE_L__component_list__BRACE_R(p)

container : BRACE_L component_list BRACE_R

p_dots__EMPTY(p)

dots :

p_dots__dots__DOT(p)

dots : dots DOT

p_error(p)

p_fixed_duration_container__BRACE_L__FRACTION__BRACE_R(p)

fixed_duration_container : BRACE_L FRACTION BRACE_R

p_leaf__leaf_body__post_events(p)

leaf : leaf_body post_events

p_leaf_body__chord_body(p)

leaf_body : chord_body

p_leaf_body__note_body(p)

leaf_body : note_body

p_leaf_body__rest_body(p)

leaf_body : rest_body

p_measure__PIPE__FRACTION__component_list__PIPE(p)

measure : PIPE FRACTION component_list PIPE

p_negative_leaf_duration__INTEGER_N__dots(p)

negative_leaf_duration : INTEGER_N dots

p_note_body__pitch(p)

note_body : pitch

p_note_body__pitch__positive_leaf_duration(p)

note_body : pitch positive_leaf_duration

p_note_body__positive_leaf_duration(p)

note_body : positive_leaf_duration

p_pitch__PITCHNAME(p)

pitch : PITCHNAME

p_pitch__PITCHNAME__apostrophes(p)

pitch : PITCHNAME apostrophes

p_pitch__PITCHNAME__commas(p)

pitch : PITCHNAME commas

p_pitches__pitch(p)

pitches : pitch

p_pitches__pitches__pitch(p)

pitches : pitches pitch

p_positive_leaf_duration__INTEGER_P__dots(p)

positive_leaf_duration : INTEGER_P dots

p_post_event__beam(p)

post_event : beam

p_post_event__slur(p)

post_event : slur

p_post_event__tie(p)

post_event : tie

p_post_events__EMPTY(p)

post_events :

p_post_events__post_events__post_event(p)

post_events : post_events post_event

p_rest_body__RESTNAME(p)

rest_body : RESTNAME

p_rest_body__RESTNAME__positive_leaf_duration(p)

rest_body : RESTNAME positive_leaf_duration

p_rest_body__negative_leaf_duration(p)

rest_body : negative_leaf_duration

p_slur__PAREN_L(p)

slur : PAREN_L

p_slur__PAREN_R(p)

slur : PAREN_R

p_start__EMPTY(p)

start :

p_start__start__component(p)

start : start component

p_start__start__measure(p)

start : start measure

p_tie__TILDE(p)

tie : TILDE

p_tuplet__FRACTION__container(p)

tuplet : FRACTION container

parser_rules_object

Parser rules object of reduced ly parser.

t_FRACTION(t)

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

t_INTEGER_N(t)

(-[1-9]d*)

t_INTEGER_P(t)

([1-9]d*)

t_PITCHNAME(t)

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

t_error(t)

t_newline(t)

n+

overridden debug

Gets debug boolean of reduced ly parser.

Returns true or false.

lexer_rules_object

Lexer rules object of reduced ly parser.

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

parser_rules_object

Parser rules object of reduced ly parser.

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+