Class: Antlr4::Runtime::ATNConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/antlr4/runtime/atn_config.rb

Direct Known Subclasses

LexerATNConfig

Constant Summary collapse

SUPPRESS_PRECEDENCE_FILTER =
0x40000000

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeATNConfig

Returns a new instance of ATNConfig


12
13
14
15
# File 'lib/antlr4/runtime/atn_config.rb', line 12

def initialize
  @reaches_into_outer_context = 0
  @alt = 0
end

Instance Attribute Details

#altObject

Returns the value of attribute alt


6
7
8
# File 'lib/antlr4/runtime/atn_config.rb', line 6

def alt
  @alt
end

#contextObject

Returns the value of attribute context


7
8
9
# File 'lib/antlr4/runtime/atn_config.rb', line 7

def context
  @context
end

#reaches_into_outer_contextObject

Returns the value of attribute reaches_into_outer_context


9
10
11
# File 'lib/antlr4/runtime/atn_config.rb', line 9

def reaches_into_outer_context
  @reaches_into_outer_context
end

#semantic_contextObject

Returns the value of attribute semantic_context


10
11
12
# File 'lib/antlr4/runtime/atn_config.rb', line 10

def semantic_context
  @semantic_context
end

#stateObject

Returns the value of attribute state


5
6
7
# File 'lib/antlr4/runtime/atn_config.rb', line 5

def state
  @state
end

#targetObject

Returns the value of attribute target


8
9
10
# File 'lib/antlr4/runtime/atn_config.rb', line 8

def target
  @target
end

Instance Method Details

#atn_config1(state, alt, context) ⇒ Object


38
39
40
# File 'lib/antlr4/runtime/atn_config.rb', line 38

def atn_config1(state, alt, context)
  atn_config2(state, alt, context, SemanticContext::NONE)
end

#atn_config2(state, alt, context, semantic_context) ⇒ Object


42
43
44
45
46
47
# File 'lib/antlr4/runtime/atn_config.rb', line 42

def atn_config2(state, alt, context, semantic_context)
  @state = state
  @alt = alt
  @context = context
  @semantic_context = semantic_context
end

#atn_config3(c, state) ⇒ Object


49
50
51
# File 'lib/antlr4/runtime/atn_config.rb', line 49

def atn_config3(c, state)
  atn_config7(c, state, c.context, c.semantic_context)
end

#atn_config4(c, state, semantic_context) ⇒ Object


53
54
55
# File 'lib/antlr4/runtime/atn_config.rb', line 53

def atn_config4(c, state, semantic_context)
  atn_config7(c, state, c.context, semantic_context)
end

#atn_config5(c, semantic_context) ⇒ Object


57
58
59
# File 'lib/antlr4/runtime/atn_config.rb', line 57

def atn_config5(c, semantic_context)
  atn_config7(c, c.state, c.context, semantic_context)
end

#atn_config6(c, state, context) ⇒ Object


61
62
63
# File 'lib/antlr4/runtime/atn_config.rb', line 61

def atn_config6(c, state, context)
  atn_config7(c, state, context, c.semantic_context)
end

#atn_config7(c, state, context, semantic_context) ⇒ Object


65
66
67
68
69
70
71
# File 'lib/antlr4/runtime/atn_config.rb', line 65

def atn_config7(c, state, context, semantic_context)
  @state = state
  @alt = c.alt
  @context = context
  @semantic_context = semantic_context
  @reaches_into_outer_context = c.reaches_into_outer_context
end

#atn_config_copy(old) ⇒ Object


30
31
32
33
34
35
36
# File 'lib/antlr4/runtime/atn_config.rb', line 30

def atn_config_copy(old)
  @state = old.state
  @alt = old.alt
  @context = old.context
  @semantic_context = old.semantic_context
  @reaches_into_outer_context = old.reaches_into_outer_context
end

#bucket_hashObject


17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/antlr4/runtime/atn_config.rb', line 17

def bucket_hash
  return @_bucket_hash unless @_bucket_hash.nil?

  if !@_bucket_hash.nil?
    if hash_code == @_bucket_hash
      puts 'Same hash_code for ATNConfig.bucket_hash'
    else
      puts 'Different hash_code for ATNConfig.bucket_hash'
    end
  end
  @_bucket_hash = MurmurHash.hash_int_int(@state.state_number, @alt)
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)

115
116
117
118
119
120
121
122
123
# File 'lib/antlr4/runtime/atn_config.rb', line 115

def eql?(other)
  if self == other
    return true
  elsif other.nil?
    return false
  end

  @state.state_number == other.state.state_number && @alt == other.alt && (@context == other.context || (!@context.nil? && @context.<=>(other.context))) && @semantic_context.<=>(other.semantic_context) && precedence_filter_suppressed? == other.precedence_filter_suppressed?
end

#hashObject


125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/antlr4/runtime/atn_config.rb', line 125

def hash
  return @_hash unless @_hash.nil?

  hash_code = MurmurHash.hash_int_int_obj_obj(@state.state_number,@alt,@context,@semantic_context)

  if !@_hash.nil?
    if hash_code == @_hash
      puts 'Same hash_code for ATNConfig'
    else
      puts 'Different hash_code for ATNConfig'
    end
  end
  @_hash = hash_code
end

#outer_context_depthObject


73
74
75
# File 'lib/antlr4/runtime/atn_config.rb', line 73

def outer_context_depth
  (@reaches_into_outer_context & ~SUPPRESS_PRECEDENCE_FILTER)
end

#precedence_filter_suppressed(value) ⇒ Object


81
82
83
84
85
86
87
# File 'lib/antlr4/runtime/atn_config.rb', line 81

def precedence_filter_suppressed(value)
  if value
    @reaches_into_outer_context |= 0x40000000
  else
    @reaches_into_outer_context &= ~SUPPRESS_PRECEDENCE_FILTER
  end
end

#precedence_filter_suppressed?Boolean

Returns:

  • (Boolean)

77
78
79
# File 'lib/antlr4/runtime/atn_config.rb', line 77

def precedence_filter_suppressed?
  (@reaches_into_outer_context & SUPPRESS_PRECEDENCE_FILTER) != 0
end

#to_sObject


89
90
91
# File 'lib/antlr4/runtime/atn_config.rb', line 89

def to_s
  to_s2(nil, true)
end

#to_s2(_recog = nil, show_alt = false) ⇒ Object


93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/antlr4/runtime/atn_config.rb', line 93

def to_s2(_recog = nil, show_alt = false)
  buf = ''
  buf << '('
  buf << @state.to_s
  if show_alt
    buf << ','
    buf << @alt.to_s
  end
  unless @context.nil?
    buf << ',['
    buf << @context.to_s
    buf << ']'
  end
  if !@semantic_context.nil? && @semantic_context != SemanticContext::NONE
    buf << ','
    buf << @semantic_context.to_s
  end
  buf << ',up=' << outer_context_depth.to_s if outer_context_depth > 0
  buf << ')'
  buf
end