Class: Ibex::IR::ParserContract
- Inherits:
-
Object
- Object
- Ibex::IR::ParserContract
- Defined in:
- lib/ibex/ir/parser_contract.rb
Overview
Root-owned parser configuration persisted by the current Grammar IR.
Defined Under Namespace
Classes: Entry
Constant Summary collapse
- DEFINITIONS =
@rbs! type definition = { configuration: String, values: Array } type entry_location = { file: String?, line: Integer, column: Integer } type entry_value = String? | bool | entry_location?
Configuration::Registry.parser_setting_definitions
Instance Attribute Summary collapse
-
#algorithm ⇒ Object
readonly
: Entry.
-
#cst_trivia ⇒ Object
readonly
: Entry.
-
#entries ⇒ Object
readonly
: Entry.
Instance Method Summary collapse
-
#configuration_locations ⇒ Object
Source locations supplied to the typed resolver.
-
#configuration_values ⇒ Object
Values supplied to the typed resolver; unspecified fields are absent.
-
#initialize(algorithm: nil, entries: nil, cst_trivia: nil) ⇒ ParserContract
constructor
A new instance of ParserContract.
- #to_h ⇒ Object
Constructor Details
#initialize(algorithm: nil, entries: nil, cst_trivia: nil) ⇒ ParserContract
Returns a new instance of ParserContract.
75 76 77 78 79 80 |
# File 'lib/ibex/ir/parser_contract.rb', line 75 def initialize(algorithm: nil, entries: nil, cst_trivia: nil) @algorithm = normalize_entry(:algorithm, algorithm) @entries = normalize_entry(:entries, entries) @cst_trivia = normalize_entry(:cst_trivia, cst_trivia) freeze end |
Instance Attribute Details
#algorithm ⇒ Object (readonly)
: Entry
70 71 72 |
# File 'lib/ibex/ir/parser_contract.rb', line 70 def algorithm @algorithm end |
#cst_trivia ⇒ Object (readonly)
: Entry
72 73 74 |
# File 'lib/ibex/ir/parser_contract.rb', line 72 def cst_trivia @cst_trivia end |
#entries ⇒ Object (readonly)
: Entry
71 72 73 |
# File 'lib/ibex/ir/parser_contract.rb', line 71 def entries @entries end |
Instance Method Details
#configuration_locations ⇒ Object
Source locations supplied to the typed resolver.
102 103 104 105 106 107 |
# File 'lib/ibex/ir/parser_contract.rb', line 102 def configuration_locations specified_entries.to_h do |entry| location = entry.location || raise("explicit parser contract entry is missing its location") [DEFINITIONS.fetch(entry.key).fetch(:configuration), location] end end |
#configuration_values ⇒ Object
Values supplied to the typed resolver; unspecified fields are absent.
93 94 95 96 97 98 |
# File 'lib/ibex/ir/parser_contract.rb', line 93 def configuration_values specified_entries.to_h do |entry| value = entry.value || raise("explicit parser contract entry is missing its value") [DEFINITIONS.fetch(entry.key).fetch(:configuration), value] end end |
#to_h ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/ibex/ir/parser_contract.rb', line 83 def to_h { algorithm: @algorithm.to_h, entries: @entries.to_h, cst_trivia: @cst_trivia.to_h } end |