Class: HeadMusic::Notation::LilyPond::Parser
- Inherits:
-
Object
- Object
- HeadMusic::Notation::LilyPond::Parser
- Defined in:
- lib/head_music/notation/lily_pond/parser.rb
Overview
Interprets a LilyPond string as a HeadMusic::Content::Flow.
The pipeline validates in stages — blank input, lexing, delimiter balance, then the document's structure and every pitch, duration, key, and meter — before a flow is built, so a caller never receives a reference to a partially built flow. Unsupported constructs are named by the reader rather than swept up front, so one inside a \layout or \midi block the reader skips never reaches a caller.
Instance Method Summary collapse
- #build_flow ⇒ Object private
- #flow ⇒ Object
-
#initialize(lily_pond_string) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(lily_pond_string) ⇒ Parser
Returns a new instance of Parser.
12 13 14 |
# File 'lib/head_music/notation/lily_pond/parser.rb', line 12 def initialize(lily_pond_string) @lily_pond_string = lily_pond_string end |
Instance Method Details
#build_flow ⇒ Object (private)
22 23 24 25 26 27 28 |
# File 'lib/head_music/notation/lily_pond/parser.rb', line 22 def build_flow ParsePreflight.ensure_input_present(@lily_pond_string) tokens = Lexer.new(@lily_pond_string).tokens ParsePreflight.ensure_balanced_delimiters(tokens) document = DocumentReader.new(tokens).document FlowBuilder.new(document).flow end |
#flow ⇒ Object
16 17 18 |
# File 'lib/head_music/notation/lily_pond/parser.rb', line 16 def flow @flow ||= build_flow end |