antlr3 1.8.0 → 1.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. data/History.txt +35 -0
  2. data/Manifest.txt +73 -0
  3. data/README.txt +6 -13
  4. data/java/RubyTarget.java +43 -19
  5. data/java/antlr-full-3.2.1.jar +0 -0
  6. data/lib/antlr3/debug.rb +2 -0
  7. data/lib/antlr3/debug/event-hub.rb +55 -55
  8. data/lib/antlr3/debug/record-event-listener.rb +2 -2
  9. data/lib/antlr3/debug/rule-tracer.rb +14 -14
  10. data/lib/antlr3/debug/socket.rb +47 -47
  11. data/lib/antlr3/debug/trace-event-listener.rb +8 -8
  12. data/lib/antlr3/main.rb +29 -9
  13. data/lib/antlr3/modes/ast-builder.rb +7 -7
  14. data/lib/antlr3/modes/filter.rb +19 -17
  15. data/lib/antlr3/profile.rb +34 -6
  16. data/lib/antlr3/recognizers.rb +50 -1
  17. data/lib/antlr3/streams.rb +19 -15
  18. data/lib/antlr3/streams/rewrite.rb +241 -229
  19. data/lib/antlr3/template/group-file-lexer.rb +6 -8
  20. data/lib/antlr3/template/group-file-parser.rb +16 -16
  21. data/lib/antlr3/template/group-file.rb +1 -1
  22. data/lib/antlr3/test/call-stack.rb +13 -13
  23. data/lib/antlr3/test/core-extensions.rb +69 -69
  24. data/lib/antlr3/test/functional.rb +0 -4
  25. data/lib/antlr3/test/grammar.rb +70 -70
  26. data/lib/antlr3/token.rb +41 -17
  27. data/lib/antlr3/tree.rb +11 -14
  28. data/lib/antlr3/tree/debug.rb +53 -53
  29. data/lib/antlr3/tree/visitor.rb +11 -11
  30. data/lib/antlr3/tree/wizard.rb +35 -35
  31. data/lib/antlr3/util.rb +18 -0
  32. data/lib/antlr3/version.rb +1 -1
  33. data/rakefile +1 -0
  34. data/samples/ANTLRv3Grammar.g +3 -3
  35. data/samples/JavaScript.g +702 -0
  36. data/samples/standard/C/C.g +543 -0
  37. data/samples/standard/C/C.tokens +175 -0
  38. data/samples/standard/C/C__testrig.st +0 -0
  39. data/samples/standard/C/c.rb +12 -0
  40. data/samples/standard/C/input +3479 -0
  41. data/samples/standard/C/output +171 -0
  42. data/samples/standard/LL-star/LLStar.g +101 -0
  43. data/samples/standard/LL-star/input +12 -0
  44. data/samples/standard/LL-star/ll-star.rb +12 -0
  45. data/samples/standard/LL-star/output +2 -0
  46. data/samples/standard/calc/Calculator.g +47 -0
  47. data/samples/standard/calc/Calculator.py +16 -0
  48. data/samples/standard/calc/Calculator.rb +28 -0
  49. data/samples/standard/cminus/CMinus.g +141 -0
  50. data/samples/standard/cminus/bytecode.group +80 -0
  51. data/samples/standard/cminus/cminus.rb +16 -0
  52. data/samples/standard/cminus/input +9 -0
  53. data/samples/standard/cminus/java.group +91 -0
  54. data/samples/standard/cminus/output +11 -0
  55. data/samples/standard/cminus/python.group +48 -0
  56. data/samples/standard/dynamic-scope/DynamicScopes.g +50 -0
  57. data/samples/standard/dynamic-scope/dynamic-scopes.rb +12 -0
  58. data/samples/standard/dynamic-scope/input +7 -0
  59. data/samples/standard/dynamic-scope/output +4 -0
  60. data/samples/standard/fuzzy/FuzzyJava.g +89 -0
  61. data/samples/standard/fuzzy/fuzzy.py +11 -0
  62. data/samples/standard/fuzzy/fuzzy.rb +9 -0
  63. data/samples/standard/fuzzy/input +13 -0
  64. data/samples/standard/fuzzy/output +12 -0
  65. data/samples/standard/hoisted-predicates/HoistedPredicates.g +40 -0
  66. data/samples/standard/hoisted-predicates/hoisted-predicates.rb +13 -0
  67. data/samples/standard/hoisted-predicates/input +1 -0
  68. data/samples/standard/hoisted-predicates/output +1 -0
  69. data/samples/standard/island-grammar/Javadoc.g +46 -0
  70. data/samples/standard/island-grammar/Simple.g +104 -0
  71. data/samples/standard/island-grammar/input +11 -0
  72. data/samples/standard/island-grammar/island.rb +12 -0
  73. data/samples/standard/island-grammar/output +16 -0
  74. data/samples/standard/java/Java.g +827 -0
  75. data/samples/standard/java/input +80 -0
  76. data/samples/standard/java/java.rb +13 -0
  77. data/samples/standard/java/output +1 -0
  78. data/samples/standard/python/Python.g +718 -0
  79. data/samples/standard/python/PythonTokenSource.rb +107 -0
  80. data/samples/standard/python/input +210 -0
  81. data/samples/standard/python/output +24 -0
  82. data/samples/standard/python/python.rb +14 -0
  83. data/samples/standard/rakefile +18 -0
  84. data/samples/standard/scopes/SymbolTable.g +66 -0
  85. data/samples/standard/scopes/input +12 -0
  86. data/samples/standard/scopes/output +3 -0
  87. data/samples/standard/scopes/scopes.rb +12 -0
  88. data/samples/standard/simplecTreeParser/SimpleC.g +113 -0
  89. data/samples/standard/simplecTreeParser/SimpleCWalker.g +64 -0
  90. data/samples/standard/simplecTreeParser/input +12 -0
  91. data/samples/standard/simplecTreeParser/output +1 -0
  92. data/samples/standard/simplecTreeParser/simplec.rb +18 -0
  93. data/samples/standard/treeparser/Lang.g +24 -0
  94. data/samples/standard/treeparser/LangDumpDecl.g +17 -0
  95. data/samples/standard/treeparser/input +1 -0
  96. data/samples/standard/treeparser/output +2 -0
  97. data/samples/standard/treeparser/treeparser.rb +18 -0
  98. data/samples/standard/tweak/Tweak.g +68 -0
  99. data/samples/standard/tweak/input +9 -0
  100. data/samples/standard/tweak/output +16 -0
  101. data/samples/standard/tweak/tweak.rb +13 -0
  102. data/samples/standard/xml/README +16 -0
  103. data/samples/standard/xml/XML.g +123 -0
  104. data/samples/standard/xml/input +21 -0
  105. data/samples/standard/xml/output +39 -0
  106. data/samples/standard/xml/xml.rb +9 -0
  107. data/templates/Ruby.stg +4 -4
  108. data/test/functional/ast-output/auto-ast.rb +0 -5
  109. data/test/functional/ast-output/rewrites.rb +4 -4
  110. data/test/unit/test-scope.rb +45 -0
  111. metadata +96 -8
@@ -374,7 +374,7 @@ module GroupFile
374
374
  case alt_1
375
375
  when 1
376
376
  # at line
377
- if @input.peek( 1 ).between?( 0x30, 0x39 ) || @input.peek( 1 ).between?( 0x41, 0x5a ) || @input.peek(1) == 0x5f || @input.peek( 1 ).between?( 0x61, 0x7a )
377
+ if @input.peek( 1 ).between?( 0x30, 0x39 ) || @input.peek( 1 ).between?( 0x41, 0x5a ) || @input.peek( 1 ) == 0x5f || @input.peek( 1 ).between?( 0x61, 0x7a )
378
378
  @input.consume
379
379
  else
380
380
  mse = MismatchedSet( nil )
@@ -411,7 +411,7 @@ module GroupFile
411
411
 
412
412
  # - - - - main rule block - - - -
413
413
  # at line 129:5: ( 'a' .. 'z' | '_' ) ( 'a' .. 'z' | '_' | 'A' .. 'Z' | '0' .. '9' )*
414
- if @input.peek(1) == 0x5f || @input.peek( 1 ).between?( 0x61, 0x7a )
414
+ if @input.peek( 1 ) == 0x5f || @input.peek( 1 ).between?( 0x61, 0x7a )
415
415
  @input.consume
416
416
  else
417
417
  mse = MismatchedSet( nil )
@@ -432,7 +432,7 @@ module GroupFile
432
432
  case alt_2
433
433
  when 1
434
434
  # at line
435
- if @input.peek( 1 ).between?( 0x30, 0x39 ) || @input.peek( 1 ).between?( 0x41, 0x5a ) || @input.peek(1) == 0x5f || @input.peek( 1 ).between?( 0x61, 0x7a )
435
+ if @input.peek( 1 ).between?( 0x30, 0x39 ) || @input.peek( 1 ).between?( 0x41, 0x5a ) || @input.peek( 1 ) == 0x5f || @input.peek( 1 ).between?( 0x61, 0x7a )
436
436
  @input.consume
437
437
  else
438
438
  mse = MismatchedSet( nil )
@@ -793,7 +793,7 @@ module GroupFile
793
793
  case alt_11
794
794
  when 1
795
795
  # at line
796
- if @input.peek( 1 ).between?( 0x9, 0xa ) || @input.peek( 1 ).between?( 0xc, 0xd ) || @input.peek(1) == 0x20
796
+ if @input.peek( 1 ).between?( 0x9, 0xa ) || @input.peek( 1 ).between?( 0xc, 0xd ) || @input.peek( 1 ) == 0x20
797
797
  @input.consume
798
798
  else
799
799
  mse = MismatchedSet( nil )
@@ -805,7 +805,7 @@ module GroupFile
805
805
 
806
806
  else
807
807
  match_count_11 > 0 and break
808
- eee = EarlyExit(11)
808
+ eee = EarlyExit( 11 )
809
809
 
810
810
 
811
811
  raise eee
@@ -920,7 +920,7 @@ module GroupFile
920
920
  1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1, 16, 3, -1,
921
921
  1, 4, 1, 2, 2, -1, 1, 1 )
922
922
  SPECIAL = unpack( 24, -1 )
923
- TRANSITION = [
923
+ TRANSITION = [
924
924
  unpack( 2, 15, 1, -1, 2, 15, 18, -1, 1, 15, 1, -1, 1, 13, 1, 14,
925
925
  2, -1, 1, 8, 1, 13, 1, 4, 1, 5, 1, 7, 1, -1, 1, 6, 2, -1,
926
926
  1, 14, 10, -1, 1, 2, 1, 3, 1, 12, 1, 9, 3, -1, 26, 10, 4,
@@ -986,5 +986,3 @@ end # module Template
986
986
  end # module ANTLR3
987
987
 
988
988
  # - - - - - - end action @lexer::footer - - - - - - -
989
-
990
-
@@ -130,7 +130,7 @@ module GroupFile
130
130
  def unescape( text )
131
131
  text.gsub( /\\(?:([abefnrstv])|([0-7]{3})|x([0-9a-fA-F]{2})|(.))/ ) do
132
132
  if $1
133
- case $1[0]
133
+ case $1[ 0 ]
134
134
  when ?a then "\a"
135
135
  when ?b then "\b"
136
136
  when ?e then "\e"
@@ -153,7 +153,7 @@ module GroupFile
153
153
  when TEMPLATE
154
154
  token.text.gsub( /\A<<<\r?\n?|\r?\n?>>>\Z/, '' )
155
155
  when STRING
156
- unescape( token.text[1...-1] )
156
+ unescape( token.text[ 1...-1 ] )
157
157
  end
158
158
  end
159
159
 
@@ -227,8 +227,8 @@ module GroupFile
227
227
  end # loop for decision 2
228
228
 
229
229
  rescue ANTLR3::Error::RecognitionError => re
230
- report_error(re)
231
- recover(re)
230
+ report_error( re )
231
+ recover( re )
232
232
 
233
233
  ensure
234
234
  # -> uncomment the next line to manually enable rule tracing
@@ -302,8 +302,8 @@ module GroupFile
302
302
  end
303
303
 
304
304
  rescue ANTLR3::Error::RecognitionError => re
305
- report_error(re)
306
- recover(re)
305
+ report_error( re )
306
+ recover( re )
307
307
 
308
308
  ensure
309
309
  # -> uncomment the next line to manually enable rule tracing
@@ -388,8 +388,8 @@ module GroupFile
388
388
  end
389
389
 
390
390
  rescue ANTLR3::Error::RecognitionError => re
391
- report_error(re)
392
- recover(re)
391
+ report_error( re )
392
+ recover( re )
393
393
 
394
394
  ensure
395
395
  # -> uncomment the next line to manually enable rule tracing
@@ -463,8 +463,8 @@ module GroupFile
463
463
 
464
464
  end
465
465
  rescue ANTLR3::Error::RecognitionError => re
466
- report_error(re)
467
- recover(re)
466
+ report_error( re )
467
+ recover( re )
468
468
 
469
469
  ensure
470
470
  # -> uncomment the next line to manually enable rule tracing
@@ -517,8 +517,8 @@ module GroupFile
517
517
  end # loop for decision 9
518
518
 
519
519
  rescue ANTLR3::Error::RecognitionError => re
520
- report_error(re)
521
- recover(re)
520
+ report_error( re )
521
+ recover( re )
522
522
 
523
523
  ensure
524
524
  # -> uncomment the next line to manually enable rule tracing
@@ -598,8 +598,8 @@ module GroupFile
598
598
 
599
599
  end
600
600
  rescue ANTLR3::Error::RecognitionError => re
601
- report_error(re)
602
- recover(re)
601
+ report_error( re )
602
+ recover( re )
603
603
 
604
604
  ensure
605
605
  # -> uncomment the next line to manually enable rule tracing
@@ -658,9 +658,9 @@ if __FILE__ == $0 and ARGV.first != '--'
658
658
  # GroupFile.g
659
659
 
660
660
 
661
- defined?(ANTLR3::Template::GroupFile::Lexer) or require 'antlr3/template/group-file'
661
+ defined?( ANTLR3::Template::GroupFile::Lexer ) or require 'antlr3/template/group-file'
662
662
  ANTLR3::Template::GroupFile::Parser.main( ARGV )
663
663
 
664
664
  # - - - - - - end action @parser::main - - - - - - -
665
665
 
666
- end
666
+ end
@@ -17,4 +17,4 @@ class Group
17
17
  Parser = GroupFile::Parser
18
18
  end
19
19
  end
20
- end
20
+ end
@@ -2,20 +2,20 @@
2
2
 
3
3
  unless defined? Call
4
4
 
5
- Call = Struct.new(:file, :line, :method)
5
+ Call = Struct.new( :file, :line, :method )
6
6
  class Call
7
7
 
8
- def self.parse(call_string)
9
- parts = call_string.split(':', 3)
8
+ def self.parse( call_string )
9
+ parts = call_string.split( ':', 3 )
10
10
  file = parts.shift
11
11
  line = parts.shift.to_i
12
12
  if parts.empty?
13
- return Call.new(file, line)
13
+ return Call.new( file, line )
14
14
  else
15
15
  mstring = parts.shift
16
- match = mstring.match(/`(.+)'/)
17
- method = match ? match[1] : nil
18
- return Call.new(file, line, method)
16
+ match = mstring.match( /`(.+)'/ )
17
+ method = match ? match[ 1 ] : nil
18
+ return Call.new( file, line, method )
19
19
  end
20
20
  end
21
21
 
@@ -32,9 +32,9 @@ class Call
32
32
  end
33
33
 
34
34
  def to_s
35
- string = '%s:%i' % [file, line]
35
+ string = '%s:%i' % [ file, line ]
36
36
  method and string << ":in `%s'" % method
37
- return(string)
37
+ return( string )
38
38
  end
39
39
 
40
40
  def inspect
@@ -43,15 +43,15 @@ class Call
43
43
  end
44
44
 
45
45
  module Kernel
46
- def call_stack(depth = 1)
47
- Call.convert_backtrace(caller(depth + 1))
46
+ def call_stack( depth = 1 )
47
+ Call.convert_backtrace( caller( depth + 1 ) )
48
48
  end
49
49
  end
50
50
 
51
51
  class Exception
52
52
  def backtrace!
53
- Call.convert_backtrace(backtrace)
53
+ Call.convert_backtrace( backtrace )
54
54
  end
55
55
  end
56
56
 
57
- end # unless defined? Call
57
+ end # unless defined? Call
@@ -2,28 +2,28 @@
2
2
  # encoding: utf-8
3
3
 
4
4
  class String
5
- def /(subpath)
6
- File.join(self, subpath.to_s)
5
+ def /( subpath )
6
+ File.join( self, subpath.to_s )
7
7
  end
8
8
 
9
- def here_indent(chr = '| ')
10
- dup.here_indent!(chr)
9
+ def here_indent( chr = '| ' )
10
+ dup.here_indent!( chr )
11
11
  end
12
12
 
13
- def here_indent!(chr = '| ')
14
- chr = Regexp.escape(chr)
15
- exp = Regexp.new("^ *#{chr}")
16
- self.gsub!(exp,'')
13
+ def here_indent!( chr = '| ' )
14
+ chr = Regexp.escape( chr )
15
+ exp = Regexp.new( "^ *#{ chr }" )
16
+ self.gsub!( exp,'' )
17
17
  return self
18
18
  end
19
19
 
20
- def here_flow(chr = '| ')
21
- dup.here_flow!(chr)
20
+ def here_flow( chr = '| ' )
21
+ dup.here_flow!( chr )
22
22
  end
23
23
 
24
- def here_flow!(chr = '| ')
25
- here_indent!(chr).gsub!(/\n\s+/,' ')
26
- return(self)
24
+ def here_flow!( chr = '| ' )
25
+ here_indent!( chr ).gsub!( /\n\s+/,' ' )
26
+ return( self )
27
27
  end
28
28
 
29
29
  # Indent left or right by n spaces.
@@ -32,11 +32,11 @@ class String
32
32
  # CREDIT: Gavin Sinclair
33
33
  # CREDIT: Trans
34
34
 
35
- def indent(n)
35
+ def indent( n )
36
36
  if n >= 0
37
- gsub(/^/, ' ' * n)
37
+ gsub( /^/, ' ' * n )
38
38
  else
39
- gsub(/^ {0,#{-n}}/, "")
39
+ gsub( /^ {0,#{ -n }}/, "" )
40
40
  end
41
41
  end
42
42
 
@@ -44,8 +44,8 @@ class String
44
44
  #
45
45
  # CREDIT: Noah Gibbs
46
46
 
47
- def outdent(n)
48
- indent(-n)
47
+ def outdent( n )
48
+ indent( -n )
49
49
  end
50
50
 
51
51
  # Returns the shortest length of leading whitespace for all non-blank lines
@@ -57,11 +57,11 @@ class String
57
57
  #
58
58
  # CREDIT: Kyle Yetter
59
59
  def level_of_indent
60
- self.scan(/^ *(?=\S)/).map { |space| space.length }.min || 0
60
+ self.scan( /^ *(?=\S)/ ).map { |space| space.length }.min || 0
61
61
  end
62
62
 
63
- def fixed_indent(n)
64
- self.outdent(self.level_of_indent).indent(n)
63
+ def fixed_indent( n )
64
+ self.outdent( self.level_of_indent ).indent( n )
65
65
  end
66
66
 
67
67
  # Provides a margin controlled string.
@@ -77,16 +77,16 @@ class String
77
77
  #
78
78
  # CREDIT: Trans
79
79
 
80
- def margin(n=0)
80
+ def margin( n=0 )
81
81
  #d = /\A.*\n\s*(.)/.match( self )[1]
82
82
  #d = /\A\s*(.)/.match( self)[1] unless d
83
- d = ((/\A.*\n\s*(.)/.match(self)) ||
84
- (/\A\s*(.)/.match(self)))[1]
83
+ d = ( ( /\A.*\n\s*(.)/.match( self ) ) ||
84
+ ( /\A\s*(.)/.match( self ) ) )[ 1 ]
85
85
  return '' unless d
86
86
  if n == 0
87
- gsub(/\n\s*\Z/,'').gsub(/^\s*[#{d}]/, '')
87
+ gsub( /\n\s*\Z/,'' ).gsub( /^\s*[#{ d }]/, '' )
88
88
  else
89
- gsub(/\n\s*\Z/,'').gsub(/^\s*[#{d}]/, ' ' * n)
89
+ gsub( /\n\s*\Z/,'' ).gsub( /^\s*[#{ d }]/, ' ' * n )
90
90
  end
91
91
  end
92
92
 
@@ -99,16 +99,16 @@ class String
99
99
  # CREDIT: Noah Gibbs
100
100
  # CREDIT: GGaramuno
101
101
 
102
- def expand_tabs(n=8)
102
+ def expand_tabs( n=8 )
103
103
  n = n.to_int
104
104
  raise ArgumentError, "n must be >= 0" if n < 0
105
- return gsub(/\t/, "") if n == 0
106
- return gsub(/\t/, " ") if n == 1
105
+ return gsub( /\t/, "" ) if n == 0
106
+ return gsub( /\t/, " " ) if n == 1
107
107
  str = self.dup
108
108
  while
109
- str.gsub!(/^([^\t\n]*)(\t+)/) { |f|
110
- val = ( n * $2.size - ($1.size % n) )
111
- $1 << (' ' * val)
109
+ str.gsub!( /^([^\t\n]*)(\t+)/ ) { |f|
110
+ val = ( n * $2.size - ( $1.size % n ) )
111
+ $1 << ( ' ' * val )
112
112
  }
113
113
  end
114
114
  str
@@ -125,10 +125,10 @@ class String
125
125
  # "SnakeCase::Errors".underscore #=> "snake_case/errors"
126
126
 
127
127
  def snakecase
128
- gsub(/::/, '/'). # NOT SO SURE ABOUT THIS -T
129
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
130
- gsub(/([a-z\d])([A-Z])/,'\1_\2').
131
- tr("-", "_").
128
+ gsub( /::/, '/' ). # NOT SO SURE ABOUT THIS -T
129
+ gsub( /([A-Z]+)([A-Z][a-z])/,'\1_\2' ).
130
+ gsub( /([a-z\d])([A-Z])/,'\1_\2' ).
131
+ tr( "-", "_" ).
132
132
  downcase
133
133
  end
134
134
 
@@ -150,26 +150,26 @@ class Module
150
150
  # CREDIT: Trans
151
151
 
152
152
  def modspace
153
- space = name[ 0...(name.rindex( '::' ) || 0)]
154
- space.empty? ? Object : eval(space)
153
+ space = name[ 0...( name.rindex( '::' ) || 0 ) ]
154
+ space.empty? ? Object : eval( space )
155
155
  end
156
156
  end
157
157
 
158
158
  module Kernel
159
159
  autoload :Tempfile, 'tempfile'
160
160
 
161
- def screen_width(out=STDERR)
162
- default_width = ENV['COLUMNS'] || 80
161
+ def screen_width( out=STDERR )
162
+ default_width = ENV[ 'COLUMNS' ] || 80
163
163
  tiocgwinsz = 0x5413
164
- data = [0, 0, 0, 0].pack("SSSS")
165
- if out.ioctl(tiocgwinsz, data) >= 0 then
166
- rows, cols, xpixels, ypixels = data.unpack("SSSS")
164
+ data = [ 0, 0, 0, 0 ].pack( "SSSS" )
165
+ if out.ioctl( tiocgwinsz, data ) >= 0 then
166
+ rows, cols, xpixels, ypixels = data.unpack( "SSSS" )
167
167
  if cols >= 0 then cols else default_width end
168
168
  else
169
169
  default_width
170
170
  end
171
171
  rescue Exception => e
172
- default_width rescue (raise e)
172
+ default_width rescue ( raise e )
173
173
  end
174
174
  end
175
175
 
@@ -184,11 +184,11 @@ class File
184
184
  # File.relative_path('rel/path') # => './rel/path'
185
185
  # File.relative_path('/some/abs/path', '/some') # => './abs/path'
186
186
  # File.relative_path('/some/file.txt', '/some/abs/path') # => '../../file.txt'
187
- def self.relative_path(target, reference = Dir.pwd)
188
- pair = [target, reference].map! do |path|
189
- File.expand_path(path.to_s).split(File::Separator).tap do |list|
190
- if list.empty? then list << String.new(File::Separator)
191
- elsif list.first.empty? then list.first.replace(File::Separator)
187
+ def self.relative_path( target, reference = Dir.pwd )
188
+ pair = [ target, reference ].map! do |path|
189
+ File.expand_path( path.to_s ).split( File::Separator ).tap do |list|
190
+ if list.empty? then list << String.new( File::Separator )
191
+ elsif list.first.empty? then list.first.replace( File::Separator )
192
192
  end
193
193
  end
194
194
  end
@@ -199,30 +199,30 @@ class File
199
199
  reference_list.shift or break
200
200
  end
201
201
 
202
- relative_list = Array.new(reference_list.length, '..')
202
+ relative_list = Array.new( reference_list.length, '..' )
203
203
  relative_list.empty? and relative_list << '.'
204
- relative_list.concat(target_list).compact!
205
- return relative_list.join(File::Separator)
204
+ relative_list.concat( target_list ).compact!
205
+ return relative_list.join( File::Separator )
206
206
  end
207
207
 
208
208
  end
209
209
 
210
210
  class Dir
211
- defined?(DOTS) or DOTS = %w(. ..).freeze
212
- def self.children(directory)
213
- entries = Dir.entries(directory) - DOTS
211
+ defined?( DOTS ) or DOTS = %w(. ..).freeze
212
+ def self.children( directory )
213
+ entries = Dir.entries( directory ) - DOTS
214
214
  entries.map! do |entry|
215
- File.join(directory, entry)
215
+ File.join( directory, entry )
216
216
  end
217
217
  end
218
218
 
219
- def self.mkpath(path)
220
- $VERBOSE and $stderr.puts("INFO: Dir.mkpath(%p)" % path)
221
- test(?d, path) and return(path)
222
- parent = File.dirname(path)
223
- test(?d, parent) or mkpath(parent)
224
- Dir.mkdir(path)
225
- return(path)
219
+ def self.mkpath( path )
220
+ $VERBOSE and $stderr.puts( "INFO: Dir.mkpath(%p)" % path )
221
+ test( ?d, path ) and return( path )
222
+ parent = File.dirname( path )
223
+ test( ?d, parent ) or mkpath( parent )
224
+ Dir.mkdir( path )
225
+ return( path )
226
226
  end
227
227
 
228
228
  end
@@ -240,12 +240,12 @@ class Array
240
240
  #
241
241
  # CREDIT: Richard Laugesen
242
242
 
243
- def pad(len, val=nil)
243
+ def pad( len, val=nil )
244
244
  return dup if self.size >= len.abs
245
245
  if len < 0
246
- Array.new((len+size).abs,val) + self
246
+ Array.new( ( len+size ).abs,val ) + self
247
247
  else
248
- self + Array.new(len-size,val)
248
+ self + Array.new( len-size,val )
249
249
  end
250
250
  end
251
251
 
@@ -257,12 +257,12 @@ class Array
257
257
  #
258
258
  # CREDIT: Richard Laugesen
259
259
 
260
- def pad!(len, val=nil)
260
+ def pad!( len, val=nil )
261
261
  return self if self.size >= len.abs
262
262
  if len < 0
263
- replace Array.new((len+size).abs,val) + self
263
+ replace Array.new( ( len+size ).abs,val ) + self
264
264
  else
265
- concat Array.new(len-size,val)
265
+ concat Array.new( len-size,val )
266
266
  end
267
267
  end
268
268