Module: Ibex::Configuration::Registry
- Defined in:
- lib/ibex/configuration.rb
Overview
Closed definitions shared by generation, grammar tests, and analyses.
Constant Summary collapse
- DEFINITIONS =
[ Key.new("grammar.mode", type: :symbol, default: :default, owner: :grammar_contract, allowed_values: %i[default extended], cli_option: :mode), Key.new("parser.algorithm", type: :symbol, default: :lalr, owner: :grammar_contract, allowed_values: %i[slr lalr ielr lr1], cli_option: :algorithm, parser_setting: :algorithm), Key.new("parser.entries", type: :symbol, default: :shared, owner: :grammar_contract, allowed_values: %i[shared isolated], cli_option: :entry_isolation, parser_setting: :entries), Key.new("cst.trivia", type: :symbol, default: :leading, owner: :grammar_contract, allowed_values: %i[leading balanced drop], cli_option: :cst_trivia, parser_setting: :cst_trivia, cli_aliases: ["attach"]), Key.new("parser.superclass", type: :optional_string, default: nil, owner: :grammar_contract, cli_option: :superclass), Key.new("actions.omit_calls", type: :optional_boolean, default: nil, owner: :grammar_contract, cli_option: :omit_actions), Key.new("table.representation", type: :symbol, default: :compact, owner: :project_build, allowed_values: %i[plain compact], cli_option: :table), Key.new("runtime.embedded", type: :boolean, default: false, owner: :project_build, cli_option: :embedded), Key.new("build.debug", type: :boolean, default: false, owner: :project_build, cli_option: :debug), Key.new("source.line_mapping", type: :symbol, default: :actions, owner: :project_build, allowed_values: %i[actions all none], cli_option: :line_convert), Key.new("build.frozen_strings", type: :boolean, default: false, owner: :project_build, cli_option: :frozen), Key.new("build.executable", type: :optional_string, default: nil, owner: :project_build, cli_option: :executable) ].freeze
- BY_NAME =
: Array
DEFINITIONS.to_h { |key| [key.name, key] }.freeze
- CLI_ALGORITHM_VALUES =
(BY_NAME.fetch("parser.algorithm").allowed_values || []).map(&:to_s).freeze
- CLI_CST_TRIVIA_VALUES =
( (BY_NAME.fetch("cst.trivia").allowed_values || []).map(&:to_s) + BY_NAME.fetch("cst.trivia").cli_aliases ).freeze
Class Method Summary collapse
- .fetch(name) ⇒ Object
- .keys ⇒ Object
- .parser_setting_definitions ⇒ Object
- .parser_setting_key(setting) ⇒ Object
- .parser_setting_values(setting) ⇒ Object
Class Method Details
.fetch(name) ⇒ Object
325 326 327 |
# File 'lib/ibex/configuration.rb', line 325 def fetch(name) BY_NAME.fetch(name) { raise ArgumentError, "unknown configuration key: #{name.inspect}" } end |
.keys ⇒ Object
330 331 332 |
# File 'lib/ibex/configuration.rb', line 330 def keys DEFINITIONS end |
.parser_setting_definitions ⇒ Object
335 336 337 338 339 340 341 342 343 344 345 |
# File 'lib/ibex/configuration.rb', line 335 def parser_setting_definitions definitions = {} #: Hash[Symbol, Hash[Symbol, untyped]] @parser_setting_definitions ||= DEFINITIONS.each_with_object(definitions) do |key, definitions| next unless key.parser_setting definitions[key.parser_setting] = { configuration: key.name, values: (key.allowed_values || []).map { |value| value.to_s.to_sym }.freeze }.freeze end.freeze end |
.parser_setting_key(setting) ⇒ Object
353 354 355 |
# File 'lib/ibex/configuration.rb', line 353 def parser_setting_key(setting) fetch(parser_setting_definitions.fetch(setting).fetch(:configuration)) end |
.parser_setting_values(setting) ⇒ Object
348 349 350 |
# File 'lib/ibex/configuration.rb', line 348 def parser_setting_values(setting) parser_setting_definitions.fetch(setting).fetch(:values) end |