Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Seriously. stop with all the clever. The ruby parser is fast enough

  • Loading branch information...
commit ea143708e8d3563bc5f4aa532fcbe60a717948fc 1 parent 5137739
Ryan Davis authored January 10, 2011

Showing 1 changed file with 2 additions and 51 deletions. Show diff stats Hide diff stats

  1. 53  lib/racc/parserfilegenerator.rb
53  lib/racc/parserfilegenerator.rb
@@ -325,57 +325,8 @@ def state_transition_table
325 325
     end
326 326
 
327 327
     def integer_list(name, table)
328  
-      if table.size > 2000
329  
-        serialize_integer_list_compressed name, table
330  
-      else
331  
-        serialize_integer_list_std name, table
332  
-      end
333  
-    end
334  
-
335  
-    def serialize_integer_list_compressed(name, table)
336  
-      # TODO: this can be made a LOT more clean with a simple split/map
337  
-      sep  = "\n"
338  
-      nsep = ",\n"
339  
-      buf  = ''
340  
-      com  = ''
341  
-      ncom = ','
342  
-      co   = com
343  
-      @f.print 'clist = ['
344  
-      table.each do |i|
345  
-        buf << co << i.to_s; co = ncom
346  
-        if buf.size > 66
347  
-          @f.print sep; sep = nsep
348  
-          @f.print "'", buf, "'"
349  
-          buf = ''
350  
-          co = com
351  
-        end
352  
-      end
353  
-      unless buf.empty?
354  
-        @f.print sep
355  
-        @f.print "'", buf, "'"
356  
-      end
357  
-      line ' ]'
358  
-
359  
-      @f.print(<<-End)
360  
-        #{name} = arr = ::Array.new(#{table.size}, nil)
361  
-        idx = 0
362  
-        clist.each do |str|
363  
-          str.split(',', -1).each do |i|
364  
-            arr[idx] = i.to_i unless i.empty?
365  
-            idx += 1
366  
-          end
367  
-        end
368  
-      End
369  
-    end
370  
-
371  
-    def serialize_integer_list_std(name, table)
372  
-      sep = ''
373  
-      line "#{name} = ["
374  
-      table.each_slice(10) do |ns|
375  
-        @f.print sep; sep = ",\n"
376  
-        @f.print ns.map {|n| sprintf('%6s', n ? n.to_s : 'nil') }.join(',')
377  
-      end
378  
-      line ' ]'
  328
+      lines = table.inspect.split(/((?:\w+, ){15})/).reject { |s| s.empty? }
  329
+      line "#{name} = #{lines.join("\n")}"
379 330
     end
380 331
 
381 332
     def i_i_sym_list(name, table)

0 notes on commit ea14370

Please sign in to comment.
Something went wrong with that request. Please try again.