ReducedLyParser

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.parser" { graph [label="abjad.parser"]; node [color=1]; "abjad.parser.ReducedLyParser.ReducedLyParser" [URL="../api/abjad/parser/ReducedLyParser.html#abjad.parser.ReducedLyParser.ReducedLyParser", color=black, fontcolor=white, label="Reduced\nLy\nParser", target=_top]; } subgraph "cluster_abjad.system" { graph [label="abjad.system"]; node [color=2]; "abjad.system.AbjadObject.AbjadObject" [URL="../api/abjad/parser/../system/AbjadObject.html#abjad.system.AbjadObject.AbjadObject", label="Abjad\nObject", target=_top]; "abjad.system.Parser.Parser" [URL="../api/abjad/parser/../system/Parser.html#abjad.system.Parser.Parser", label=Parser, shape=oval, style=bold, target=_top]; "abjad.system.AbjadObject.AbjadObject" -> "abjad.system.Parser.Parser"; } subgraph cluster_builtins { graph [label=builtins]; node [color=3]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } "abjad.system.Parser.Parser" -> "abjad.parser.ReducedLyParser.ReducedLyParser"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; }

class abjad.parser.ReducedLyParser.ReducedLyParser(debug=False)

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

>>> parser = abjad.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)
>>> abjad.show(container) 

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.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to '' or 'storage'. Interprets '' equal to 'storage'.

Returns string.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.


Methods

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

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+

(Parser).tokenize(string)

Tokenize string and print results.


Read-only properties

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.