Parser

abstract class abctools.Parser(debug=False)

Abstract base class for Abjad parsers.

Rules objects for lexing and parsing must be defined by overriding the abstract properties lexer_rules_object and parser_rules_object.

For most parsers these properties should simply return self.

Lineage

digraph InheritanceGraph { graph [background=transparent, bgcolor=transparent, color=lightslategrey, fontname=Arial, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, root="__builtin__.object", splines=spline, style="dotted, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=12, penwidth=2, style="filled, rounded"]; edge [color=lightsteelblue2, penwidth=2]; subgraph cluster_abctools { graph [label=abctools]; "abjad.tools.abctools.AbjadObject.AbjadObject" [color=1, group=0, label=AbjadObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" [color=1, group=0, label=AbstractBase, shape=box]; "abjad.tools.abctools.Parser.Parser" [color=black, fontcolor=white, group=0, label=<<B>Parser</B>>, shape=oval, style="filled, rounded"]; "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.abctools.Parser.Parser"; "abjad.tools.abctools.AbjadObject.AbstractBase" -> "abjad.tools.abctools.AbjadObject.AbjadObject"; } subgraph cluster_lilypondparsertools { graph [label=lilypondparsertools]; "abjad.tools.lilypondparsertools.LilyPondParser.LilyPondParser" [color=3, group=2, label=LilyPondParser, shape=box]; "abjad.tools.lilypondparsertools.ReducedLyParser.ReducedLyParser" [color=3, group=2, label=ReducedLyParser, shape=box]; "abjad.tools.lilypondparsertools.SchemeParser.SchemeParser" [color=3, group=2, label=SchemeParser, shape=box]; } subgraph cluster_rhythmtreetools { graph [label=rhythmtreetools]; "abjad.tools.rhythmtreetools.RhythmTreeParser.RhythmTreeParser" [color=4, group=3, label=RhythmTreeParser, shape=box]; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=2, group=1, label=object, shape=box]; } "abjad.tools.abctools.Parser.Parser" -> "abjad.tools.lilypondparsertools.LilyPondParser.LilyPondParser"; "abjad.tools.abctools.Parser.Parser" -> "abjad.tools.lilypondparsertools.ReducedLyParser.ReducedLyParser"; "abjad.tools.abctools.Parser.Parser" -> "abjad.tools.lilypondparsertools.SchemeParser.SchemeParser"; "abjad.tools.abctools.Parser.Parser" -> "abjad.tools.rhythmtreetools.RhythmTreeParser.RhythmTreeParser"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

debug True if the parser runs in debugging mode.
lexer The parser’s PLY Lexer instance.
lexer_rules_object The object containing the parser’s lexical rule definitions.
logger The parser’s Logger instance.
logger_path The output path for the parser’s logfile.
output_path The output path for files associated with the parser.
parser The parser’s PLY LRParser instance.
parser_rules_object The object containing the parser’s syntactical rule definitions.
pickle_path The output path for the parser’s pickled parsing tables.
tokenize(input_string) Tokenize input string and print results.
__call__(input_string) Parse input_string and return result.
__eq__(expr) Is true when ID of expr equals ID of Abjad object.
__format__([format_specification]) Formats Abjad object.
__hash__() Hashes Abjad object.
__ne__(expr) Is true when Abjad object does not equal expr.
__repr__() Gets interpreter representation of Abjad object.

Read-only properties

Parser.debug

True if the parser runs in debugging mode.

Parser.lexer

The parser’s PLY Lexer instance.

abstract Parser.lexer_rules_object

The object containing the parser’s lexical rule definitions.

Parser.logger

The parser’s Logger instance.

Parser.logger_path

The output path for the parser’s logfile.

Parser.output_path

The output path for files associated with the parser.

Parser.parser

The parser’s PLY LRParser instance.

abstract Parser.parser_rules_object

The object containing the parser’s syntactical rule definitions.

Parser.pickle_path

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

Methods

Parser.tokenize(input_string)

Tokenize input string and print results.

Special methods

Parser.__call__(input_string)

Parse input_string and return result.

(AbjadObject).__eq__(expr)

Is true when ID of expr equals ID of Abjad object. Otherwise false.

Returns true or false.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to ‘’ or ‘storage’. Interprets ‘’ equal to ‘storage’.

Returns string.

(AbjadObject).__hash__()

Hashes Abjad object.

Required to be explicitly redefined on Python 3 if __eq__ changes.

Returns integer.

(AbjadObject).__ne__(expr)

Is true when Abjad object does not equal expr. Otherwise false.

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.