Class: Clef::Parser::LilypondParser

Inherits:
Object
  • Object
show all
Defined in:
lib/clef/parser/lilypond_parser.rb

Constant Summary collapse

SUPPORTED_COMMANDS =
%w[\\clef \\key \\major \\minor \\time \\tempo \\relative \\new \\with].freeze
DYNAMIC_COMMANDS =
Clef::Notation::Dynamic::TYPES.map { |type| "\\#{type}" }.freeze
STAFF_COMMAND =
/\\new\s+(?:Staff|PianoStaff|StaffGroup)/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(plugins: Clef.plugins) ⇒ LilypondParser

Returns a new instance of LilypondParser.

Parameters:



13
14
15
16
# File 'lib/clef/parser/lilypond_parser.rb', line 13

def initialize(plugins: Clef.plugins)
  @plugins = plugins
  @warnings = []
end

Instance Attribute Details

#pluginsObject (readonly)

Returns the value of attribute plugins.



10
11
12
# File 'lib/clef/parser/lilypond_parser.rb', line 10

def plugins
  @plugins
end

#warningsObject (readonly)

Returns the value of attribute warnings.



10
11
12
# File 'lib/clef/parser/lilypond_parser.rb', line 10

def warnings
  @warnings
end

Instance Method Details

#parse(input) ⇒ Clef::Core::Score

Parameters:

  • input (String)

Returns:



20
21
22
23
24
25
26
# File 'lib/clef/parser/lilypond_parser.rb', line 20

def parse(input)
  cleaned = strip_comments(input)
  @warnings = unsupported_command_warnings(cleaned)
  score = build_score(cleaned)
  plugins.run_hook(:on_after_parse, score)
  score
end