antlr3 1.6.0 → 1.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/antlr3/dfa.rb CHANGED
@@ -4,7 +4,7 @@
4
4
  =begin LICENSE
5
5
 
6
6
  [The "BSD licence"]
7
- Copyright (c) 2009 Kyle Yetter
7
+ Copyright (c) 2009-2010 Kyle Yetter
8
8
  All rights reserved.
9
9
 
10
10
  Redistribution and use in source and binary forms, with or without
@@ -108,30 +108,30 @@ class DFA
108
108
  attr_reader :decision, :eot, :eof, :min, :max,
109
109
  :accept, :special, :transition
110
110
 
111
- def unpack(*data)
111
+ def unpack( *data )
112
112
  data.empty? and return [].freeze
113
113
 
114
114
  n = data.length / 2
115
115
  size = 0
116
116
  n.times { |i| size += data[ 2*i ] }
117
117
  if size > 1024
118
- values = Hash.new(0)
119
- data.each_slice(2) do |count, value|
120
- values[value] += count
118
+ values = Hash.new( 0 )
119
+ data.each_slice( 2 ) do |count, value|
120
+ values[ value ] += count
121
121
  end
122
- default = values.keys.max_by { |v| values[v] }
122
+ default = values.keys.max_by { |v| values[ v ] }
123
123
 
124
- unpacked = Hash.new(default)
124
+ unpacked = Hash.new( default )
125
125
  position = 0
126
- data.each_slice(2) do |count, value|
126
+ data.each_slice( 2 ) do |count, value|
127
127
  unless value == default
128
- count.times { |i| unpacked[position + i] = value }
128
+ count.times { |i| unpacked[ position + i ] = value }
129
129
  end
130
130
  position += count
131
131
  end
132
132
  else
133
133
  unpacked = []
134
- data.each_slice(2) do |count, value|
134
+ data.each_slice( 2 ) do |count, value|
135
135
  unpacked.fill( value, unpacked.length, count )
136
136
  end
137
137
  end
@@ -159,87 +159,157 @@ class DFA
159
159
  raise unless e.message =~ /uninitialized constant/
160
160
  constant = e.name
161
161
  message = Util.tidy( <<-END )
162
- | No #{constant} information provided.
162
+ | No #{ constant } information provided.
163
163
  | DFA cannot be instantiated without providing state array information.
164
164
  | When DFAs are generated by ANTLR, this information should already be
165
165
  | provided in the DFA subclass constants.
166
166
  END
167
167
  end
168
168
 
169
- def predict(input)
170
- mark = input.mark
171
- state = 0
169
+ if RUBY_VERSION =~ /^1\.9/
172
170
 
173
- 50000.times do
174
- special_state = @special[state]
175
- if special_state >= 0
176
- state = @special_block.call(special_state)
177
- if state == -1
178
- no_viable_alternative(state, input)
179
- return 0
171
+ def predict( input )
172
+ mark = input.mark
173
+ state = 0
174
+
175
+ 50000.times do
176
+ special_state = @special[ state ]
177
+ if special_state >= 0
178
+ state = @special_block.call( special_state )
179
+ if state == -1
180
+ no_viable_alternative( state, input )
181
+ return 0
182
+ end
183
+ input.consume
184
+ next
185
+ end
186
+ @accept[ state ] >= 1 and return @accept[ state ]
187
+
188
+ # look for a normal char transition
189
+
190
+ c = input.peek.ord
191
+ # the @min and @max arrays contain the bounds of the character (or token type)
192
+ # ranges for the transition decisions
193
+ if c.between?( @min[ state ], @max[ state ] )
194
+ # c - @min[state] is the position of the character within the range
195
+ # so for a range like ?a..?z, a match of ?a would be 0,
196
+ # ?c would be 2, and ?z would be 25
197
+ next_state = @transition[ state ][ c - @min[ state ] ]
198
+ if next_state < 0
199
+ if @eot[ state ] >= 0
200
+ state = @eot[ state ]
201
+ input.consume
202
+ next
203
+ end
204
+ no_viable_alternative( state, input )
205
+ return 0
206
+ end
207
+
208
+ state = next_state
209
+ input.consume
210
+ next
180
211
  end
181
- input.consume
182
- next
212
+
213
+ if @eot[ state ] >= 0
214
+ state = @eot[ state ]
215
+ input.consume()
216
+ next
217
+ end
218
+
219
+ ( c == EOF && @eof[ state ] >= 0 ) and return @accept[ @eof[ state ] ]
220
+ no_viable_alternative( state, input )
221
+ return 0
183
222
  end
184
- @accept[state] >= 1 and return @accept[state]
185
223
 
186
- # look for a normal char transition
224
+ ANTLR3.bug!( Util.tidy( <<-END ) )
225
+ | DFA BANG!
226
+ | The prediction loop has exceeded a maximum limit of 50000 iterations
227
+ | ----
228
+ | decision: #@decision_number
229
+ | description: #{ description }
230
+ END
231
+ ensure
232
+ input.rewind( mark )
233
+ end
234
+
235
+ else
236
+
237
+ def predict( input )
238
+ mark = input.mark
239
+ state = 0
187
240
 
188
- c = input.peek
189
- # the @min and @max arrays contain the bounds of the character (or token type)
190
- # ranges for the transition decisions
191
- if c.between?( @min[ state ], @max[ state ] )
192
- # c - @min[state] is the position of the character within the range
193
- # so for a range like ?a..?z, a match of ?a would be 0,
194
- # ?c would be 2, and ?z would be 25
195
- next_state = @transition[state][c - @min[state]]
196
- if next_state < 0
197
- if @eot[state] >= 0
198
- state = @eot[state]
199
- input.consume
200
- next
241
+ 50000.times do
242
+ special_state = @special[ state ]
243
+ if special_state >= 0
244
+ state = @special_block.call( special_state )
245
+ if state == -1
246
+ no_viable_alternative( state, input )
247
+ return 0
201
248
  end
202
- no_viable_alternative(state, input)
203
- return 0
249
+ input.consume
250
+ next
204
251
  end
252
+ @accept[ state ] >= 1 and return @accept[ state ]
205
253
 
206
- state = next_state
207
- input.consume()
208
- next
209
- end
210
- if @eot[state] >= 0
211
- state = @eot[state]
212
- input.consume()
213
- next
254
+ # look for a normal char transition
255
+
256
+ c = input.peek
257
+ # the @min and @max arrays contain the bounds of the character (or token type)
258
+ # ranges for the transition decisions
259
+ if c.between?( @min[ state ], @max[ state ] )
260
+ # c - @min[state] is the position of the character within the range
261
+ # so for a range like ?a..?z, a match of ?a would be 0,
262
+ # ?c would be 2, and ?z would be 25
263
+ next_state = @transition[ state ][ c - @min[ state ] ]
264
+ if next_state < 0
265
+ if @eot[ state ] >= 0
266
+ state = @eot[ state ]
267
+ input.consume
268
+ next
269
+ end
270
+ no_viable_alternative( state, input )
271
+ return 0
272
+ end
273
+
274
+ state = next_state
275
+ input.consume()
276
+ next
277
+ end
278
+ if @eot[ state ] >= 0
279
+ state = @eot[ state ]
280
+ input.consume()
281
+ next
282
+ end
283
+ ( c == EOF && @eof[ state ] >= 0 ) and return @accept[ @eof[ state ] ]
284
+ no_viable_alternative( state, input )
285
+ return 0
214
286
  end
215
- (c == EOF && @eof[state] >= 0) and return @accept[@eof[state]]
216
- no_viable_alternative(state, input)
217
- return 0
287
+
288
+ ANTLR3.bug!( Util.tidy( <<-END ) )
289
+ | DFA BANG!
290
+ | The prediction loop has exceeded a maximum limit of 50000 iterations
291
+ | ----
292
+ | decision: #@decision_number
293
+ | description: #{ description }
294
+ END
295
+ ensure
296
+ input.rewind( mark )
218
297
  end
219
298
 
220
- ANTLR3.bug!( Util.tidy(<<-END) )
221
- | DFA BANG!
222
- | The prediction loop has exceeded a maximum limit of 50000 iterations
223
- | ----
224
- | decision: #@decision_number
225
- | description: #{description}
226
- END
227
- ensure
228
- input.rewind(mark)
229
299
  end
230
-
231
- def no_viable_alternative(state, input)
232
- raise(BacktrackingFailed) if @recognizer.state.backtracking > 0
233
- except = NoViableAlternative.new(description, @decision_number, state, input)
234
- error(except)
235
- raise(except)
300
+
301
+ def no_viable_alternative( state, input )
302
+ raise( BacktrackingFailed ) if @recognizer.state.backtracking > 0
303
+ except = NoViableAlternative.new( description, @decision_number, state, input )
304
+ error( except )
305
+ raise( except )
236
306
  end
237
307
 
238
- def error(except)
308
+ def error( except )
239
309
  # overridable debugging hook
240
310
  end
241
311
 
242
- def special_state_transition(state, input)
312
+ def special_state_transition( state, input )
243
313
  return -1
244
314
  end
245
315
 
data/lib/antlr3/dot.rb CHANGED
@@ -4,7 +4,7 @@
4
4
  =begin LICENSE
5
5
 
6
6
  [The "BSD licence"]
7
- Copyright (c) 2009 Kyle Yetter
7
+ Copyright (c) 2009-2010 Kyle Yetter
8
8
  All rights reserved.
9
9
 
10
10
  Redistribution and use in source and binary forms, with or without
@@ -49,26 +49,26 @@ library.
49
49
 
50
50
  module DOT
51
51
  class Context
52
- def []=(var, value)
53
- instance_variable_set(:"@#{var}", value)
52
+ def []=( var, value )
53
+ instance_variable_set( :"@#{ var }", value )
54
54
  end
55
- def [](var)
56
- instance_variable_get(:"@#{var}")
55
+ def []( var )
56
+ instance_variable_get( :"@#{ var }" )
57
57
  end
58
58
 
59
- def initialize(template, vars = {})
59
+ def initialize( template, vars = {} )
60
60
  @__template__ = template
61
61
  vars.each do |var, value|
62
- self[var] = value
62
+ self[ var ] = value
63
63
  end
64
64
  end
65
65
 
66
66
  def to_s
67
- @__template__.result(binding)
67
+ @__template__.result( binding )
68
68
  end
69
69
  end
70
70
  class TreeGenerator
71
- TREE_TEMPLATE = ERB.new( Util.tidy(<<-END) )
71
+ TREE_TEMPLATE = ERB.new( Util.tidy( <<-END ) )
72
72
  | digraph {
73
73
  | ordering=out;
74
74
  | ranksep=.4;
@@ -80,33 +80,33 @@ module DOT
80
80
  | }
81
81
  END
82
82
 
83
- NODE_TEMPLATE = ERB.new( Util.tidy(<<-END) )
83
+ NODE_TEMPLATE = ERB.new( Util.tidy( <<-END ) )
84
84
  | <%= @name %> [label="<%= @text %>"];
85
85
  END
86
86
 
87
- EDGE_TEMPLATE = ERB.new( Util.tidy(<<-END) )
87
+ EDGE_TEMPLATE = ERB.new( Util.tidy( <<-END ) )
88
88
  | <%= @parent %> -> <%= @child %>; // "<%= @parent_text %>" -> "<%= @child_text %>"
89
89
  END
90
90
 
91
- def self.generate(tree, adaptor = nil, tree_template = TREE_TEMPLATE,
92
- edge_template = EDGE_TEMPLATE)
93
- new.to_dot(tree, adaptor, tree_template, edge_template)
91
+ def self.generate( tree, adaptor = nil, tree_template = TREE_TEMPLATE,
92
+ edge_template = EDGE_TEMPLATE )
93
+ new.to_dot( tree, adaptor, tree_template, edge_template )
94
94
  end
95
95
 
96
96
  def initialize
97
97
  @node_number = 0
98
98
  @node_to_number_map = Hash.new do |map, node|
99
- map[node] = @node_number
99
+ map[ node ] = @node_number
100
100
  @node_number += 1
101
101
  @node_number - 1
102
102
  end
103
103
  end
104
104
 
105
- def to_dot(tree, adaptor = nil, tree_template = TREE_TEMPLATE,
106
- edge_template = EDGE_TEMPLATE)
105
+ def to_dot( tree, adaptor = nil, tree_template = TREE_TEMPLATE,
106
+ edge_template = EDGE_TEMPLATE )
107
107
  adaptor ||= AST::CommonTreeAdaptor.new
108
108
  @node_number = 0
109
- tree_template = Context.new(tree_template, :nodes => [], :edges => [])
109
+ tree_template = Context.new( tree_template, :nodes => [], :edges => [] )
110
110
  define_nodes( tree, adaptor, tree_template )
111
111
 
112
112
  @node_number = 0
@@ -114,28 +114,28 @@ module DOT
114
114
  return tree_template.to_s
115
115
  end
116
116
 
117
- def define_nodes( tree, adaptor, tree_template, known_nodes = nil)
117
+ def define_nodes( tree, adaptor, tree_template, known_nodes = nil )
118
118
  known_nodes ||= Set.new
119
119
  tree.nil? and return
120
120
  n = adaptor.child_count( tree )
121
121
  n == 0 and return
122
122
  number = node_number( tree )
123
123
  unless known_nodes.include?( number )
124
- parent_node_template = node_template_for(adaptor, child)
125
- tree_template[:nodes] << parent_node_template
124
+ parent_node_template = node_template_for( adaptor, child )
125
+ tree_template[ :nodes ] << parent_node_template
126
126
  known_nodes.add( number )
127
127
  end
128
128
 
129
129
  n.times do |index|
130
130
  child = adaptor.child_of( tree, index )
131
131
  number = @node_to_number_map[ child ]
132
- unless known_nodes.include?(number)
132
+ unless known_nodes.include?( number )
133
133
  node_template = node_template_for( adaptor, child )
134
- tree_template[:nodes] << node_template
134
+ tree_template[ :nodes ] << node_template
135
135
  known_nodes.add( number )
136
136
  end
137
137
 
138
- define_nodes(child, adaptor, tree_template, edge_template)
138
+ define_nodes( child, adaptor, tree_template, edge_template )
139
139
  end
140
140
  end
141
141
 
@@ -151,24 +151,24 @@ module DOT
151
151
  child = adaptor.child_of( tree, index )
152
152
  child_text = adaptor.text_of( child )
153
153
  child_name = 'n%i' % @node_to_number_map[ tree ]
154
- edge_template = Context.new(edge_template,
154
+ edge_template = Context.new( edge_template,
155
155
  :parent => parent_name, :child => child_name,
156
156
  :parent_text => parent_text, :child_text => child_text
157
157
  )
158
- tree_template[:edges] << edge_template
158
+ tree_template[ :edges ] << edge_template
159
159
  define_edges( child, adaptor, tree_template, edge_template )
160
160
  end
161
161
  end
162
162
 
163
- def node_template_for(adaptor, tree)
163
+ def node_template_for( adaptor, tree )
164
164
  text = adaptor.text_of( tree )
165
- node_template = Context.new(NODE_TEMPLATE)
165
+ node_template = Context.new( NODE_TEMPLATE )
166
166
  unique_name = 'n%i' % @node_to_number_map[ tree ]
167
- node_template[:name] = unique_name
168
- text and text = text.gsub(/"/, '\\"')
169
- node_template[:text] = text
167
+ node_template[ :name ] = unique_name
168
+ text and text = text.gsub( /"/, '\\"' )
169
+ node_template[ :text ] = text
170
170
  return node_template
171
171
  end
172
172
  end
173
173
  end
174
- end
174
+ end
data/lib/antlr3/error.rb CHANGED
@@ -4,7 +4,7 @@
4
4
  =begin LICENSE
5
5
 
6
6
  [The "BSD licence"]
7
- Copyright (c) 2009 Kyle Yetter
7
+ Copyright (c) 2009-2010 Kyle Yetter
8
8
  All rights reserved.
9
9
 
10
10
  Redistribution and use in source and binary forms, with or without
@@ -117,21 +117,21 @@ class RecognitionError < StandardError
117
117
  @column = @input.column
118
118
  when AST::TreeNodeStream
119
119
  @symbol = @input.look
120
- if @symbol.respond_to?(:line) and @symbol.respond_to?(:column)
120
+ if @symbol.respond_to?( :line ) and @symbol.respond_to?( :column )
121
121
  @line, @column = @symbol.line, @symbol.column
122
122
  else
123
123
  extract_from_node_stream( @input )
124
124
  end
125
125
  else
126
126
  @symbol = @input.look
127
- if @symbol.respond_to?(:line) and @symbol.respond_to?(:column)
127
+ if @symbol.respond_to?( :line ) and @symbol.respond_to?( :column )
128
128
  @line, @column = @symbol.line, @symbol.column
129
- elsif @input.respond_to?(:line) and @input.respond_to?(:column)
129
+ elsif @input.respond_to?( :line ) and @input.respond_to?( :column )
130
130
  @line, @column = @input.line, @input.column
131
131
  end
132
132
  end
133
133
  end
134
- super(message)
134
+ super( message )
135
135
  end
136
136
 
137
137
  def approximate_line_info?
@@ -144,7 +144,7 @@ class RecognitionError < StandardError
144
144
  @symbol.type
145
145
  when AST::TreeNodeStream
146
146
  adaptor = @input.adaptor
147
- return adaptor.type(@symbol)
147
+ return adaptor.type( @symbol )
148
148
  else
149
149
  return @symbol
150
150
  end
@@ -160,16 +160,16 @@ class RecognitionError < StandardError
160
160
 
161
161
  private
162
162
 
163
- def extract_from_node_stream(nodes)
163
+ def extract_from_node_stream( nodes )
164
164
  adaptor = nodes.adaptor
165
- payload = adaptor.token(@symbol)
165
+ payload = adaptor.token( @symbol )
166
166
 
167
167
  if payload
168
168
  @token = payload
169
169
  if payload.line <= 0
170
170
  i = -1
171
- while prior_node = nodes.look(i)
172
- prior_payload = adaptor.token(prior_node)
171
+ while prior_node = nodes.look( i )
172
+ prior_payload = adaptor.token( prior_node )
173
173
  if prior_payload and prior_payload.line > 0
174
174
  @line = prior_payload.line
175
175
  @column = prior_payload.column
@@ -182,10 +182,10 @@ private
182
182
  @line = payload.line
183
183
  @column = payload.column
184
184
  end
185
- elsif @symbol.is_a?(AST::Tree)
185
+ elsif @symbol.is_a?( AST::Tree )
186
186
  @line = @symbol.line
187
187
  @column = @symbol.column
188
- @symbol.is_a?(AST::CommonTree) and @token = @symbol.token
188
+ @symbol.is_a?( AST::CommonTree ) and @token = @symbol.token
189
189
  else
190
190
  type = adaptor.type( @symbol )
191
191
  text = adaptor.text( @symbol )
@@ -210,13 +210,14 @@ occurs when::
210
210
 
211
211
  class MismatchedToken < RecognitionError
212
212
  attr_reader :expecting
213
- def initialize(expecting, input)
213
+
214
+ def initialize( expecting, input )
214
215
  @expecting = expecting
215
- super(input)
216
+ super( input )
216
217
  end
217
218
 
218
219
  def message
219
- "%s: %p %p" % [self.class, unexpected_type, @expecting.inspect]
220
+ "%s: %p %p" % [ self.class, unexpected_type, @expecting.inspect ]
220
221
  end
221
222
  end
222
223
 
@@ -234,7 +235,7 @@ class UnwantedToken < MismatchedToken
234
235
  def message
235
236
  exp = @expecting == INVALID_TOKEN_TYPE ? '' : ", expected %p" % @expecting
236
237
  text = @symbol.text rescue nil
237
- "%s: found=%p%s" % [self.class, text, exp]
238
+ "%s: found=%p%s" % [ self.class, text, exp ]
238
239
  end
239
240
  end
240
241
 
@@ -282,8 +283,8 @@ in ruby:
282
283
 
283
284
  class MissingToken < MismatchedToken
284
285
  attr_accessor :inserted
285
- def initialize(expecting, input, inserted)
286
- super(expecting, input)
286
+ def initialize( expecting, input, inserted )
287
+ super( expecting, input )
287
288
  @inserted = inserted
288
289
  end
289
290
 
@@ -294,7 +295,7 @@ class MissingToken < MismatchedToken
294
295
  def message
295
296
  if @inserted and @symbol
296
297
  "%s: inserted %p at %p" %
297
- [self.class, @inserted, @symbol.text]
298
+ [ self.class, @inserted, @symbol.text ]
298
299
  else
299
300
  msg = self.class.to_s
300
301
  msg << ': at %p' % token.text unless @token.nil?
@@ -316,15 +317,15 @@ occurs when::
316
317
 
317
318
  class MismatchedRange < RecognitionError
318
319
  attr_accessor :min, :max
319
- def initialize(min, max, input)
320
+ def initialize( min, max, input )
320
321
  @min = min
321
322
  @max = max
322
- super(input)
323
+ super( input )
323
324
  end
324
325
 
325
326
  def message
326
327
  "%s: %p not in %p..%p" %
327
- [self.class, unexpected_type, @min, @max]
328
+ [ self.class, unexpected_type, @min, @max ]
328
329
  end
329
330
  end
330
331
 
@@ -340,14 +341,14 @@ occurs when::
340
341
 
341
342
  class MismatchedSet < RecognitionError
342
343
  attr_accessor :expecting
343
- def initialize(expecting, input)
344
- super(input)
344
+ def initialize( expecting, input )
345
+ super( input )
345
346
  @expecting = expecting
346
347
  end
347
348
 
348
349
  def message
349
350
  "%s: %p not in %p" %
350
- [self.class, unexpected_type, @expecting]
351
+ [ self.class, unexpected_type, @expecting ]
351
352
  end
352
353
  end
353
354
 
@@ -364,7 +365,7 @@ occurs when::
364
365
  class MismatchedNotSet < MismatchedSet
365
366
  def message
366
367
  '%s: %p != %p' %
367
- [self.class, unexpected_type, @expecting]
368
+ [ self.class, unexpected_type, @expecting ]
368
369
  end
369
370
  end
370
371
 
@@ -394,16 +395,16 @@ current input does not appear to be part of any token specification.
394
395
 
395
396
  class NoViableAlternative < RecognitionError
396
397
  attr_accessor :grammar_decision_description, :decision_number, :state_number
397
- def initialize(grammar_decision_description, decision_number, state_number, input)
398
+ def initialize( grammar_decision_description, decision_number, state_number, input )
398
399
  @grammar_decision_description = grammar_decision_description
399
400
  @decision_number = decision_number
400
401
  @state_number = state_number
401
- super(input)
402
+ super( input )
402
403
  end
403
404
 
404
405
  def message
405
406
  '%s: %p != [%p]' %
406
- [self.class, unexpected_type, @grammar_decision_description]
407
+ [ self.class, unexpected_type, @grammar_decision_description ]
407
408
  end
408
409
  end
409
410
 
@@ -438,13 +439,16 @@ now in ruby
438
439
 
439
440
  class EarlyExit < RecognitionError
440
441
  attr_accessor :decision_number
441
- def initialize(decision_number, input)
442
+
443
+ def initialize( decision_number, input )
442
444
  @decision_number = decision_number
443
- super(input)
445
+ super( input )
444
446
  end
447
+
445
448
  def message
446
449
  "The recognizer did not match anything for a (..)+ loop."
447
450
  end
451
+
448
452
  end
449
453
 
450
454
  =begin rdoc ANTLR3::Error::FailedPredicate
@@ -459,14 +463,18 @@ occurs when::
459
463
 
460
464
  class FailedPredicate < RecognitionError
461
465
  attr_accessor :input, :rule_name, :predicate_text
462
- def initialize(input, rule_name, predicate_text)
466
+ def initialize( input, rule_name, predicate_text )
463
467
  @rule_name = rule_name
464
468
  @predicate_text = predicate_text
465
- super(input)
469
+ super( input )
470
+ end
471
+
472
+ def inspect
473
+ '%s(%s, { %s }?)' % [ self.class.name, @rule_name, @predicate_text ]
466
474
  end
467
475
 
468
476
  def message
469
- '%s(%s, { %s }?)' % [self.class.name, @rule_name, @predicate_text]
477
+ "rule #@rule_name failed predicate: { #@predicate_text }?"
470
478
  end
471
479
  end
472
480
 
@@ -483,14 +491,14 @@ occurs when::
483
491
 
484
492
  class MismatchedTreeNode < RecognitionError
485
493
  attr_accessor :expecting, :input
486
- def initialize(expecting, input)
494
+ def initialize( expecting, input )
487
495
  @expecting = expecting
488
- super(input)
496
+ super( input )
489
497
  end
490
498
 
491
499
  def message
492
500
  '%s: %p != %p' %
493
- [self.class, unexpected_type, @expecting]
501
+ [ self.class, unexpected_type, @expecting ]
494
502
  end
495
503
  end
496
504
 
@@ -507,13 +515,13 @@ occurs when::
507
515
 
508
516
  class RewriteCardinalityError < StandardError
509
517
  attr_accessor :element_description
510
- def initialize(element_description)
518
+ def initialize( element_description )
511
519
  @element_description = element_description
512
- super(message)
520
+ super( message )
513
521
  end
514
522
 
515
523
  def message
516
- "%s: %s" % [self.class, @element_description]
524
+ "%s: %s" % [ self.class, @element_description ]
517
525
  end
518
526
  end
519
527
 
@@ -529,8 +537,8 @@ occurs when::
529
537
 
530
538
  class RewriteEarlyExit < RewriteCardinalityError
531
539
  attr_accessor :element_description
532
- def initialize(element_description = nil)
533
- super(element_description)
540
+ def initialize( element_description = nil )
541
+ super( element_description )
534
542
  end
535
543
  end
536
544
 
@@ -562,17 +570,17 @@ situations that result in tree inconsistencies:
562
570
  =end
563
571
 
564
572
  class TreeInconsistency < StandardError
565
- def self.failed_index_check!(expected, real)
566
- new(
573
+ def self.failed_index_check!( expected, real )
574
+ new(
567
575
  "%s: child indexes don't match -> expected %d found %d" %
568
- [self, expected, real]
576
+ [ self, expected, real ]
569
577
  )
570
578
  end
571
579
 
572
- def self.failed_parent_check!(expected, real)
573
- new(
580
+ def self.failed_parent_check!( expected, real )
581
+ new(
574
582
  "%s: parents don't match; expected %p found %p" %
575
- [self, expected, real]
583
+ [ self, expected, real ]
576
584
  )
577
585
  end
578
586
 
@@ -583,56 +591,56 @@ end
583
591
 
584
592
  module_function
585
593
 
586
- def MismatchedToken(expecting, input = @input)
587
- MismatchedToken.new(expecting, input)
594
+ def MismatchedToken( expecting, input = @input )
595
+ MismatchedToken.new( expecting, input )
588
596
  end
589
597
 
590
- def UnwantedToken(expecting, input = @input)
591
- UnwantedToken.new(expecting, input)
598
+ def UnwantedToken( expecting, input = @input )
599
+ UnwantedToken.new( expecting, input )
592
600
  end
593
601
 
594
- def MissingToken(expecting, inserted, input = @input)
595
- MissingToken.new(expecting, input, inserted)
602
+ def MissingToken( expecting, inserted, input = @input )
603
+ MissingToken.new( expecting, input, inserted )
596
604
  end
597
605
 
598
- def MismatchedRange(min, max, input = @input)
599
- MismatchedRange.new(min, max, input)
606
+ def MismatchedRange( min, max, input = @input )
607
+ MismatchedRange.new( min, max, input )
600
608
  end
601
609
 
602
- def MismatchedSet(expecting, input = @input)
603
- MismatchedSet.new(expecting, input)
610
+ def MismatchedSet( expecting, input = @input )
611
+ MismatchedSet.new( expecting, input )
604
612
  end
605
613
 
606
- def MismatchedNotSet(expecting, input = @input)
607
- MismatchedNotSet.new(expecting, input)
614
+ def MismatchedNotSet( expecting, input = @input )
615
+ MismatchedNotSet.new( expecting, input )
608
616
  end
609
617
 
610
- def NoViableAlternative(description, decision_number, state_number, input = @input)
611
- NoViableAlternative.new(description, decision_number, state_number, input)
618
+ def NoViableAlternative( description, decision, state, input = @input )
619
+ NoViableAlternative.new( description, decision, state, input )
612
620
  end
613
621
 
614
- def EarlyExit(decision_number, input = @input)
615
- EarlyExit.new(decision_number, input)
622
+ def EarlyExit( decision, input = @input )
623
+ EarlyExit.new( decision, input )
616
624
  end
617
625
 
618
- def FailedPredicate(rule_name, predicate_text, input = @input)
619
- FailedPredicate.new(input, rule_name, predicate_text)
626
+ def FailedPredicate( rule, predicate, input = @input )
627
+ FailedPredicate.new( input, rule_name, predicate )
620
628
  end
621
629
 
622
- def MismatchedTreeNode(expecting, input = @input)
623
- MismatchedTreeNode.new(expecting, input)
630
+ def MismatchedTreeNode( expecting, input = @input )
631
+ MismatchedTreeNode.new( expecting, input )
624
632
  end
625
633
 
626
- def RewriteCardinalityError(element_description)
627
- RewriteCardinalityError.new(element_description)
634
+ def RewriteCardinalityError( element_description )
635
+ RewriteCardinalityError.new( element_description )
628
636
  end
629
637
 
630
- def RewriteEarlyExit(element_description = nil)
631
- RewriteEarlyExit.new(element_description)
638
+ def RewriteEarlyExit( element_description = nil )
639
+ RewriteEarlyExit.new( element_description )
632
640
  end
633
641
 
634
- def RewriteEmptyStream(element_description)
635
- RewriteEmptyStream.new(element_description)
642
+ def RewriteEmptyStream( element_description )
643
+ RewriteEmptyStream.new( element_description )
636
644
  end
637
645
 
638
646
  end
@@ -646,12 +654,11 @@ include Error
646
654
  =end
647
655
 
648
656
  class Bug < StandardError
649
- def initialize(message = nil, *args)
657
+ def initialize( message = nil, *args )
650
658
  message = "something occurred that should not occur within unmodified, " <<
651
- "ANTLR-generated source code: #{message}"
652
- super(message, *args)
659
+ "ANTLR-generated source code: #{ message }"
660
+ super( message, *args )
653
661
  end
654
662
  end
655
663
 
656
664
  end
657
-