rdoc 6.4.0 → 6.6.0

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.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.rdoc +1 -2
  3. data/LEGAL.rdoc +1 -1
  4. data/README.rdoc +2 -2
  5. data/TODO.rdoc +1 -1
  6. data/exe/rdoc +0 -1
  7. data/lib/rdoc/alias.rb +0 -1
  8. data/lib/rdoc/anon_class.rb +0 -1
  9. data/lib/rdoc/any_method.rb +17 -2
  10. data/lib/rdoc/attr.rb +0 -1
  11. data/lib/rdoc/class_module.rb +0 -1
  12. data/lib/rdoc/code_objects.rb +1 -2
  13. data/lib/rdoc/comment.rb +20 -41
  14. data/lib/rdoc/constant.rb +0 -1
  15. data/lib/rdoc/context/section.rb +2 -1
  16. data/lib/rdoc/context.rb +1 -3
  17. data/lib/rdoc/cross_reference.rb +17 -2
  18. data/lib/rdoc/encoding.rb +1 -6
  19. data/lib/rdoc/erb_partial.rb +0 -1
  20. data/lib/rdoc/erbio.rb +2 -7
  21. data/lib/rdoc/extend.rb +0 -1
  22. data/lib/rdoc/generator/darkfish.rb +2 -6
  23. data/lib/rdoc/generator/json_index.rb +2 -2
  24. data/lib/rdoc/generator/markup.rb +1 -2
  25. data/lib/rdoc/generator/ri.rb +0 -1
  26. data/lib/rdoc/generator/template/darkfish/_head.rhtml +10 -10
  27. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +27 -3
  28. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +22 -2
  29. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +1 -1
  30. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +25 -4
  31. data/lib/rdoc/generator/template/darkfish/class.rhtml +28 -20
  32. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +44 -7
  33. data/lib/rdoc/generator/template/darkfish/index.rhtml +1 -1
  34. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +14 -1
  35. data/lib/rdoc/generator/template/darkfish/js/search.js +4 -4
  36. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +7 -6
  37. data/lib/rdoc/generator/template/json_index/js/navigation.js +8 -8
  38. data/lib/rdoc/generator.rb +5 -5
  39. data/lib/rdoc/ghost_method.rb +0 -1
  40. data/lib/rdoc/i18n.rb +1 -1
  41. data/lib/rdoc/include.rb +0 -1
  42. data/lib/rdoc/known_classes.rb +5 -4
  43. data/lib/rdoc/markdown/entities.rb +0 -1
  44. data/lib/rdoc/markdown/literals.rb +98 -40
  45. data/lib/rdoc/markdown.kpeg +26 -19
  46. data/lib/rdoc/markdown.rb +326 -227
  47. data/lib/rdoc/markup/attr_changer.rb +0 -1
  48. data/lib/rdoc/markup/attr_span.rb +0 -1
  49. data/lib/rdoc/markup/attribute_manager.rb +29 -36
  50. data/lib/rdoc/markup/attributes.rb +0 -1
  51. data/lib/rdoc/markup/blank_line.rb +0 -1
  52. data/lib/rdoc/markup/block_quote.rb +0 -1
  53. data/lib/rdoc/markup/document.rb +0 -1
  54. data/lib/rdoc/markup/formatter.rb +0 -1
  55. data/lib/rdoc/markup/hard_break.rb +0 -1
  56. data/lib/rdoc/markup/heading.rb +0 -1
  57. data/lib/rdoc/markup/include.rb +0 -1
  58. data/lib/rdoc/markup/indented_paragraph.rb +0 -1
  59. data/lib/rdoc/markup/list.rb +0 -1
  60. data/lib/rdoc/markup/list_item.rb +0 -1
  61. data/lib/rdoc/markup/paragraph.rb +0 -1
  62. data/lib/rdoc/markup/parser.rb +12 -6
  63. data/lib/rdoc/markup/raw.rb +0 -1
  64. data/lib/rdoc/markup/regexp_handling.rb +0 -1
  65. data/lib/rdoc/markup/rule.rb +0 -1
  66. data/lib/rdoc/markup/to_ansi.rb +0 -1
  67. data/lib/rdoc/markup/to_html.rb +21 -16
  68. data/lib/rdoc/markup/to_html_crossref.rb +0 -1
  69. data/lib/rdoc/markup/to_html_snippet.rb +0 -1
  70. data/lib/rdoc/markup/to_joined_paragraph.rb +2 -3
  71. data/lib/rdoc/markup/to_label.rb +1 -2
  72. data/lib/rdoc/markup/to_markdown.rb +0 -1
  73. data/lib/rdoc/markup/to_rdoc.rb +3 -21
  74. data/lib/rdoc/markup/to_table_of_contents.rb +0 -1
  75. data/lib/rdoc/markup/to_test.rb +0 -1
  76. data/lib/rdoc/markup/to_tt_only.rb +0 -1
  77. data/lib/rdoc/markup/verbatim.rb +0 -1
  78. data/lib/rdoc/markup.rb +35 -667
  79. data/lib/rdoc/meta_method.rb +0 -1
  80. data/lib/rdoc/method_attr.rb +1 -2
  81. data/lib/rdoc/mixin.rb +0 -1
  82. data/lib/rdoc/normal_class.rb +1 -2
  83. data/lib/rdoc/normal_module.rb +1 -2
  84. data/lib/rdoc/options.rb +36 -20
  85. data/lib/rdoc/parser/c.rb +89 -101
  86. data/lib/rdoc/parser/changelog.rb +0 -1
  87. data/lib/rdoc/parser/markdown.rb +0 -2
  88. data/lib/rdoc/parser/rd.rb +0 -1
  89. data/lib/rdoc/parser/ripper_state_lex.rb +1 -1
  90. data/lib/rdoc/parser/ruby.rb +29 -14
  91. data/lib/rdoc/parser/ruby_tools.rb +0 -2
  92. data/lib/rdoc/parser/text.rb +0 -1
  93. data/lib/rdoc/parser.rb +19 -2
  94. data/lib/rdoc/rd/block_parser.rb +666 -12
  95. data/lib/rdoc/rd/block_parser.ry +13 -9
  96. data/lib/rdoc/rd/inline.rb +0 -1
  97. data/lib/rdoc/rd/inline_parser.rb +3 -1
  98. data/lib/rdoc/rd.rb +3 -4
  99. data/lib/rdoc/rdoc.rb +19 -7
  100. data/lib/rdoc/require.rb +0 -1
  101. data/lib/rdoc/ri/driver.rb +20 -86
  102. data/lib/rdoc/ri/store.rb +0 -1
  103. data/lib/rdoc/ri.rb +4 -5
  104. data/lib/rdoc/rubygems_hook.rb +1 -1
  105. data/lib/rdoc/servlet.rb +1 -1
  106. data/lib/rdoc/single_class.rb +5 -1
  107. data/lib/rdoc/stats/quiet.rb +0 -1
  108. data/lib/rdoc/stats/verbose.rb +0 -2
  109. data/lib/rdoc/stats.rb +3 -4
  110. data/lib/rdoc/store.rb +4 -4
  111. data/lib/rdoc/task.rb +31 -5
  112. data/lib/rdoc/token_stream.rb +0 -1
  113. data/lib/rdoc/top_level.rb +0 -1
  114. data/lib/rdoc/version.rb +3 -1
  115. data/lib/rdoc.rb +46 -46
  116. metadata +9 -11
  117. data/Gemfile +0 -12
  118. data/Rakefile +0 -107
  119. data/bin/console +0 -7
  120. data/bin/setup +0 -6
  121. data/rdoc.gemspec +0 -249
@@ -1,11 +1,659 @@
1
1
  # frozen_string_literal: true
2
2
  #
3
3
  # DO NOT MODIFY!!!!
4
- # This file is automatically generated by Racc 1.5.2
5
- # from Racc grammar file "".
4
+ # This file is automatically generated by Racc 1.7.3
5
+ # from Racc grammar file "block_parser.ry".
6
6
  #
7
7
 
8
- require 'racc/parser.rb'
8
+ ###### racc/parser.rb begin
9
+ unless $".find {|p| p.end_with?('/racc/parser.rb')}
10
+ $".push "#{__dir__}/racc/parser.rb"
11
+ #--
12
+ # Copyright (c) 1999-2006 Minero Aoki
13
+ #
14
+ # This program is free software.
15
+ # You can distribute/modify this program under the same terms of ruby.
16
+ #
17
+ # As a special exception, when this code is copied by Racc
18
+ # into a Racc output file, you may use that output file
19
+ # without restriction.
20
+ #++
21
+
22
+ unless $".find {|p| p.end_with?('/racc/info.rb')}
23
+ $".push "#{__dir__}/racc/info.rb"
24
+
25
+ module Racc
26
+ VERSION = '1.7.3'
27
+ Version = VERSION
28
+ Copyright = 'Copyright (c) 1999-2006 Minero Aoki'
29
+ end
30
+
31
+ end
32
+
33
+
34
+ unless defined?(NotImplementedError)
35
+ NotImplementedError = NotImplementError # :nodoc:
36
+ end
37
+
38
+ module Racc
39
+ class ParseError < StandardError; end
40
+ end
41
+ unless defined?(::ParseError)
42
+ ParseError = Racc::ParseError # :nodoc:
43
+ end
44
+
45
+ # Racc is a LALR(1) parser generator.
46
+ # It is written in Ruby itself, and generates Ruby programs.
47
+ #
48
+ # == Command-line Reference
49
+ #
50
+ # racc [-o<var>filename</var>] [--output-file=<var>filename</var>]
51
+ # [-e<var>rubypath</var>] [--executable=<var>rubypath</var>]
52
+ # [-v] [--verbose]
53
+ # [-O<var>filename</var>] [--log-file=<var>filename</var>]
54
+ # [-g] [--debug]
55
+ # [-E] [--embedded]
56
+ # [-l] [--no-line-convert]
57
+ # [-c] [--line-convert-all]
58
+ # [-a] [--no-omit-actions]
59
+ # [-C] [--check-only]
60
+ # [-S] [--output-status]
61
+ # [--version] [--copyright] [--help] <var>grammarfile</var>
62
+ #
63
+ # [+grammarfile+]
64
+ # Racc grammar file. Any extension is permitted.
65
+ # [-o+outfile+, --output-file=+outfile+]
66
+ # A filename for output. default is <+filename+>.tab.rb
67
+ # [-O+filename+, --log-file=+filename+]
68
+ # Place logging output in file +filename+.
69
+ # Default log file name is <+filename+>.output.
70
+ # [-e+rubypath+, --executable=+rubypath+]
71
+ # output executable file(mode 755). where +path+ is the Ruby interpreter.
72
+ # [-v, --verbose]
73
+ # verbose mode. create +filename+.output file, like yacc's y.output file.
74
+ # [-g, --debug]
75
+ # add debug code to parser class. To display debugging information,
76
+ # use this '-g' option and set @yydebug true in parser class.
77
+ # [-E, --embedded]
78
+ # Output parser which doesn't need runtime files (racc/parser.rb).
79
+ # [-F, --frozen]
80
+ # Output parser which declares frozen_string_literals: true
81
+ # [-C, --check-only]
82
+ # Check syntax of racc grammar file and quit.
83
+ # [-S, --output-status]
84
+ # Print messages time to time while compiling.
85
+ # [-l, --no-line-convert]
86
+ # turns off line number converting.
87
+ # [-c, --line-convert-all]
88
+ # Convert line number of actions, inner, header and footer.
89
+ # [-a, --no-omit-actions]
90
+ # Call all actions, even if an action is empty.
91
+ # [--version]
92
+ # print Racc version and quit.
93
+ # [--copyright]
94
+ # Print copyright and quit.
95
+ # [--help]
96
+ # Print usage and quit.
97
+ #
98
+ # == Generating Parser Using Racc
99
+ #
100
+ # To compile Racc grammar file, simply type:
101
+ #
102
+ # $ racc parse.y
103
+ #
104
+ # This creates Ruby script file "parse.tab.y". The -o option can change the output filename.
105
+ #
106
+ # == Writing A Racc Grammar File
107
+ #
108
+ # If you want your own parser, you have to write a grammar file.
109
+ # A grammar file contains the name of your parser class, grammar for the parser,
110
+ # user code, and anything else.
111
+ # When writing a grammar file, yacc's knowledge is helpful.
112
+ # If you have not used yacc before, Racc is not too difficult.
113
+ #
114
+ # Here's an example Racc grammar file.
115
+ #
116
+ # class Calcparser
117
+ # rule
118
+ # target: exp { print val[0] }
119
+ #
120
+ # exp: exp '+' exp
121
+ # | exp '*' exp
122
+ # | '(' exp ')'
123
+ # | NUMBER
124
+ # end
125
+ #
126
+ # Racc grammar files resemble yacc files.
127
+ # But (of course), this is Ruby code.
128
+ # yacc's $$ is the 'result', $0, $1... is
129
+ # an array called 'val', and $-1, $-2... is an array called '_values'.
130
+ #
131
+ # See the {Grammar File Reference}[rdoc-ref:lib/racc/rdoc/grammar.en.rdoc] for
132
+ # more information on grammar files.
133
+ #
134
+ # == Parser
135
+ #
136
+ # Then you must prepare the parse entry method. There are two types of
137
+ # parse methods in Racc, Racc::Parser#do_parse and Racc::Parser#yyparse
138
+ #
139
+ # Racc::Parser#do_parse is simple.
140
+ #
141
+ # It's yyparse() of yacc, and Racc::Parser#next_token is yylex().
142
+ # This method must returns an array like [TOKENSYMBOL, ITS_VALUE].
143
+ # EOF is [false, false].
144
+ # (TOKENSYMBOL is a Ruby symbol (taken from String#intern) by default.
145
+ # If you want to change this, see the grammar reference.
146
+ #
147
+ # Racc::Parser#yyparse is little complicated, but useful.
148
+ # It does not use Racc::Parser#next_token, instead it gets tokens from any iterator.
149
+ #
150
+ # For example, <code>yyparse(obj, :scan)</code> causes
151
+ # calling +obj#scan+, and you can return tokens by yielding them from +obj#scan+.
152
+ #
153
+ # == Debugging
154
+ #
155
+ # When debugging, "-v" or/and the "-g" option is helpful.
156
+ #
157
+ # "-v" creates verbose log file (.output).
158
+ # "-g" creates a "Verbose Parser".
159
+ # Verbose Parser prints the internal status when parsing.
160
+ # But it's _not_ automatic.
161
+ # You must use -g option and set +@yydebug+ to +true+ in order to get output.
162
+ # -g option only creates the verbose parser.
163
+ #
164
+ # === Racc reported syntax error.
165
+ #
166
+ # Isn't there too many "end"?
167
+ # grammar of racc file is changed in v0.10.
168
+ #
169
+ # Racc does not use '%' mark, while yacc uses huge number of '%' marks..
170
+ #
171
+ # === Racc reported "XXXX conflicts".
172
+ #
173
+ # Try "racc -v xxxx.y".
174
+ # It causes producing racc's internal log file, xxxx.output.
175
+ #
176
+ # === Generated parsers does not work correctly
177
+ #
178
+ # Try "racc -g xxxx.y".
179
+ # This command let racc generate "debugging parser".
180
+ # Then set @yydebug=true in your parser.
181
+ # It produces a working log of your parser.
182
+ #
183
+ # == Re-distributing Racc runtime
184
+ #
185
+ # A parser, which is created by Racc, requires the Racc runtime module;
186
+ # racc/parser.rb.
187
+ #
188
+ # Ruby 1.8.x comes with Racc runtime module,
189
+ # you need NOT distribute Racc runtime files.
190
+ #
191
+ # If you want to include the Racc runtime module with your parser.
192
+ # This can be done by using '-E' option:
193
+ #
194
+ # $ racc -E -omyparser.rb myparser.y
195
+ #
196
+ # This command creates myparser.rb which `includes' Racc runtime.
197
+ # Only you must do is to distribute your parser file (myparser.rb).
198
+ #
199
+ # Note: parser.rb is ruby license, but your parser is not.
200
+ # Your own parser is completely yours.
201
+ module Racc
202
+
203
+ unless defined?(Racc_No_Extensions)
204
+ Racc_No_Extensions = false # :nodoc:
205
+ end
206
+
207
+ class Parser
208
+
209
+ Racc_Runtime_Version = ::Racc::VERSION
210
+ Racc_Runtime_Core_Version_R = ::Racc::VERSION
211
+
212
+ begin
213
+ if Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
214
+ require 'jruby'
215
+ require 'racc/cparse-jruby.jar'
216
+ com.headius.racc.Cparse.new.load(JRuby.runtime, false)
217
+ else
218
+ require 'racc/cparse'
219
+ end
220
+
221
+ unless new.respond_to?(:_racc_do_parse_c, true)
222
+ raise LoadError, 'old cparse.so'
223
+ end
224
+ if Racc_No_Extensions
225
+ raise LoadError, 'selecting ruby version of racc runtime core'
226
+ end
227
+
228
+ Racc_Main_Parsing_Routine = :_racc_do_parse_c # :nodoc:
229
+ Racc_YY_Parse_Method = :_racc_yyparse_c # :nodoc:
230
+ Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_C # :nodoc:
231
+ Racc_Runtime_Type = 'c' # :nodoc:
232
+ rescue LoadError
233
+ Racc_Main_Parsing_Routine = :_racc_do_parse_rb
234
+ Racc_YY_Parse_Method = :_racc_yyparse_rb
235
+ Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_R
236
+ Racc_Runtime_Type = 'ruby'
237
+ end
238
+
239
+ def Parser.racc_runtime_type # :nodoc:
240
+ Racc_Runtime_Type
241
+ end
242
+
243
+ def _racc_setup
244
+ @yydebug = false unless self.class::Racc_debug_parser
245
+ @yydebug = false unless defined?(@yydebug)
246
+ if @yydebug
247
+ @racc_debug_out = $stderr unless defined?(@racc_debug_out)
248
+ @racc_debug_out ||= $stderr
249
+ end
250
+ arg = self.class::Racc_arg
251
+ arg[13] = true if arg.size < 14
252
+ arg
253
+ end
254
+
255
+ def _racc_init_sysvars
256
+ @racc_state = [0]
257
+ @racc_tstack = []
258
+ @racc_vstack = []
259
+
260
+ @racc_t = nil
261
+ @racc_val = nil
262
+
263
+ @racc_read_next = true
264
+
265
+ @racc_user_yyerror = false
266
+ @racc_error_status = 0
267
+ end
268
+
269
+ # The entry point of the parser. This method is used with #next_token.
270
+ # If Racc wants to get token (and its value), calls next_token.
271
+ #
272
+ # Example:
273
+ # def parse
274
+ # @q = [[1,1],
275
+ # [2,2],
276
+ # [3,3],
277
+ # [false, '$']]
278
+ # do_parse
279
+ # end
280
+ #
281
+ # def next_token
282
+ # @q.shift
283
+ # end
284
+ class_eval <<~RUBY, __FILE__, __LINE__ + 1
285
+ def do_parse
286
+ #{Racc_Main_Parsing_Routine}(_racc_setup(), false)
287
+ end
288
+ RUBY
289
+
290
+ # The method to fetch next token.
291
+ # If you use #do_parse method, you must implement #next_token.
292
+ #
293
+ # The format of return value is [TOKEN_SYMBOL, VALUE].
294
+ # +token-symbol+ is represented by Ruby's symbol by default, e.g. :IDENT
295
+ # for 'IDENT'. ";" (String) for ';'.
296
+ #
297
+ # The final symbol (End of file) must be false.
298
+ def next_token
299
+ raise NotImplementedError, "#{self.class}\#next_token is not defined"
300
+ end
301
+
302
+ def _racc_do_parse_rb(arg, in_debug)
303
+ action_table, action_check, action_default, action_pointer,
304
+ _, _, _, _,
305
+ _, _, token_table, * = arg
306
+
307
+ _racc_init_sysvars
308
+ tok = act = i = nil
309
+
310
+ catch(:racc_end_parse) {
311
+ while true
312
+ if i = action_pointer[@racc_state[-1]]
313
+ if @racc_read_next
314
+ if @racc_t != 0 # not EOF
315
+ tok, @racc_val = next_token()
316
+ unless tok # EOF
317
+ @racc_t = 0
318
+ else
319
+ @racc_t = (token_table[tok] or 1) # error token
320
+ end
321
+ racc_read_token(@racc_t, tok, @racc_val) if @yydebug
322
+ @racc_read_next = false
323
+ end
324
+ end
325
+ i += @racc_t
326
+ unless i >= 0 and
327
+ act = action_table[i] and
328
+ action_check[i] == @racc_state[-1]
329
+ act = action_default[@racc_state[-1]]
330
+ end
331
+ else
332
+ act = action_default[@racc_state[-1]]
333
+ end
334
+ while act = _racc_evalact(act, arg)
335
+ ;
336
+ end
337
+ end
338
+ }
339
+ end
340
+
341
+ # Another entry point for the parser.
342
+ # If you use this method, you must implement RECEIVER#METHOD_ID method.
343
+ #
344
+ # RECEIVER#METHOD_ID is a method to get next token.
345
+ # It must 'yield' the token, which format is [TOKEN-SYMBOL, VALUE].
346
+ class_eval <<~RUBY, __FILE__, __LINE__ + 1
347
+ def yyparse(recv, mid)
348
+ #{Racc_YY_Parse_Method}(recv, mid, _racc_setup(), false)
349
+ end
350
+ RUBY
351
+
352
+ def _racc_yyparse_rb(recv, mid, arg, c_debug)
353
+ action_table, action_check, action_default, action_pointer,
354
+ _, _, _, _,
355
+ _, _, token_table, * = arg
356
+
357
+ _racc_init_sysvars
358
+
359
+ catch(:racc_end_parse) {
360
+ until i = action_pointer[@racc_state[-1]]
361
+ while act = _racc_evalact(action_default[@racc_state[-1]], arg)
362
+ ;
363
+ end
364
+ end
365
+ recv.__send__(mid) do |tok, val|
366
+ unless tok
367
+ @racc_t = 0
368
+ else
369
+ @racc_t = (token_table[tok] or 1) # error token
370
+ end
371
+ @racc_val = val
372
+ @racc_read_next = false
373
+
374
+ i += @racc_t
375
+ unless i >= 0 and
376
+ act = action_table[i] and
377
+ action_check[i] == @racc_state[-1]
378
+ act = action_default[@racc_state[-1]]
379
+ end
380
+ while act = _racc_evalact(act, arg)
381
+ ;
382
+ end
383
+
384
+ while !(i = action_pointer[@racc_state[-1]]) ||
385
+ ! @racc_read_next ||
386
+ @racc_t == 0 # $
387
+ unless i and i += @racc_t and
388
+ i >= 0 and
389
+ act = action_table[i] and
390
+ action_check[i] == @racc_state[-1]
391
+ act = action_default[@racc_state[-1]]
392
+ end
393
+ while act = _racc_evalact(act, arg)
394
+ ;
395
+ end
396
+ end
397
+ end
398
+ }
399
+ end
400
+
401
+ ###
402
+ ### common
403
+ ###
404
+
405
+ def _racc_evalact(act, arg)
406
+ action_table, action_check, _, action_pointer,
407
+ _, _, _, _,
408
+ _, _, _, shift_n,
409
+ reduce_n, * = arg
410
+ nerr = 0 # tmp
411
+
412
+ if act > 0 and act < shift_n
413
+ #
414
+ # shift
415
+ #
416
+ if @racc_error_status > 0
417
+ @racc_error_status -= 1 unless @racc_t <= 1 # error token or EOF
418
+ end
419
+ @racc_vstack.push @racc_val
420
+ @racc_state.push act
421
+ @racc_read_next = true
422
+ if @yydebug
423
+ @racc_tstack.push @racc_t
424
+ racc_shift @racc_t, @racc_tstack, @racc_vstack
425
+ end
426
+
427
+ elsif act < 0 and act > -reduce_n
428
+ #
429
+ # reduce
430
+ #
431
+ code = catch(:racc_jump) {
432
+ @racc_state.push _racc_do_reduce(arg, act)
433
+ false
434
+ }
435
+ if code
436
+ case code
437
+ when 1 # yyerror
438
+ @racc_user_yyerror = true # user_yyerror
439
+ return -reduce_n
440
+ when 2 # yyaccept
441
+ return shift_n
442
+ else
443
+ raise '[Racc Bug] unknown jump code'
444
+ end
445
+ end
446
+
447
+ elsif act == shift_n
448
+ #
449
+ # accept
450
+ #
451
+ racc_accept if @yydebug
452
+ throw :racc_end_parse, @racc_vstack[0]
453
+
454
+ elsif act == -reduce_n
455
+ #
456
+ # error
457
+ #
458
+ case @racc_error_status
459
+ when 0
460
+ unless arg[21] # user_yyerror
461
+ nerr += 1
462
+ on_error @racc_t, @racc_val, @racc_vstack
463
+ end
464
+ when 3
465
+ if @racc_t == 0 # is $
466
+ # We're at EOF, and another error occurred immediately after
467
+ # attempting auto-recovery
468
+ throw :racc_end_parse, nil
469
+ end
470
+ @racc_read_next = true
471
+ end
472
+ @racc_user_yyerror = false
473
+ @racc_error_status = 3
474
+ while true
475
+ if i = action_pointer[@racc_state[-1]]
476
+ i += 1 # error token
477
+ if i >= 0 and
478
+ (act = action_table[i]) and
479
+ action_check[i] == @racc_state[-1]
480
+ break
481
+ end
482
+ end
483
+ throw :racc_end_parse, nil if @racc_state.size <= 1
484
+ @racc_state.pop
485
+ @racc_vstack.pop
486
+ if @yydebug
487
+ @racc_tstack.pop
488
+ racc_e_pop @racc_state, @racc_tstack, @racc_vstack
489
+ end
490
+ end
491
+ return act
492
+
493
+ else
494
+ raise "[Racc Bug] unknown action #{act.inspect}"
495
+ end
496
+
497
+ racc_next_state(@racc_state[-1], @racc_state) if @yydebug
498
+
499
+ nil
500
+ end
501
+
502
+ def _racc_do_reduce(arg, act)
503
+ _, _, _, _,
504
+ goto_table, goto_check, goto_default, goto_pointer,
505
+ nt_base, reduce_table, _, _,
506
+ _, use_result, * = arg
507
+
508
+ state = @racc_state
509
+ vstack = @racc_vstack
510
+ tstack = @racc_tstack
511
+
512
+ i = act * -3
513
+ len = reduce_table[i]
514
+ reduce_to = reduce_table[i+1]
515
+ method_id = reduce_table[i+2]
516
+ void_array = []
517
+
518
+ tmp_t = tstack[-len, len] if @yydebug
519
+ tmp_v = vstack[-len, len]
520
+ tstack[-len, len] = void_array if @yydebug
521
+ vstack[-len, len] = void_array
522
+ state[-len, len] = void_array
523
+
524
+ # tstack must be updated AFTER method call
525
+ if use_result
526
+ vstack.push __send__(method_id, tmp_v, vstack, tmp_v[0])
527
+ else
528
+ vstack.push __send__(method_id, tmp_v, vstack)
529
+ end
530
+ tstack.push reduce_to
531
+
532
+ racc_reduce(tmp_t, reduce_to, tstack, vstack) if @yydebug
533
+
534
+ k1 = reduce_to - nt_base
535
+ if i = goto_pointer[k1]
536
+ i += state[-1]
537
+ if i >= 0 and (curstate = goto_table[i]) and goto_check[i] == k1
538
+ return curstate
539
+ end
540
+ end
541
+ goto_default[k1]
542
+ end
543
+
544
+ # This method is called when a parse error is found.
545
+ #
546
+ # ERROR_TOKEN_ID is an internal ID of token which caused error.
547
+ # You can get string representation of this ID by calling
548
+ # #token_to_str.
549
+ #
550
+ # ERROR_VALUE is a value of error token.
551
+ #
552
+ # value_stack is a stack of symbol values.
553
+ # DO NOT MODIFY this object.
554
+ #
555
+ # This method raises ParseError by default.
556
+ #
557
+ # If this method returns, parsers enter "error recovering mode".
558
+ def on_error(t, val, vstack)
559
+ raise ParseError, sprintf("parse error on value %s (%s)",
560
+ val.inspect, token_to_str(t) || '?')
561
+ end
562
+
563
+ # Enter error recovering mode.
564
+ # This method does not call #on_error.
565
+ def yyerror
566
+ throw :racc_jump, 1
567
+ end
568
+
569
+ # Exit parser.
570
+ # Return value is +Symbol_Value_Stack[0]+.
571
+ def yyaccept
572
+ throw :racc_jump, 2
573
+ end
574
+
575
+ # Leave error recovering mode.
576
+ def yyerrok
577
+ @racc_error_status = 0
578
+ end
579
+
580
+ # For debugging output
581
+ def racc_read_token(t, tok, val)
582
+ @racc_debug_out.print 'read '
583
+ @racc_debug_out.print tok.inspect, '(', racc_token2str(t), ') '
584
+ @racc_debug_out.puts val.inspect
585
+ @racc_debug_out.puts
586
+ end
587
+
588
+ def racc_shift(tok, tstack, vstack)
589
+ @racc_debug_out.puts "shift #{racc_token2str tok}"
590
+ racc_print_stacks tstack, vstack
591
+ @racc_debug_out.puts
592
+ end
593
+
594
+ def racc_reduce(toks, sim, tstack, vstack)
595
+ out = @racc_debug_out
596
+ out.print 'reduce '
597
+ if toks.empty?
598
+ out.print ' <none>'
599
+ else
600
+ toks.each {|t| out.print ' ', racc_token2str(t) }
601
+ end
602
+ out.puts " --> #{racc_token2str(sim)}"
603
+ racc_print_stacks tstack, vstack
604
+ @racc_debug_out.puts
605
+ end
606
+
607
+ def racc_accept
608
+ @racc_debug_out.puts 'accept'
609
+ @racc_debug_out.puts
610
+ end
611
+
612
+ def racc_e_pop(state, tstack, vstack)
613
+ @racc_debug_out.puts 'error recovering mode: pop token'
614
+ racc_print_states state
615
+ racc_print_stacks tstack, vstack
616
+ @racc_debug_out.puts
617
+ end
618
+
619
+ def racc_next_state(curstate, state)
620
+ @racc_debug_out.puts "goto #{curstate}"
621
+ racc_print_states state
622
+ @racc_debug_out.puts
623
+ end
624
+
625
+ def racc_print_stacks(t, v)
626
+ out = @racc_debug_out
627
+ out.print ' ['
628
+ t.each_index do |i|
629
+ out.print ' (', racc_token2str(t[i]), ' ', v[i].inspect, ')'
630
+ end
631
+ out.puts ' ]'
632
+ end
633
+
634
+ def racc_print_states(s)
635
+ out = @racc_debug_out
636
+ out.print ' ['
637
+ s.each {|st| out.print ' ', st }
638
+ out.puts ' ]'
639
+ end
640
+
641
+ def racc_token2str(tok)
642
+ self.class::Racc_token_to_s_table[tok] or
643
+ raise "[Racc Bug] can't convert token #{tok} to string"
644
+ end
645
+
646
+ # Convert internal ID of token symbol to the string.
647
+ def token_to_str(t)
648
+ self.class::Racc_token_to_s_table[t]
649
+ end
650
+
651
+ end
652
+
653
+ end
654
+
655
+ end
656
+ ###### racc/parser.rb end
9
657
 
10
658
  class RDoc::RD
11
659
 
@@ -18,8 +666,6 @@ class BlockParser < Racc::Parser
18
666
 
19
667
  # :stopdoc:
20
668
 
21
- TMPFILE = ["rdtmp", $$, 0]
22
-
23
669
  MARK_TO_LEVEL = {
24
670
  '=' => 1,
25
671
  '==' => 2,
@@ -129,15 +775,19 @@ def next_token # :nodoc:
129
775
  # non-RD part begin
130
776
  when /^=begin\s+(\w+)/
131
777
  part = $1
778
+ =begin # not imported to RDoc
132
779
  if @in_part # if in non-RD part
133
780
  @part_content.push(line)
134
781
  else
135
782
  @in_part = part if @tree.filter[part] # if filter exists
136
783
  # p "BEGIN_PART: #{@in_part}" # DEBUG
137
784
  end
785
+ =end
786
+ @in_part = part
138
787
  # non-RD part end
139
- when /^=end/
788
+ when /^=end(?:$|[\s\0\C-d\C-z])/
140
789
  if @in_part # if in non-RD part
790
+ =begin # not imported to RDoc
141
791
  # p "END_PART: #{@in_part}" # DEBUG
142
792
  # make Part-in object
143
793
  part = RDoc::RD::Part.new(@part_content.join(""), @tree, "r")
@@ -148,20 +798,22 @@ def next_token # :nodoc:
148
798
  if @tree.filter[@in_part].mode == :rd # if output is RD formatted
149
799
  subtree = parse_subtree(part_out.to_a)
150
800
  else # if output is target formatted
151
- basename = TMPFILE.join('.')
152
- TMPFILE[-1] += 1
153
- tmpfile = open(@tree.tmp_dir + "/" + basename + ".#{@in_part}", "w")
154
- tmpfile.print(part_out)
155
- tmpfile.close
801
+ basename = Tempfile.create(["rdtmp", ".#{@in_part}"], @tree.tmp_dir) do |tmpfile|
802
+ tmpfile.print(part_out)
803
+ File.basename(tmpfile.path)
804
+ end
156
805
  subtree = parse_subtree(["=begin\n", "<<< #{basename}\n", "=end\n"])
157
806
  end
158
807
  @in_part = nil
159
808
  return [:SUBTREE, subtree]
809
+ =end
160
810
  end
161
811
  else
812
+ =begin # not imported to RDoc
162
813
  if @in_part # if in non-RD part
163
814
  @part_content.push(line)
164
815
  end
816
+ =end
165
817
  end
166
818
  end
167
819
 
@@ -356,7 +1008,7 @@ def get_included(file)
356
1008
  file_name = File.join dir, file
357
1009
 
358
1010
  if File.exist? file_name then
359
- included = IO.readlines file_name
1011
+ included = File.readlines file_name
360
1012
  break
361
1013
  end
362
1014
  end
@@ -620,6 +1272,7 @@ Racc_arg = [
620
1272
  racc_shift_n,
621
1273
  racc_reduce_n,
622
1274
  racc_use_result_var ]
1275
+ Ractor.make_shareable(Racc_arg) if defined?(Ractor)
623
1276
 
624
1277
  Racc_token_to_s_table = [
625
1278
  "$end",
@@ -670,6 +1323,7 @@ Racc_token_to_s_table = [
670
1323
  "blocks_in_list",
671
1324
  "block_in_list",
672
1325
  "whitelines2" ]
1326
+ Ractor.make_shareable(Racc_token_to_s_table) if defined?(Ractor)
673
1327
 
674
1328
  Racc_debug_parser = false
675
1329