class Antlr4::Runtime::ATNConfigSet
Attributes
configs[RW]
conflictingAlts[RW]
dips_into_outer_context[RW]
full_ctx[RW]
has_semantic_context[RW]
readonly[RW]
unique_alt[RW]
Public Class Methods
new(full_ctx = true)
click to toggle source
# 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
Public Instance Methods
add(config, merge_cache = nil)
click to toggle source
# 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()
click to toggle source
# 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?()
click to toggle source
# File lib/antlr4/runtime/atn_config_set.rb, line 78 def empty? @config_lookup.empty? end
find_first_rule_stop_state()
click to toggle source
# 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)
click to toggle source
# 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()
click to toggle source
# File lib/antlr4/runtime/atn_config_set.rb, line 142 def size @configs.length end
to_s()
click to toggle source
# 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