reduced¶
Classes
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
Gets debug boolean of reduced ly parser.
Lexer rules object of reduced ly parser.
apostrophes : APOSTROPHE
apostrophes : apostrophes APOSTROPHE
beam : BRACKET_L
beam : BRACKET_R
chord_body : chord_pitches
chord_body : chord_pitches positive_leaf_duration
chord_pitches : CARAT_L pitches CARAT_R
commas : COMMA
commas : commas COMMA
component : container
component : fixed_duration_container
component : leaf
component : tuplet
component_list :
component_list : component_list component
container : BRACE_L component_list BRACE_R
dots :
dots : dots DOT
fixed_duration_container : BRACE_L FRACTION BRACE_R
leaf : leaf_body post_events
leaf_body : chord_body
leaf_body : note_body
leaf_body : rest_body
measure : PIPE FRACTION component_list PIPE
negative_leaf_duration : INTEGER_N dots
note_body : pitch
note_body : pitch positive_leaf_duration
note_body : positive_leaf_duration
pitch : PITCHNAME
pitch : PITCHNAME apostrophes
pitch : PITCHNAME commas
pitches : pitch
pitches : pitches pitch
positive_leaf_duration : INTEGER_P dots
post_event : beam
post_event : slur
post_event : tie
post_events :
post_events : post_events post_event
rest_body : RESTNAME
rest_body : RESTNAME positive_leaf_duration
rest_body : negative_leaf_duration
slur : PAREN_L
slur : PAREN_R
start :
start : start component
start : start measure
tie : TILDE
tuplet : FRACTION container
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
([1-9]d*/[1-9]d*)
(-[1-9]d*)
([1-9]d*)
t_PAREN_L
t_PAREN_R
t_PIPE
[a-g](ff|ss|f|s|tqf|tqs|qs|qf)?
t_RESTNAME
t_TILDE
t_ignore
n+
tokens
Special methods
Methods
- p_chord_body__chord_pitches__positive_leaf_duration(p)[source]¶
chord_body : chord_pitches positive_leaf_duration
- p_container__BRACE_L__component_list__BRACE_R(p)[source]¶
container : BRACE_L component_list BRACE_R
- p_fixed_duration_container__BRACE_L__FRACTION__BRACE_R(p)[source]¶
fixed_duration_container : BRACE_L FRACTION BRACE_R
- p_measure__PIPE__FRACTION__component_list__PIPE(p)[source]¶
measure : PIPE FRACTION component_list PIPE
- p_rest_body__RESTNAME__positive_leaf_duration(p)[source]¶
rest_body : RESTNAME positive_leaf_duration
Read-only properties
- overridden debug¶
Gets debug boolean of reduced ly parser.
Returns true or false.
- lexer_rules_object¶
Lexer rules object of reduced ly parser.
- parser_rules_object¶
Parser rules object of reduced ly parser.
Functions
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: