racc 1.4.16 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/README.ja.rdoc +0 -1
  3. data/README.rdoc +8 -11
  4. data/bin/racc +37 -23
  5. data/{rdoc → doc}/en/NEWS.en.rdoc +0 -0
  6. data/{rdoc → doc}/en/grammar.en.rdoc +27 -31
  7. data/doc/en/grammar2.en.rdoc +219 -0
  8. data/{rdoc → doc}/ja/NEWS.ja.rdoc +0 -0
  9. data/{rdoc → doc}/ja/command.ja.html +1 -1
  10. data/{rdoc → doc}/ja/debug.ja.rdoc +0 -0
  11. data/{rdoc → doc}/ja/grammar.ja.rdoc +0 -0
  12. data/{rdoc → doc}/ja/index.ja.html +0 -0
  13. data/{rdoc → doc}/ja/parser.ja.rdoc +0 -0
  14. data/{rdoc → doc}/ja/usage.ja.html +0 -0
  15. data/ext/racc/cparse/cparse.c +19 -17
  16. data/ext/racc/cparse/extconf.rb +2 -1
  17. data/lib/racc/compat.rb +5 -4
  18. data/lib/racc/debugflags.rb +5 -4
  19. data/lib/racc/exception.rb +4 -1
  20. data/lib/racc/grammar.rb +22 -17
  21. data/lib/racc/grammarfileparser.rb +7 -6
  22. data/lib/racc/info.rb +5 -2
  23. data/lib/racc/iset.rb +5 -4
  24. data/lib/racc/logfilegenerator.rb +5 -4
  25. data/lib/racc/parser-text.rb +10 -16
  26. data/lib/racc/parser.rb +10 -16
  27. data/lib/racc/parserfilegenerator.rb +5 -47
  28. data/lib/racc/sourcetext.rb +5 -4
  29. data/lib/racc/state.rb +4 -1
  30. data/lib/racc/statetransitiontable.rb +9 -14
  31. metadata +22 -140
  32. data/DEPENDS +0 -4
  33. data/Manifest.txt +0 -146
  34. data/Rakefile +0 -58
  35. data/bin/racc2y +0 -195
  36. data/bin/y2racc +0 -339
  37. data/ext/racc/com/headius/racc/Cparse.java +0 -849
  38. data/fastcache/extconf.rb +0 -2
  39. data/fastcache/fastcache.c +0 -185
  40. data/lib/racc/pre-setup +0 -13
  41. data/misc/dist.sh +0 -31
  42. data/sample/array.y +0 -67
  43. data/sample/array2.y +0 -59
  44. data/sample/calc-ja.y +0 -66
  45. data/sample/calc.y +0 -65
  46. data/sample/conflict.y +0 -15
  47. data/sample/hash.y +0 -60
  48. data/sample/lalr.y +0 -17
  49. data/sample/lists.y +0 -57
  50. data/sample/syntax.y +0 -46
  51. data/sample/yyerr.y +0 -46
  52. data/setup.rb +0 -1587
  53. data/tasks/doc.rb +0 -12
  54. data/tasks/email.rb +0 -55
  55. data/test/assets/cadenza.y +0 -170
  56. data/test/assets/cast.y +0 -926
  57. data/test/assets/chk.y +0 -126
  58. data/test/assets/conf.y +0 -16
  59. data/test/assets/csspool.y +0 -729
  60. data/test/assets/digraph.y +0 -29
  61. data/test/assets/echk.y +0 -118
  62. data/test/assets/edtf.y +0 -583
  63. data/test/assets/err.y +0 -60
  64. data/test/assets/error_recovery.y +0 -35
  65. data/test/assets/expect.y +0 -7
  66. data/test/assets/firstline.y +0 -4
  67. data/test/assets/huia.y +0 -318
  68. data/test/assets/ichk.y +0 -102
  69. data/test/assets/intp.y +0 -546
  70. data/test/assets/journey.y +0 -47
  71. data/test/assets/liquor.y +0 -313
  72. data/test/assets/machete.y +0 -423
  73. data/test/assets/macruby.y +0 -2197
  74. data/test/assets/mailp.y +0 -437
  75. data/test/assets/mediacloth.y +0 -599
  76. data/test/assets/mof.y +0 -649
  77. data/test/assets/namae.y +0 -302
  78. data/test/assets/nasl.y +0 -626
  79. data/test/assets/newsyn.y +0 -25
  80. data/test/assets/noend.y +0 -4
  81. data/test/assets/nokogiri-css.y +0 -255
  82. data/test/assets/nonass.y +0 -41
  83. data/test/assets/normal.y +0 -27
  84. data/test/assets/norule.y +0 -4
  85. data/test/assets/nullbug1.y +0 -25
  86. data/test/assets/nullbug2.y +0 -15
  87. data/test/assets/opal.y +0 -1807
  88. data/test/assets/opt.y +0 -123
  89. data/test/assets/percent.y +0 -35
  90. data/test/assets/php_serialization.y +0 -98
  91. data/test/assets/recv.y +0 -97
  92. data/test/assets/riml.y +0 -665
  93. data/test/assets/rrconf.y +0 -14
  94. data/test/assets/ruby18.y +0 -1943
  95. data/test/assets/ruby19.y +0 -2174
  96. data/test/assets/ruby20.y +0 -2350
  97. data/test/assets/ruby21.y +0 -2359
  98. data/test/assets/ruby22.y +0 -2381
  99. data/test/assets/scan.y +0 -72
  100. data/test/assets/syntax.y +0 -50
  101. data/test/assets/tp_plus.y +0 -622
  102. data/test/assets/twowaysql.y +0 -278
  103. data/test/assets/unterm.y +0 -5
  104. data/test/assets/useless.y +0 -12
  105. data/test/assets/yyerr.y +0 -46
  106. data/test/bench.y +0 -36
  107. data/test/helper.rb +0 -115
  108. data/test/infini.y +0 -8
  109. data/test/regress/cadenza +0 -796
  110. data/test/regress/cast +0 -3425
  111. data/test/regress/csspool +0 -2318
  112. data/test/regress/edtf +0 -1794
  113. data/test/regress/huia +0 -1392
  114. data/test/regress/journey +0 -222
  115. data/test/regress/liquor +0 -885
  116. data/test/regress/machete +0 -833
  117. data/test/regress/mediacloth +0 -1463
  118. data/test/regress/mof +0 -1368
  119. data/test/regress/namae +0 -634
  120. data/test/regress/nasl +0 -2058
  121. data/test/regress/nokogiri-css +0 -836
  122. data/test/regress/opal +0 -6429
  123. data/test/regress/php_serialization +0 -336
  124. data/test/regress/riml +0 -3297
  125. data/test/regress/ruby18 +0 -6351
  126. data/test/regress/ruby22 +0 -7456
  127. data/test/regress/tp_plus +0 -1933
  128. data/test/regress/twowaysql +0 -556
  129. data/test/scandata/brace +0 -7
  130. data/test/scandata/gvar +0 -1
  131. data/test/scandata/normal +0 -4
  132. data/test/scandata/percent +0 -18
  133. data/test/scandata/slash +0 -10
  134. data/test/src.intp +0 -34
  135. data/test/start.y +0 -20
  136. data/test/test_chk_y.rb +0 -52
  137. data/test/test_grammar_file_parser.rb +0 -15
  138. data/test/test_racc_command.rb +0 -322
  139. data/test/test_scan_y.rb +0 -52
  140. data/test/testscanner.rb +0 -51
  141. data/web/racc.en.rhtml +0 -42
  142. data/web/racc.ja.rhtml +0 -51
@@ -1,13 +1,14 @@
1
+ #--
2
+ #
1
3
  #
2
- # $Id: 74ff4369ce53c7f45cfc2644ce907785104ebf6e $
3
4
  #
4
5
  # Copyright (c) 1999-2006 Minero Aoki
5
6
  #
6
7
  # This program is free software.
7
- # You can distribute/modify this program under the terms of
8
- # the GNU LGPL, Lesser General Public License version 2.1.
9
- # For details of LGPL, see the file "COPYING".
8
+ # You can distribute/modify this program under the same terms of ruby.
9
+ # see the file "COPYING".
10
10
  #
11
+ #++
11
12
 
12
13
  module Racc
13
14
 
@@ -1,11 +1,14 @@
1
+ #--
2
+ #
1
3
  #
2
- # $Id: ebb9798ad0b211e031670a12a1ab154678c1c8f3 $
3
4
  #
4
5
  # Copyright (c) 1999-2006 Minero Aoki
5
6
  #
6
7
  # This program is free software.
7
8
  # You can distribute/modify this program under the same terms of ruby.
8
9
  # see the file "COPYING".
10
+ #
11
+ #++
9
12
 
10
13
  module Racc
11
14
  class Error < StandardError; end
data/lib/racc/grammar.rb CHANGED
@@ -1,11 +1,14 @@
1
+ #--
2
+ #
1
3
  #
2
- # $Id: 3fcabd58bef02540bf78e8142469681cb9f975c2 $
3
4
  #
4
5
  # Copyright (c) 1999-2006 Minero Aoki
5
6
  #
6
7
  # This program is free software.
7
8
  # You can distribute/modify this program under the same terms of ruby.
8
9
  # see the file "COPYING".
10
+ #
11
+ #++
9
12
 
10
13
  require 'racc/compat'
11
14
  require 'racc/iset'
@@ -83,14 +86,15 @@ module Racc
83
86
  end
84
87
 
85
88
  def n_useless_nonterminals
86
- @n_useless_nonterminals ||=
87
- begin
88
- n = 0
89
- @symboltable.each_nonterminal do |sym|
90
- n += 1 if sym.useless?
91
- end
92
- n
93
- end
89
+ @n_useless_nonterminals ||= each_useless_nonterminal.count
90
+ end
91
+
92
+ def each_useless_nonterminal
93
+ return to_enum __method__ unless block_given?
94
+
95
+ @symboltable.each_nonterminal do |sym|
96
+ yield sym if sym.useless?
97
+ end
94
98
  end
95
99
 
96
100
  def useless_rule_exist?
@@ -98,14 +102,15 @@ module Racc
98
102
  end
99
103
 
100
104
  def n_useless_rules
101
- @n_useless_rules ||=
102
- begin
103
- n = 0
104
- each do |r|
105
- n += 1 if r.useless?
106
- end
107
- n
108
- end
105
+ @n_useless_rules ||= each_useless_rule.count
106
+ end
107
+
108
+ def each_useless_rule
109
+ return to_enum __method__ unless block_given?
110
+
111
+ each do |r|
112
+ yield r if r.useless?
113
+ end
109
114
  end
110
115
 
111
116
  def nfa
@@ -1,13 +1,14 @@
1
+ #--
2
+ #
1
3
  #
2
- # $Id: 63bd084db2dce8a2c9760318faae6104717cead7 $
3
4
  #
4
5
  # Copyright (c) 1999-2006 Minero Aoki
5
6
  #
6
7
  # This program is free software.
7
- # You can distribute/modify this program under the terms of
8
- # the GNU LGPL, Lesser General Public License version 2.1.
9
- # For details of the GNU LGPL, see the file "COPYING".
8
+ # You can distribute/modify this program under the same terms of ruby.
9
+ # see the file "COPYING".
10
10
  #
11
+ #++
11
12
 
12
13
  require 'racc'
13
14
  require 'racc/compat'
@@ -286,7 +287,7 @@ module Racc
286
287
  end
287
288
 
288
289
  def add_user_code(label, src)
289
- @result.params.send(USER_CODE_LABELS[label]).push src
290
+ @result.params.public_send(USER_CODE_LABELS[label]).push src
290
291
  end
291
292
 
292
293
  end
@@ -427,7 +428,7 @@ module Racc
427
428
  $raccs_print_type = false
428
429
 
429
430
  def scan_action
430
- buf = ''
431
+ buf = String.new
431
432
  nest = 1
432
433
  pre = nil
433
434
  @in_block = 'action'
data/lib/racc/info.rb CHANGED
@@ -1,14 +1,17 @@
1
+ #--
2
+ #
1
3
  #
2
- # $Id: 8ab2cb5341529fe5e35956bb1a1f42ec9b9c6f5a $
3
4
  #
4
5
  # Copyright (c) 1999-2006 Minero Aoki
5
6
  #
6
7
  # This program is free software.
7
8
  # You can distribute/modify this program under the same terms of ruby.
8
9
  # see the file "COPYING".
10
+ #
11
+ #++
9
12
 
10
13
  module Racc
11
- VERSION = '1.4.16'
14
+ VERSION = '1.6.0'
12
15
  Version = VERSION
13
16
  Copyright = 'Copyright (c) 1999-2006 Minero Aoki'
14
17
  end
data/lib/racc/iset.rb CHANGED
@@ -1,13 +1,14 @@
1
+ #--
2
+ #
1
3
  #
2
- # $Id: 31aa4331c08dfd4609c06eb5f94b7ef38dc708e1 $
3
4
  #
4
5
  # Copyright (c) 1999-2006 Minero Aoki
5
6
  #
6
7
  # This program is free software.
7
- # You can distribute/modify this program under the terms of
8
- # the GNU LGPL, Lesser General Public License version 2.1.
9
- # For details of the GNU LGPL, see the file "COPYING".
8
+ # You can distribute/modify this program under the same terms of ruby.
9
+ # see the file "COPYING".
10
10
  #
11
+ #++
11
12
 
12
13
  module Racc
13
14
 
@@ -1,13 +1,14 @@
1
+ #--
2
+ #
1
3
  #
2
- # $Id: 5e9d0a01b5d56fd9cdc3d5cb078b1a3e1bbaf779 $
3
4
  #
4
5
  # Copyright (c) 1999-2006 Minero Aoki
5
6
  #
6
7
  # This program is free software.
7
- # You can distribute/modify this program under the terms of
8
- # the GNU LGPL, Lesser General Public License version 2.1.
9
- # For details of the GNU LGPL, see the file "COPYING".
8
+ # You can distribute/modify this program under the same terms of ruby.
9
+ # see the file "COPYING".
10
10
  #
11
+ #++
11
12
 
12
13
  module Racc
13
14
 
@@ -31,7 +31,7 @@ end
31
31
  # == Command-line Reference
32
32
  #
33
33
  # racc [-o<var>filename</var>] [--output-file=<var>filename</var>]
34
- # [-e<var>rubypath</var>] [--embedded=<var>rubypath</var>]
34
+ # [-e<var>rubypath</var>] [--executable=<var>rubypath</var>]
35
35
  # [-v] [--verbose]
36
36
  # [-O<var>filename</var>] [--log-file=<var>filename</var>]
37
37
  # [-g] [--debug]
@@ -43,7 +43,7 @@ end
43
43
  # [-S] [--output-status]
44
44
  # [--version] [--copyright] [--help] <var>grammarfile</var>
45
45
  #
46
- # [+filename+]
46
+ # [+grammarfile+]
47
47
  # Racc grammar file. Any extension is permitted.
48
48
  # [-o+outfile+, --output-file=+outfile+]
49
49
  # A filename for output. default is <+filename+>.tab.rb
@@ -181,45 +181,39 @@ end
181
181
  # Your own parser is completely yours.
182
182
  module Racc
183
183
 
184
- unless defined?(Racc_No_Extentions)
185
- Racc_No_Extentions = false # :nodoc:
184
+ unless defined?(Racc_No_Extensions)
185
+ Racc_No_Extensions = false # :nodoc:
186
186
  end
187
187
 
188
188
  class Parser
189
189
 
190
190
  Racc_Runtime_Version = ::Racc::VERSION
191
- Racc_Runtime_Revision = '$Id: 7adc21ee7a5690f10b7ff399b8af4e2717b9d94c $'
192
-
193
191
  Racc_Runtime_Core_Version_R = ::Racc::VERSION
194
- Racc_Runtime_Core_Revision_R = '$Id: 7adc21ee7a5690f10b7ff399b8af4e2717b9d94c $'.split[1]
192
+
195
193
  begin
196
194
  if Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
195
+ require 'jruby'
197
196
  require 'racc/cparse-jruby.jar'
198
197
  com.headius.racc.Cparse.new.load(JRuby.runtime, false)
199
198
  else
200
199
  require 'racc/cparse'
201
200
  end
202
- # Racc_Runtime_Core_Version_C = (defined in extention)
203
- Racc_Runtime_Core_Revision_C = Racc_Runtime_Core_Id_C.split[2]
201
+
204
202
  unless new.respond_to?(:_racc_do_parse_c, true)
205
203
  raise LoadError, 'old cparse.so'
206
204
  end
207
- if Racc_No_Extentions
205
+ if Racc_No_Extensions
208
206
  raise LoadError, 'selecting ruby version of racc runtime core'
209
207
  end
210
208
 
211
209
  Racc_Main_Parsing_Routine = :_racc_do_parse_c # :nodoc:
212
210
  Racc_YY_Parse_Method = :_racc_yyparse_c # :nodoc:
213
211
  Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_C # :nodoc:
214
- Racc_Runtime_Core_Revision = Racc_Runtime_Core_Revision_C # :nodoc:
215
212
  Racc_Runtime_Type = 'c' # :nodoc:
216
213
  rescue LoadError
217
- puts $!
218
- puts $!.backtrace
219
214
  Racc_Main_Parsing_Routine = :_racc_do_parse_rb
220
215
  Racc_YY_Parse_Method = :_racc_yyparse_rb
221
216
  Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_R
222
- Racc_Runtime_Core_Revision = Racc_Runtime_Core_Revision_R
223
217
  Racc_Runtime_Type = 'ruby'
224
218
  end
225
219
 
@@ -332,7 +326,7 @@ puts $!.backtrace
332
326
  # It must 'yield' the token, which format is [TOKEN-SYMBOL, VALUE].
333
327
  class_eval %{
334
328
  def yyparse(recv, mid)
335
- #{Racc_YY_Parse_Method}(recv, mid, _racc_setup(), true)
329
+ #{Racc_YY_Parse_Method}(recv, mid, _racc_setup(), false)
336
330
  end
337
331
  }
338
332
 
@@ -554,7 +548,7 @@ puts $!.backtrace
554
548
  end
555
549
 
556
550
  # Exit parser.
557
- # Return value is Symbol_Value_Stack[0].
551
+ # Return value is +Symbol_Value_Stack[0]+.
558
552
  def yyaccept
559
553
  throw :racc_jump, 2
560
554
  end
data/lib/racc/parser.rb CHANGED
@@ -29,7 +29,7 @@ end
29
29
  # == Command-line Reference
30
30
  #
31
31
  # racc [-o<var>filename</var>] [--output-file=<var>filename</var>]
32
- # [-e<var>rubypath</var>] [--embedded=<var>rubypath</var>]
32
+ # [-e<var>rubypath</var>] [--executable=<var>rubypath</var>]
33
33
  # [-v] [--verbose]
34
34
  # [-O<var>filename</var>] [--log-file=<var>filename</var>]
35
35
  # [-g] [--debug]
@@ -41,7 +41,7 @@ end
41
41
  # [-S] [--output-status]
42
42
  # [--version] [--copyright] [--help] <var>grammarfile</var>
43
43
  #
44
- # [+filename+]
44
+ # [+grammarfile+]
45
45
  # Racc grammar file. Any extension is permitted.
46
46
  # [-o+outfile+, --output-file=+outfile+]
47
47
  # A filename for output. default is <+filename+>.tab.rb
@@ -179,45 +179,39 @@ end
179
179
  # Your own parser is completely yours.
180
180
  module Racc
181
181
 
182
- unless defined?(Racc_No_Extentions)
183
- Racc_No_Extentions = false # :nodoc:
182
+ unless defined?(Racc_No_Extensions)
183
+ Racc_No_Extensions = false # :nodoc:
184
184
  end
185
185
 
186
186
  class Parser
187
187
 
188
188
  Racc_Runtime_Version = ::Racc::VERSION
189
- Racc_Runtime_Revision = '$Id: e754525bd317344c4284fca6fdce0a425979ade1 $'
190
-
191
189
  Racc_Runtime_Core_Version_R = ::Racc::VERSION
192
- Racc_Runtime_Core_Revision_R = '$Id: e754525bd317344c4284fca6fdce0a425979ade1 $'.split[1]
190
+
193
191
  begin
194
192
  if Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
193
+ require 'jruby'
195
194
  require 'racc/cparse-jruby.jar'
196
195
  com.headius.racc.Cparse.new.load(JRuby.runtime, false)
197
196
  else
198
197
  require 'racc/cparse'
199
198
  end
200
- # Racc_Runtime_Core_Version_C = (defined in extention)
201
- Racc_Runtime_Core_Revision_C = Racc_Runtime_Core_Id_C.split[2]
199
+
202
200
  unless new.respond_to?(:_racc_do_parse_c, true)
203
201
  raise LoadError, 'old cparse.so'
204
202
  end
205
- if Racc_No_Extentions
203
+ if Racc_No_Extensions
206
204
  raise LoadError, 'selecting ruby version of racc runtime core'
207
205
  end
208
206
 
209
207
  Racc_Main_Parsing_Routine = :_racc_do_parse_c # :nodoc:
210
208
  Racc_YY_Parse_Method = :_racc_yyparse_c # :nodoc:
211
209
  Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_C # :nodoc:
212
- Racc_Runtime_Core_Revision = Racc_Runtime_Core_Revision_C # :nodoc:
213
210
  Racc_Runtime_Type = 'c' # :nodoc:
214
211
  rescue LoadError
215
- puts $!
216
- puts $!.backtrace
217
212
  Racc_Main_Parsing_Routine = :_racc_do_parse_rb
218
213
  Racc_YY_Parse_Method = :_racc_yyparse_rb
219
214
  Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_R
220
- Racc_Runtime_Core_Revision = Racc_Runtime_Core_Revision_R
221
215
  Racc_Runtime_Type = 'ruby'
222
216
  end
223
217
 
@@ -330,7 +324,7 @@ puts $!.backtrace
330
324
  # It must 'yield' the token, which format is [TOKEN-SYMBOL, VALUE].
331
325
  class_eval %{
332
326
  def yyparse(recv, mid)
333
- #{Racc_YY_Parse_Method}(recv, mid, _racc_setup(), true)
327
+ #{Racc_YY_Parse_Method}(recv, mid, _racc_setup(), false)
334
328
  end
335
329
  }
336
330
 
@@ -552,7 +546,7 @@ puts $!.backtrace
552
546
  end
553
547
 
554
548
  # Exit parser.
555
- # Return value is Symbol_Value_Stack[0].
549
+ # Return value is +Symbol_Value_Stack[0]+.
556
550
  def yyaccept
557
551
  throw :racc_jump, 2
558
552
  end
@@ -1,13 +1,15 @@
1
+ #--
2
+ #
1
3
  #
2
- # $Id: fff07ebfd582f8dbc845e424908cb9f41f8bf42f $
3
4
  #
4
5
  # Copyright (c) 1999-2006 Minero Aoki
5
6
  #
6
7
  # This program is free software.
7
8
  # You can distribute/modify this program under the same terms of ruby.
8
9
  # see the file "COPYING".
10
+ #
11
+ #++
9
12
 
10
- require 'enumerator'
11
13
  require 'racc/compat'
12
14
  require 'racc/sourcetext'
13
15
  require 'racc/parser-text'
@@ -235,7 +237,7 @@ module Racc
235
237
  end
236
238
 
237
239
  def unique_separator(id)
238
- sep = "...end #{id}/module_eval..."
240
+ sep = String.new "...end #{id}/module_eval..."
239
241
  while @used_separator.key?(sep)
240
242
  sep.concat sprintf('%02x', rand(255))
241
243
  end
@@ -318,50 +320,6 @@ module Racc
318
320
  end
319
321
 
320
322
  def integer_list(name, table)
321
- if table.size > 2000
322
- serialize_integer_list_compressed name, table
323
- else
324
- serialize_integer_list_std name, table
325
- end
326
- end
327
-
328
- def serialize_integer_list_compressed(name, table)
329
- # TODO: this can be made a LOT more clean with a simple split/map
330
- sep = "\n"
331
- nsep = ",\n"
332
- buf = ''
333
- com = ''
334
- ncom = ','
335
- co = com
336
- @f.print 'clist = ['
337
- table.each do |i|
338
- buf << co << i.to_s; co = ncom
339
- if buf.size > 66
340
- @f.print sep; sep = nsep
341
- @f.print "'", buf, "'"
342
- buf = ''
343
- co = com
344
- end
345
- end
346
- unless buf.empty?
347
- @f.print sep
348
- @f.print "'", buf, "'"
349
- end
350
- line ' ]'
351
-
352
- @f.print(<<-End)
353
- #{name} = arr = ::Array.new(#{table.size}, nil)
354
- idx = 0
355
- clist.each do |str|
356
- str.split(',', -1).each do |i|
357
- arr[idx] = i.to_i unless i.empty?
358
- idx += 1
359
- end
360
- end
361
- End
362
- end
363
-
364
- def serialize_integer_list_std(name, table)
365
323
  sep = ''
366
324
  line "#{name} = ["
367
325
  table.each_slice(10) do |ns|
@@ -1,13 +1,14 @@
1
+ #--
2
+ #
1
3
  #
2
- # $Id: 3b2d89d9ada2f5fcb043837dcc5c9631856d5b70 $
3
4
  #
4
5
  # Copyright (c) 1999-2006 Minero Aoki
5
6
  #
6
7
  # This program is free software.
7
- # You can distribute/modify this program under the terms of
8
- # the GNU LGPL, Lesser General Public License version 2.1.
9
- # For details of LGPL, see the file "COPYING".
8
+ # You can distribute/modify this program under the same terms of ruby.
9
+ # see the file "COPYING".
10
10
  #
11
+ #++
11
12
 
12
13
  module Racc
13
14
 
data/lib/racc/state.rb CHANGED
@@ -1,11 +1,14 @@
1
+ #--
2
+ #
1
3
  #
2
- # $Id: 6bd3136439c94cb8d928917f5e0de9c593181527 $
3
4
  #
4
5
  # Copyright (c) 1999-2006 Minero Aoki
5
6
  #
6
7
  # This program is free software.
7
8
  # You can distribute/modify this program under the same terms of ruby.
8
9
  # see the file "COPYING".
10
+ #
11
+ #++
9
12
 
10
13
  require 'racc/iset'
11
14
  require 'racc/statetransitiontable'
@@ -1,22 +1,17 @@
1
+ #--
2
+ #
1
3
  #
2
- # $Id: 4c5f4311663b6d03050953d64d6a0e7905ff2216 $
3
4
  #
4
5
  # Copyright (c) 1999-2006 Minero Aoki
5
6
  #
6
7
  # This program is free software.
7
- # You can distribute/modify this program under the terms of
8
- # the GNU LGPL, Lesser General Public License version 2.1.
9
- # For details of LGPL, see the file "COPYING".
8
+ # You can distribute/modify this program under the same terms of ruby.
9
+ # see the file "COPYING".
10
10
  #
11
+ #++
11
12
 
12
13
  require 'racc/parser'
13
14
 
14
- unless Object.method_defined?(:funcall)
15
- class Object
16
- alias funcall __send__
17
- end
18
- end
19
-
20
15
  module Racc
21
16
 
22
17
  StateTransitionTable = Struct.new(:action_table,
@@ -196,7 +191,7 @@ module Racc
196
191
  def mkmapexp(arr)
197
192
  i = ii = 0
198
193
  as = arr.size
199
- map = ''
194
+ map = String.new
200
195
  maxdup = RE_DUP_MAX
201
196
  curr = nil
202
197
  while i < as
@@ -229,7 +224,7 @@ module Racc
229
224
  map = '-' * 10240
230
225
 
231
226
  # sort long to short
232
- entries.sort! {|a,b| b[0].size <=> a[0].size }
227
+ entries.sort_by!.with_index {|a,i| [-a[0].size, i] }
233
228
 
234
229
  entries.each do |arr, chkval, expr, min, ptri|
235
230
  if upper + arr.size > map.size
@@ -299,9 +294,9 @@ module Racc
299
294
  c.module_eval "def _reduce_none(vals, vstack) vals[0] end"
300
295
  @grammar.each do |rule|
301
296
  if rule.action.empty?
302
- c.funcall(:alias_method, "_reduce_#{rule.ident}", :_reduce_none)
297
+ c.alias_method("_reduce_#{rule.ident}", :_reduce_none)
303
298
  else
304
- c.funcall(:define_method, "_racc_action_#{rule.ident}", &rule.action.proc)
299
+ c.define_method("_racc_action_#{rule.ident}", &rule.action.proc)
305
300
  c.module_eval(<<-End, __FILE__, __LINE__ + 1)
306
301
  def _reduce_#{rule.ident}(vals, vstack)
307
302
  _racc_action_#{rule.ident}(*vals)