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