Class: Antlr4::Runtime::ATNConfigSet
- Inherits:
-
Object
- Object
- Antlr4::Runtime::ATNConfigSet
- Defined in:
- lib/antlr4/runtime/atn_config_set.rb
Direct Known Subclasses
Defined Under Namespace
Classes: AbstractConfigHashSet, ConfigEqualityComparator, ConfigHashSet
Instance Attribute Summary collapse
-
#configs ⇒ Object
Returns the value of attribute configs.
-
#conflictingAlts ⇒ Object
Returns the value of attribute conflictingAlts.
-
#dips_into_outer_context ⇒ Object
Returns the value of attribute dips_into_outer_context.
-
#full_ctx ⇒ Object
Returns the value of attribute full_ctx.
-
#has_semantic_context ⇒ Object
Returns the value of attribute has_semantic_context.
-
#readonly ⇒ Object
Returns the value of attribute readonly.
-
#unique_alt ⇒ Object
Returns the value of attribute unique_alt.
Instance Method Summary collapse
- #add(config, merge_cache = nil) ⇒ Object
- #alts ⇒ Object
- #empty? ⇒ Boolean
- #find_first_rule_stop_state ⇒ Object
-
#initialize(full_ctx = true) ⇒ ATNConfigSet
constructor
A new instance of ATNConfigSet.
- #optimize_configs(interpreter) ⇒ Object
- #size ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(full_ctx = true) ⇒ ATNConfigSet
Returns a new instance of ATNConfigSet.
12 13 14 15 16 17 18 19 20 |
# File 'lib/antlr4/runtime/atn_config_set.rb', line 12 def initialize(full_ctx = true) @full_ctx = full_ctx @has_semantic_context = false @readonly = false @config_lookup = ConfigHashSet.new @configs = [] @dips_into_outer_context = false @unique_alt = ATN::INVALID_ALT_NUMBER end |
Instance Attribute Details
#configs ⇒ Object
Returns the value of attribute configs.
6 7 8 |
# File 'lib/antlr4/runtime/atn_config_set.rb', line 6 def configs @configs end |
#conflictingAlts ⇒ Object
Returns the value of attribute conflictingAlts.
10 11 12 |
# File 'lib/antlr4/runtime/atn_config_set.rb', line 10 def conflictingAlts @conflictingAlts end |
#dips_into_outer_context ⇒ Object
Returns the value of attribute dips_into_outer_context.
8 9 10 |
# File 'lib/antlr4/runtime/atn_config_set.rb', line 8 def dips_into_outer_context @dips_into_outer_context end |
#full_ctx ⇒ Object
Returns the value of attribute full_ctx.
9 10 11 |
# File 'lib/antlr4/runtime/atn_config_set.rb', line 9 def full_ctx @full_ctx end |
#has_semantic_context ⇒ Object
Returns the value of attribute has_semantic_context.
4 5 6 |
# File 'lib/antlr4/runtime/atn_config_set.rb', line 4 def has_semantic_context @has_semantic_context end |
#readonly ⇒ Object
Returns the value of attribute readonly.
5 6 7 |
# File 'lib/antlr4/runtime/atn_config_set.rb', line 5 def readonly @readonly end |
#unique_alt ⇒ Object
Returns the value of attribute unique_alt.
7 8 9 |
# File 'lib/antlr4/runtime/atn_config_set.rb', line 7 def unique_alt @unique_alt end |
Instance Method Details
#add(config, merge_cache = nil) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/antlr4/runtime/atn_config_set.rb', line 33 def add(config, merge_cache = nil) raise IllegalStateException, 'This set is readonly' if @readonly if config.semantic_context != SemanticContext::NONE @has_semantic_context = true end @dips_into_outer_context = true if config.outer_context_depth > 0 existing = @config_lookup.get_or_add config if existing == config @cached_hash_code = -1 @configs << config return true end root_is_wildcard = !@full_ctx merged = PredictionContextUtils.merge(existing.context, config.context, root_is_wildcard, merge_cache) existing.reaches_into_outer_context = [existing.reaches_into_outer_context, config.reaches_into_outer_context].max if config.precedence_filter_suppressed? existing.precedence_filter_suppressed(true) end existing.context = merged true end |
#alts ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/antlr4/runtime/atn_config_set.rb', line 22 def alts alts = BitSet.new i = 0 while i < @configs.length config = @configs[i] alts.set(config.alt) i += 1 end alts end |
#empty? ⇒ Boolean
78 79 80 |
# File 'lib/antlr4/runtime/atn_config_set.rb', line 78 def empty? @config_lookup.empty? end |
#find_first_rule_stop_state ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/antlr4/runtime/atn_config_set.rb', line 63 def find_first_rule_stop_state result = nil i = 0 while i < @configs.length config = @configs[i] if config.state.is_a? RuleStopState result = config break end i += 1 end result end |
#optimize_configs(interpreter) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/antlr4/runtime/atn_config_set.rb', line 116 def optimize_configs(interpreter) raise IllegalStateException, 'This set is readonly' if @readonly return if @config_lookup.empty? i = 0 while i < @configs.length config = @configs[i] config.context = interpreter.cached_context(config.context) i += 1 end end |
#size ⇒ Object
142 143 144 |
# File 'lib/antlr4/runtime/atn_config_set.rb', line 142 def size @configs.length end |
#to_s ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/antlr4/runtime/atn_config_set.rb', line 82 def to_s buf = '' buf << '<' i = 0 while i < @configs.length c = @configs[i] buf << c.to_s << ' ' i += 1 end buf << '>' if @has_semantic_context buf << ',hasSemanticContext=' << @has_semantic_context.to_s end buf << ',uniqueAlt=' << @unique_alt if @unique_alt != ATN::INVALID_ALT_NUMBER unless @conflictingAlts.nil? buf << ',conflictingAlts=' << @conflictingAlts.to_s end buf << ',dipsIntoOuterContext' if @dips_into_outer_context buf end |