antlr4-runtime 0.2.8 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/lib/antlr4/runtime.rb +0 -3
  4. data/lib/antlr4/runtime/antlr_file_stream.rb +2 -2
  5. data/lib/antlr4/runtime/array_2d_hash_set.rb +1 -1
  6. data/lib/antlr4/runtime/atn_config.rb +4 -2
  7. data/lib/antlr4/runtime/buffered_token_stream.rb +1 -1
  8. data/lib/antlr4/runtime/dfa.rb +1 -1
  9. data/lib/antlr4/runtime/dfa_state.rb +2 -1
  10. data/lib/antlr4/runtime/flexible_hash_map.rb +1 -1
  11. data/lib/antlr4/runtime/interval_set.rb +2 -2
  12. data/lib/antlr4/runtime/lexer_channel_action.rb +1 -1
  13. data/lib/antlr4/runtime/lexer_custom_action.rb +1 -1
  14. data/lib/antlr4/runtime/lexer_indexed_custom_action.rb +1 -1
  15. data/lib/antlr4/runtime/lexer_mode_action.rb +1 -1
  16. data/lib/antlr4/runtime/lexer_more_action.rb +1 -1
  17. data/lib/antlr4/runtime/lexer_pop_mode_action.rb +1 -1
  18. data/lib/antlr4/runtime/lexer_push_mode_action.rb +1 -1
  19. data/lib/antlr4/runtime/lexer_skip_action.rb +5 -1
  20. data/lib/antlr4/runtime/lexer_type_action.rb +1 -1
  21. data/lib/antlr4/runtime/parse_tree.rb +1 -1
  22. data/lib/antlr4/runtime/parser_atn_simulator.rb +1 -2
  23. data/lib/antlr4/runtime/prediction_context_utils.rb +4 -2
  24. data/lib/antlr4/runtime/rule_node.rb +0 -2
  25. data/lib/antlr4/runtime/semantic_context.rb +6 -5
  26. data/lib/antlr4/runtime/tag_chunk.rb +1 -1
  27. data/lib/antlr4/runtime/text_chunk.rb +1 -1
  28. data/lib/antlr4/runtime/triple.rb +1 -1
  29. data/lib/antlr4/runtime/version.rb +1 -1
  30. metadata +2 -5
  31. data/lib/antlr4/runtime/chunk.rb +0 -4
  32. data/lib/antlr4/runtime/syntax_tree.rb +0 -4
  33. data/lib/antlr4/runtime/tree.rb +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 245b28b3ff9464508be9cdd7421d5bb4db7255a841f812bf75956e7fb3787210
4
- data.tar.gz: fd3addc862687ad9ab7a1421377e89dc35141abad04c9dad4007d1bc47896249
3
+ metadata.gz: 78c1ec511ddcf4fec60fd365e53346033575d3921de4be084648b9cce1959e14
4
+ data.tar.gz: 4d27831b78dce625246739d808ed5a8417efcdf2917a0478599c4ebcaedb0d6b
5
5
  SHA512:
6
- metadata.gz: 8766b0cf6d15ec643ebebe0abf7cad7aef8386fb2a959189c96349f331719d74bd07d32f1fec747b96cda21fcdc564eb72001bb250b66771f50ba30319a16f71
7
- data.tar.gz: b165e132a9c5f03371118eba4e92bdc2ac90629392b5b864dd0e72ec1bcd034c018fe5f686c5bb2f4efc94f2ef128442f25a70d9445a3a21284c10d89fcac2ee
6
+ metadata.gz: ff1c3e79f915a0b433abed5ec837eb1523bf52b5fbb991c1be476309eefd192580e3457aaabf21aff372d2e191695ead23b1f5cc91e6ab1c69707fdb395c7030
7
+ data.tar.gz: b224ea329f5ec05f6f1e22867f17e6b7bd16129e691448e2bc4f0c3568e57c23bddcb97973a8930ff6f54e6e7616cab2f7d296d7a7d10c664f2bb72fb74c48ba
@@ -1,3 +1,8 @@
1
+ 0.2.9
2
+ ===
3
+ - Minor changes to clear some ruby interpreter and code smell warnings.
4
+ - RSpecs now run properly in RubyMine
5
+
1
6
  0.2.8
2
7
  ===
3
8
  - Change certain error messages to match the format produced by the Java runtime.
@@ -36,7 +36,6 @@ module Antlr4
36
36
  autoload :BufferedTokenStream, 'antlr4/runtime/buffered_token_stream'
37
37
  autoload :CharStream, 'antlr4/runtime/char_stream'
38
38
  autoload :CharStreams, 'antlr4/runtime/char_streams'
39
- autoload :Chunk, 'antlr4/runtime/chunk'
40
39
  autoload :CodePointCharStream, 'antlr4/runtime/code_point_char_stream'
41
40
  autoload :CommonToken, 'antlr4/runtime/common_token'
42
41
  autoload :CommonTokenFactory, 'antlr4/runtime/common_token_factory'
@@ -124,7 +123,6 @@ module Antlr4
124
123
  autoload :StarBlockStartState, 'antlr4/runtime/star_block_start_state'
125
124
  autoload :StarLoopEntryState, 'antlr4/runtime/star_loop_entry_state'
126
125
  autoload :StarLoopbackState, 'antlr4/runtime/star_loopback_state'
127
- autoload :SyntaxTree, 'antlr4/runtime/syntax_tree'
128
126
  autoload :TagChunk, 'antlr4/runtime/tag_chunk'
129
127
  autoload :TerminalNode, 'antlr4/runtime/terminal_node'
130
128
  autoload :TerminalNodeImpl, 'antlr4/runtime/terminal_node_impl'
@@ -134,7 +132,6 @@ module Antlr4
134
132
  autoload :TokenTagToken, 'antlr4/runtime/token_tag_token'
135
133
  autoload :TokensStartState, 'antlr4/runtime/tokens_start_state'
136
134
  autoload :Transition, 'antlr4/runtime/transition'
137
- autoload :Tree, 'antlr4/runtime/tree'
138
135
  autoload :Trees, 'antlr4/runtime/trees'
139
136
  autoload :Triple, 'antlr4/runtime/triple'
140
137
  autoload :Utils, 'antlr4/runtime/utils'
@@ -2,10 +2,10 @@ module Antlr4::Runtime
2
2
  class ANTLRFileStream < ANTLRInputStream
3
3
  def initialize(file_name, encoding)
4
4
  @file_name = file_name
5
- load(file_name, encoding)
5
+ load_file(file_name, encoding)
6
6
  end
7
7
 
8
- def load(file_name, encoding)
8
+ def load_file(file_name, encoding)
9
9
  data = Utils.read_file(file_name, encoding)
10
10
  @n_items = data.length
11
11
  end
@@ -145,7 +145,7 @@ module Antlr4::Runtime
145
145
 
146
146
  def iterator
147
147
  a = to_a
148
- a.sort! {|a, b| @comparator.compare(a, b)} unless @comparator.nil?
148
+ a.sort! {|x, y| @comparator.compare(x, y)} unless @comparator.nil?
149
149
  SetIterator.new(a, self)
150
150
  end
151
151
 
@@ -12,12 +12,14 @@ module Antlr4::Runtime
12
12
  def initialize
13
13
  @reaches_into_outer_context = 0
14
14
  @alt = 0
15
+ @_hash = nil
16
+ @_bucket_hash = nil
15
17
  end
16
18
 
17
19
  def bucket_hash
18
20
  return @_bucket_hash unless @_bucket_hash.nil?
19
21
 
20
- if !@_bucket_hash.nil?
22
+ unless @_bucket_hash.nil?
21
23
  if hash_code == @_bucket_hash
22
24
  puts 'Same hash_code for ATNConfig.bucket_hash'
23
25
  else
@@ -139,7 +141,7 @@ module Antlr4::Runtime
139
141
 
140
142
  hash_code = RumourHash.calculate([@state.state_number, @alt, @context, @semantic_context])
141
143
 
142
- if !@_hash.nil?
144
+ unless @_hash.nil?
143
145
  if hash_code == @_hash
144
146
  puts 'Same hash_code for ATNConfig'
145
147
  else
@@ -155,7 +155,7 @@ module Antlr4::Runtime
155
155
  @ptr = adjust_seek_index(0)
156
156
  end
157
157
 
158
- def token_source(tokenSource)
158
+ def set_token_source(tokenSource)
159
159
  @token_source = tokenSource
160
160
  @tokens.clear
161
161
  @ptr = -1
@@ -51,7 +51,7 @@ module Antlr4::Runtime
51
51
  @s0.edges[precedence] = start_state
52
52
  end
53
53
 
54
- def precedence_dfa(precedence_dfa)
54
+ def set_precedence_dfa(precedence_dfa)
55
55
  if precedence_dfa != @precedence_dfa
56
56
  raise UnsupportedOperationException, 'The precedence_dfa field cannot change after a DFA is constructed.'
57
57
  end
@@ -20,6 +20,7 @@ module Antlr4::Runtime
20
20
  @is_accept_state = false
21
21
  @edges = []
22
22
  @state_number = -1
23
+ @_hash = nil
23
24
 
24
25
  if x.nil?
25
26
  @configs = ATNConfigSet.new
@@ -72,7 +73,7 @@ module Antlr4::Runtime
72
73
 
73
74
  hash_code = RumourHash.calculate([configs.hash])
74
75
 
75
- if !@_hash.nil?
76
+ unless @_hash.nil?
76
77
  if hash_code == @_hash
77
78
  puts 'Same hash_code for DFAState'
78
79
  else
@@ -134,7 +134,7 @@ module Antlr4::Runtime
134
134
 
135
135
  hash_code = RumourHash.calculate(objs)
136
136
 
137
- if !@_hash.nil?
137
+ unless @_hash.nil?
138
138
  if hash_code == @_hash
139
139
  puts 'Same hash_code for FlexibleHashMap'
140
140
  else
@@ -124,7 +124,7 @@ module Antlr4::Runtime
124
124
  def subtract(a)
125
125
  return IntervalSet.new self if a.nil? || a.is_nil
126
126
 
127
- return subtract_interval_sets(self, a)
127
+ subtract_interval_sets(self, a)
128
128
  end
129
129
 
130
130
  def subtract_interval_sets(left, right)
@@ -297,7 +297,7 @@ module Antlr4::Runtime
297
297
 
298
298
  hash_code = RumourHash.calculate(ints)
299
299
 
300
- if !@_hash.nil?
300
+ unless @_hash.nil?
301
301
  if hash_code == @_hash
302
302
  puts 'Same hash_code for IntervalSet'
303
303
  else
@@ -24,7 +24,7 @@ module Antlr4::Runtime
24
24
 
25
25
  hash_code = RumourHash.calculate([action_type.ordinal, channel])
26
26
 
27
- if !@_hash.nil?
27
+ unless @_hash.nil?
28
28
  if hash_code == @_hash
29
29
  puts 'Same hash_code for LexerChannelAction'
30
30
  else
@@ -26,7 +26,7 @@ module Antlr4::Runtime
26
26
 
27
27
  hash_code = RumourHash.calculate([action_type, rule_index, action_index])
28
28
 
29
- if !@_hash.nil?
29
+ unless @_hash.nil?
30
30
  if hash_code == @_hash
31
31
  puts 'Same hash_code for LexerCustomAction'
32
32
  else
@@ -26,7 +26,7 @@ module Antlr4::Runtime
26
26
 
27
27
  hash_code = RumourHash.calculate([offset, action])
28
28
 
29
- if !@_hash.nil?
29
+ unless @_hash.nil?
30
30
  if hash_code == @_hash
31
31
  puts 'Same hash_code for LexerIndexedCustomAction'
32
32
  else
@@ -24,7 +24,7 @@ module Antlr4::Runtime
24
24
 
25
25
  hash_code = RumourHash.calculate([action_type, mode])
26
26
 
27
- if !@_hash.nil?
27
+ unless @_hash.nil?
28
28
  if hash_code == @_hash
29
29
  puts 'Same hash_code for LexerModeAction'
30
30
  else
@@ -20,7 +20,7 @@ module Antlr4::Runtime
20
20
 
21
21
  hash_code = RumourHash.calculate([action_type])
22
22
 
23
- if !@_hash.nil?
23
+ unless @_hash.nil?
24
24
  if hash_code == @_hash
25
25
  puts 'Same hash_code for LexerMoreAction'
26
26
  else
@@ -20,7 +20,7 @@ module Antlr4::Runtime
20
20
 
21
21
  hash_code = RumourHash.calculate([action_type])
22
22
 
23
- if !@_hash.nil?
23
+ unless @_hash.nil?
24
24
  if hash_code == @_hash
25
25
  puts 'Same hash_code for LexerPopModeAction'
26
26
  else
@@ -24,7 +24,7 @@ module Antlr4::Runtime
24
24
 
25
25
  hash_code = RumourHash.calculate([action_type, mode])
26
26
 
27
- if !@_hash.nil?
27
+ unless @_hash.nil?
28
28
  if hash_code == @_hash
29
29
  puts 'Same hash_code for LexerPushModeAction'
30
30
  else
@@ -3,6 +3,10 @@ module Antlr4::Runtime
3
3
  class LexerSkipAction < LexerAction
4
4
  include Singleton
5
5
 
6
+ def initialize
7
+ @_hash = nil
8
+ end
9
+
6
10
  def action_type
7
11
  LexerActionType::SKIP
8
12
  end
@@ -20,7 +24,7 @@ module Antlr4::Runtime
20
24
 
21
25
  hash_code = RumourHash.calculate([action_type])
22
26
 
23
- if !@_hash.nil?
27
+ unless @_hash.nil?
24
28
  if hash_code == @_hash
25
29
  puts 'Same hash_code for LexerSkipAction'
26
30
  else
@@ -24,7 +24,7 @@ module Antlr4::Runtime
24
24
 
25
25
  hash_code = RumourHash.calculate([action_type, @type])
26
26
 
27
- if !@_hash.nil?
27
+ unless @_hash.nil?
28
28
  if hash_code == @_hash
29
29
  puts 'Same hash_code for LexerTypeAction'
30
30
  else
@@ -1,5 +1,5 @@
1
1
  module Antlr4::Runtime
2
2
 
3
- class ParseTree < SyntaxTree
3
+ class ParseTree
4
4
  end
5
5
  end
@@ -246,8 +246,7 @@ module Antlr4::Runtime
246
246
  end
247
247
 
248
248
  # all adds to dfa are done after we've created full D state
249
- d = add_dfa_edge(dfa, prev_d, t, d)
250
- d
249
+ add_dfa_edge(dfa, prev_d, t, d)
251
250
  end
252
251
 
253
252
  def predicate_dfa_state(dfa_state, decision_state) # We need to test all predicates, even in DFA states that
@@ -4,6 +4,8 @@ module Antlr4::Runtime
4
4
  INITIAL_HASH = 1
5
5
  EMPTY_RETURN_STATE = Integer::MAX
6
6
 
7
+ @@_hash = nil
8
+
7
9
  def self.from_rule_context(atn, outer_ctx)
8
10
  outer_ctx = ParserRuleContext::EMPTY if outer_ctx.nil?
9
11
 
@@ -388,9 +390,9 @@ module Antlr4::Runtime
388
390
  end
389
391
 
390
392
  def self.calculate_empty_hash_code
391
- return @_hash unless @_hash.nil?
393
+ return @@_hash unless @@_hash.nil?
392
394
 
393
- @_hash = RumourHash.calculate([INITIAL_HASH])
395
+ @@_hash = RumourHash.calculate([INITIAL_HASH])
394
396
  end
395
397
 
396
398
  def self.calculate_hash_code1(parent, return_state)
@@ -1,6 +1,4 @@
1
1
  module Antlr4::Runtime
2
2
  class RuleNode < ParseTree
3
- def rule_context
4
- end
5
3
  end
6
4
  end
@@ -16,6 +16,7 @@ module Antlr4::Runtime
16
16
  @rule_index = rule_index
17
17
  @pred_index = pred_index
18
18
  @is_ctx_dependent = is_ctx_dependent
19
+ @_hash = nil
19
20
  end
20
21
 
21
22
  def eval(parser, parser_call_stack)
@@ -28,7 +29,7 @@ module Antlr4::Runtime
28
29
 
29
30
  hash_code = RumourHash.calculate([@rule_index, @pred_index, @is_ctx_dependent ? 1 : 0])
30
31
 
31
- if !@_hash.nil?
32
+ unless @_hash.nil?
32
33
  if hash_code == @_hash
33
34
  puts 'Same hash_code for SemanticContext'
34
35
  else
@@ -46,7 +47,7 @@ module Antlr4::Runtime
46
47
  end
47
48
 
48
49
  def to_s
49
- '' + @rule_index + ':' + @pred_index + 'end?'
50
+ '{' + @rule_index + ':' + @pred_index + '}?'
50
51
  end
51
52
  end
52
53
 
@@ -84,7 +85,7 @@ module Antlr4::Runtime
84
85
 
85
86
  # precedence >= _precedenceStack.peek()
86
87
  def to_s
87
- '' + @precedence + '>=precend?'
88
+ '{' + @precedence + '>=prec}?'
88
89
  end
89
90
  end
90
91
 
@@ -125,7 +126,7 @@ module Antlr4::Runtime
125
126
 
126
127
  def hash
127
128
  hash_code = RumourHash.calculate(@opnds, AND.hash)
128
- if !@_hash2.nil?
129
+ unless @_hash2.nil?
129
130
  if hash_code == @_hash2
130
131
  puts 'Same hash_code for SemanticContext_2'
131
132
  else
@@ -220,7 +221,7 @@ module Antlr4::Runtime
220
221
 
221
222
  def hash
222
223
  hash_code = MurmurHash.calculate(@opnds, OR.hash)
223
- if !@_hash3.nil?
224
+ unless @_hash3.nil?
224
225
  if hash_code == @_hash3
225
226
  puts 'Same hash_code for SemanticContext_2'
226
227
  else
@@ -1,6 +1,6 @@
1
1
  module Antlr4::Runtime
2
2
 
3
- class TagChunk < Chunk
3
+ class TagChunk
4
4
  attr_reader :tag
5
5
  attr_reader :label
6
6
 
@@ -1,6 +1,6 @@
1
1
  module Antlr4::Runtime
2
2
 
3
- class TextChunk < Chunk
3
+ class TextChunk
4
4
  attr_reader :text
5
5
 
6
6
  def initialize(text)
@@ -23,7 +23,7 @@ module Antlr4::Runtime
23
23
  def hash
24
24
  hash_code = RumourHash.hash([@a, @b, @c])
25
25
 
26
- if !@_hash.nil?
26
+ unless @_hash.nil?
27
27
  if hash_code == @_hash
28
28
  puts 'Same hash_code for Triple'
29
29
  else
@@ -1,5 +1,5 @@
1
1
  module Antlr4
2
2
  module Runtime
3
- VERSION = "0.2.8"
3
+ VERSION = "0.2.9"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: antlr4-runtime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Walmsley
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-07-05 00:00:00.000000000 Z
11
+ date: 2019-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -105,7 +105,6 @@ files:
105
105
  - lib/antlr4/runtime/buffered_token_stream.rb
106
106
  - lib/antlr4/runtime/char_stream.rb
107
107
  - lib/antlr4/runtime/char_streams.rb
108
- - lib/antlr4/runtime/chunk.rb
109
108
  - lib/antlr4/runtime/code_point_char_stream.rb
110
109
  - lib/antlr4/runtime/common_token.rb
111
110
  - lib/antlr4/runtime/common_token_factory.rb
@@ -193,7 +192,6 @@ files:
193
192
  - lib/antlr4/runtime/star_block_start_state.rb
194
193
  - lib/antlr4/runtime/star_loop_entry_state.rb
195
194
  - lib/antlr4/runtime/star_loopback_state.rb
196
- - lib/antlr4/runtime/syntax_tree.rb
197
195
  - lib/antlr4/runtime/tag_chunk.rb
198
196
  - lib/antlr4/runtime/terminal_node.rb
199
197
  - lib/antlr4/runtime/terminal_node_impl.rb
@@ -203,7 +201,6 @@ files:
203
201
  - lib/antlr4/runtime/token_tag_token.rb
204
202
  - lib/antlr4/runtime/tokens_start_state.rb
205
203
  - lib/antlr4/runtime/transition.rb
206
- - lib/antlr4/runtime/tree.rb
207
204
  - lib/antlr4/runtime/trees.rb
208
205
  - lib/antlr4/runtime/triple.rb
209
206
  - lib/antlr4/runtime/utils.rb
@@ -1,4 +0,0 @@
1
- module Antlr4::Runtime
2
- class Chunk
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module Antlr4::Runtime
2
- class SyntaxTree < Tree
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module Antlr4::Runtime
2
- class Tree
3
- end
4
- end