Class: Ibex::IR::Automaton
- Inherits:
-
Object
- Object
- Ibex::IR::Automaton
- Defined in:
- lib/ibex/ir/automaton_ir.rb
Overview
Immutable LALR automaton and its source grammar.
Instance Attribute Summary collapse
-
#algorithm ⇒ Object
readonly
: String.
-
#conflict_summary ⇒ Object
readonly
: conflict_summary.
-
#entry_construction ⇒ Object
readonly
: String.
-
#entry_states ⇒ Object
readonly
: Hash[String, Integer].
-
#grammar ⇒ Object
readonly
: Grammar.
-
#grammar_digest ⇒ Object
readonly
: String.
-
#schema_version ⇒ Object
readonly
: Integer.
-
#states ⇒ Object
readonly
: Array.
Instance Method Summary collapse
-
#initialize(grammar:, states:, conflict_summary:, algorithm: "lalr1", grammar_digest: nil, entry_states: nil, entry_construction: "shared") ⇒ Automaton
constructor
A new instance of Automaton.
- #to_h ⇒ Object
Constructor Details
#initialize(grammar:, states:, conflict_summary:, algorithm: "lalr1", grammar_digest: nil, entry_states: nil, entry_construction: "shared") ⇒ Automaton
Returns a new instance of Automaton.
87 88 89 90 91 92 93 |
# File 'lib/ibex/ir/automaton_ir.rb', line 87 def initialize(grammar:, states:, conflict_summary:, algorithm: "lalr1", grammar_digest: nil, entry_states: nil, entry_construction: "shared") initialize_current( grammar: grammar, states: states, conflict_summary: conflict_summary, algorithm: algorithm, grammar_digest: grammar_digest, entry_states: entry_states, entry_construction: entry_construction ) end |
Instance Attribute Details
#algorithm ⇒ Object (readonly)
: String
75 76 77 |
# File 'lib/ibex/ir/automaton_ir.rb', line 75 def algorithm @algorithm end |
#conflict_summary ⇒ Object (readonly)
: conflict_summary
80 81 82 |
# File 'lib/ibex/ir/automaton_ir.rb', line 80 def conflict_summary @conflict_summary end |
#entry_construction ⇒ Object (readonly)
: String
82 83 84 |
# File 'lib/ibex/ir/automaton_ir.rb', line 82 def entry_construction @entry_construction end |
#entry_states ⇒ Object (readonly)
: Hash[String, Integer]
79 80 81 |
# File 'lib/ibex/ir/automaton_ir.rb', line 79 def entry_states @entry_states end |
#grammar ⇒ Object (readonly)
: Grammar
77 78 79 |
# File 'lib/ibex/ir/automaton_ir.rb', line 77 def grammar @grammar end |
#grammar_digest ⇒ Object (readonly)
: String
76 77 78 |
# File 'lib/ibex/ir/automaton_ir.rb', line 76 def grammar_digest @grammar_digest end |
#schema_version ⇒ Object (readonly)
: Integer
81 82 83 |
# File 'lib/ibex/ir/automaton_ir.rb', line 81 def schema_version @schema_version end |
#states ⇒ Object (readonly)
: Array
78 79 80 |
# File 'lib/ibex/ir/automaton_ir.rb', line 78 def states @states end |
Instance Method Details
#to_h ⇒ Object
124 125 126 127 128 129 130 131 132 |
# File 'lib/ibex/ir/automaton_ir.rb', line 124 def to_h value = { ibex_ir: "automaton", schema_version: @schema_version, algorithm: @algorithm, grammar_digest: @grammar_digest, grammar: @grammar.to_h, states: @states.map { |state| state.to_h(@grammar) }, conflict_summary: @conflict_summary } #: Hash[Symbol, Object?] value[:entry_states] = @entry_states unless @entry_states == { @grammar.start => 0 } value[:entry_construction] = @entry_construction value end |