rdoc 5.1.0 → 6.3.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rdoc might be problematic. Click here for more details.

Files changed (158) hide show
  1. checksums.yaml +5 -5
  2. data/CONTRIBUTING.rdoc +4 -4
  3. data/Gemfile +9 -0
  4. data/History.rdoc +4 -4
  5. data/README.rdoc +5 -6
  6. data/Rakefile +35 -67
  7. data/lib/rdoc/alias.rb +1 -1
  8. data/lib/rdoc/anon_class.rb +1 -1
  9. data/lib/rdoc/any_method.rb +59 -15
  10. data/lib/rdoc/attr.rb +1 -1
  11. data/lib/rdoc/class_module.rb +5 -3
  12. data/lib/rdoc/code_object.rb +2 -9
  13. data/lib/rdoc/code_objects.rb +1 -1
  14. data/lib/rdoc/comment.rb +32 -11
  15. data/lib/rdoc/constant.rb +3 -3
  16. data/lib/rdoc/context/section.rb +1 -14
  17. data/lib/rdoc/context.rb +63 -20
  18. data/lib/rdoc/cross_reference.rb +33 -15
  19. data/lib/rdoc/encoding.rb +58 -30
  20. data/lib/rdoc/erb_partial.rb +2 -2
  21. data/lib/rdoc/erbio.rb +8 -4
  22. data/lib/rdoc/extend.rb +1 -1
  23. data/lib/rdoc/generator/darkfish.rb +60 -29
  24. data/lib/rdoc/generator/json_index.rb +6 -3
  25. data/lib/rdoc/generator/markup.rb +3 -13
  26. data/lib/rdoc/generator/pot/message_extractor.rb +1 -1
  27. data/lib/rdoc/generator/pot/po.rb +3 -3
  28. data/lib/rdoc/generator/pot/po_entry.rb +11 -11
  29. data/lib/rdoc/generator/pot.rb +4 -4
  30. data/lib/rdoc/generator/ri.rb +1 -1
  31. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +2 -2
  32. data/lib/rdoc/generator/template/darkfish/_head.rhtml +9 -7
  33. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +2 -2
  34. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +2 -2
  35. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +7 -7
  36. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +2 -2
  37. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +7 -7
  38. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +6 -6
  39. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +5 -5
  40. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +5 -5
  41. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +5 -5
  42. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +4 -4
  43. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +4 -4
  44. data/lib/rdoc/generator/template/darkfish/class.rhtml +45 -47
  45. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +55 -6
  46. data/lib/rdoc/generator/template/darkfish/index.rhtml +3 -4
  47. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +22 -99
  48. data/lib/rdoc/generator/template/darkfish/js/search.js +32 -31
  49. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +15 -16
  50. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +16 -16
  51. data/lib/rdoc/generator/template/json_index/js/navigation.js +4 -41
  52. data/lib/rdoc/generator/template/json_index/js/searcher.js +6 -6
  53. data/lib/rdoc/generator.rb +1 -1
  54. data/lib/rdoc/ghost_method.rb +1 -1
  55. data/lib/rdoc/i18n/locale.rb +1 -1
  56. data/lib/rdoc/i18n/text.rb +5 -5
  57. data/lib/rdoc/i18n.rb +3 -3
  58. data/lib/rdoc/include.rb +1 -1
  59. data/lib/rdoc/known_classes.rb +1 -1
  60. data/lib/rdoc/markdown/entities.rb +1 -1
  61. data/lib/rdoc/markdown/literals.kpeg +1 -0
  62. data/lib/rdoc/markdown/literals.rb +19 -7
  63. data/lib/rdoc/markdown.kpeg +92 -44
  64. data/lib/rdoc/markdown.rb +1171 -610
  65. data/lib/rdoc/markup/attr_changer.rb +1 -1
  66. data/lib/rdoc/markup/attr_span.rb +9 -3
  67. data/lib/rdoc/markup/attribute_manager.rb +115 -50
  68. data/lib/rdoc/markup/attributes.rb +7 -7
  69. data/lib/rdoc/markup/blank_line.rb +1 -1
  70. data/lib/rdoc/markup/block_quote.rb +1 -1
  71. data/lib/rdoc/markup/document.rb +1 -1
  72. data/lib/rdoc/markup/formatter.rb +25 -24
  73. data/lib/rdoc/markup/hard_break.rb +1 -1
  74. data/lib/rdoc/markup/heading.rb +4 -4
  75. data/lib/rdoc/markup/include.rb +1 -1
  76. data/lib/rdoc/markup/indented_paragraph.rb +1 -1
  77. data/lib/rdoc/markup/list.rb +1 -1
  78. data/lib/rdoc/markup/list_item.rb +1 -1
  79. data/lib/rdoc/markup/paragraph.rb +1 -1
  80. data/lib/rdoc/markup/parser.rb +79 -47
  81. data/lib/rdoc/markup/pre_process.rb +11 -6
  82. data/lib/rdoc/markup/raw.rb +1 -1
  83. data/lib/rdoc/markup/regexp_handling.rb +41 -0
  84. data/lib/rdoc/markup/rule.rb +1 -1
  85. data/lib/rdoc/markup/to_ansi.rb +1 -1
  86. data/lib/rdoc/markup/to_bs.rb +4 -4
  87. data/lib/rdoc/markup/to_html.rb +68 -26
  88. data/lib/rdoc/markup/to_html_crossref.rb +41 -26
  89. data/lib/rdoc/markup/to_html_snippet.rb +10 -10
  90. data/lib/rdoc/markup/to_joined_paragraph.rb +7 -32
  91. data/lib/rdoc/markup/to_label.rb +10 -10
  92. data/lib/rdoc/markup/to_markdown.rb +9 -9
  93. data/lib/rdoc/markup/to_rdoc.rb +35 -7
  94. data/lib/rdoc/markup/to_table_of_contents.rb +2 -1
  95. data/lib/rdoc/markup/to_test.rb +1 -1
  96. data/lib/rdoc/markup/to_tt_only.rb +3 -3
  97. data/lib/rdoc/markup/verbatim.rb +1 -1
  98. data/lib/rdoc/markup.rb +14 -17
  99. data/lib/rdoc/meta_method.rb +1 -1
  100. data/lib/rdoc/method_attr.rb +2 -2
  101. data/lib/rdoc/mixin.rb +1 -1
  102. data/lib/rdoc/normal_class.rb +3 -3
  103. data/lib/rdoc/normal_module.rb +1 -1
  104. data/lib/rdoc/options.rb +79 -21
  105. data/lib/rdoc/parser/c.rb +147 -194
  106. data/lib/rdoc/parser/changelog.rb +150 -19
  107. data/lib/rdoc/parser/markdown.rb +1 -1
  108. data/lib/rdoc/parser/rd.rb +1 -1
  109. data/lib/rdoc/parser/ripper_state_lex.rb +590 -0
  110. data/lib/rdoc/parser/ruby.rb +632 -466
  111. data/lib/rdoc/parser/ruby_tools.rb +33 -34
  112. data/lib/rdoc/parser/simple.rb +3 -3
  113. data/lib/rdoc/parser/text.rb +1 -1
  114. data/lib/rdoc/parser.rb +9 -34
  115. data/lib/rdoc/rd/block_parser.rb +47 -46
  116. data/lib/rdoc/rd/block_parser.ry +2 -2
  117. data/lib/rdoc/rd/inline.rb +5 -5
  118. data/lib/rdoc/rd/inline_parser.rb +139 -138
  119. data/lib/rdoc/rd/inline_parser.ry +1 -1
  120. data/lib/rdoc/rd.rb +1 -1
  121. data/lib/rdoc/rdoc.rb +54 -41
  122. data/lib/rdoc/require.rb +1 -1
  123. data/lib/rdoc/ri/driver.rb +132 -42
  124. data/lib/rdoc/ri/formatter.rb +1 -1
  125. data/lib/rdoc/ri/paths.rb +4 -18
  126. data/lib/rdoc/ri/store.rb +1 -1
  127. data/lib/rdoc/ri/task.rb +2 -2
  128. data/lib/rdoc/ri.rb +1 -1
  129. data/lib/rdoc/rubygems_hook.rb +3 -3
  130. data/lib/rdoc/servlet.rb +21 -12
  131. data/lib/rdoc/single_class.rb +1 -1
  132. data/lib/rdoc/stats/normal.rb +24 -18
  133. data/lib/rdoc/stats/quiet.rb +1 -1
  134. data/lib/rdoc/stats/verbose.rb +1 -1
  135. data/lib/rdoc/stats.rb +1 -1
  136. data/lib/rdoc/store.rb +38 -27
  137. data/lib/rdoc/task.rb +2 -2
  138. data/lib/rdoc/text.rb +16 -21
  139. data/lib/rdoc/token_stream.rb +56 -33
  140. data/lib/rdoc/tom_doc.rb +17 -12
  141. data/lib/rdoc/top_level.rb +9 -3
  142. data/lib/rdoc/version.rb +8 -0
  143. data/lib/rdoc.rb +24 -10
  144. data/man/ri.1 +247 -0
  145. data/rdoc.gemspec +206 -15
  146. metadata +15 -64
  147. data/.document +0 -5
  148. data/.gitignore +0 -13
  149. data/.travis.yml +0 -24
  150. data/lib/gauntlet_rdoc.rb +0 -82
  151. data/lib/rdoc/generator/template/darkfish/js/jquery.js +0 -4
  152. data/lib/rdoc/markup/formatter_test_case.rb +0 -764
  153. data/lib/rdoc/markup/inline.rb +0 -2
  154. data/lib/rdoc/markup/special.rb +0 -41
  155. data/lib/rdoc/markup/text_formatter_test_case.rb +0 -115
  156. data/lib/rdoc/ruby_lex.rb +0 -1367
  157. data/lib/rdoc/ruby_token.rb +0 -461
  158. data/lib/rdoc/test_case.rb +0 -204
data/lib/rdoc/ruby_lex.rb DELETED
@@ -1,1367 +0,0 @@
1
- # coding: US-ASCII
2
- # frozen_string_literal: false
3
-
4
- #--
5
- # irb/ruby-lex.rb - ruby lexcal analyzer
6
- # $Release Version: 0.9.5$
7
- # $Revision: 17979 $
8
- # $Date: 2008-07-09 10:17:05 -0700 (Wed, 09 Jul 2008) $
9
- # by Keiju ISHITSUKA(keiju@ruby-lang.org)
10
- #
11
- #++
12
-
13
- require "e2mmap"
14
- require "irb/slex"
15
- require "stringio"
16
-
17
- ##
18
- # Ruby lexer adapted from irb.
19
- #
20
- # The internals are not documented because they are scary.
21
-
22
- class RDoc::RubyLex
23
-
24
- ##
25
- # Raised upon invalid input
26
-
27
- class Error < RDoc::Error
28
- end
29
-
30
- # :stopdoc:
31
-
32
- extend Exception2MessageMapper
33
-
34
- def_exception(:AlreadyDefinedToken, "Already defined token(%s)")
35
- def_exception(:TkReading2TokenNoKey, "key nothing(key='%s')")
36
- def_exception(:TkSymbol2TokenNoKey, "key nothing(key='%s')")
37
- def_exception(:TkReading2TokenDuplicateError,
38
- "key duplicate(token_n='%s', key='%s')")
39
- def_exception(:SyntaxError, "%s")
40
-
41
- def_exception(:TerminateLineInput, "Terminate Line Input")
42
-
43
- include RDoc::RubyToken
44
- include IRB
45
-
46
- attr_accessor :continue
47
- attr_accessor :lex_state
48
- attr_reader :reader
49
-
50
- class << self
51
- attr_accessor :debug_level
52
- end
53
-
54
- def self.debug?
55
- @debug_level > 0
56
- end
57
-
58
- self.debug_level = 0
59
-
60
- # :startdoc:
61
-
62
- ##
63
- # Returns an Array of +ruby+ tokens. See ::new for a description of
64
- # +options+.
65
-
66
- def self.tokenize ruby, options
67
- tokens = []
68
-
69
- scanner = RDoc::RubyLex.new ruby, options
70
- scanner.exception_on_syntax_error = true
71
-
72
- while token = scanner.token do
73
- tokens << token
74
- end
75
-
76
- tokens
77
- end
78
-
79
- ##
80
- # Creates a new lexer for +content+. +options+ is an RDoc::Options, only
81
- # +tab_width is used.
82
-
83
- def initialize(content, options)
84
- lex_init
85
-
86
- if /\t/ =~ content then
87
- tab_width = options.tab_width
88
- content = content.split(/\n/).map do |line|
89
- 1 while line.gsub!(/\t+/) {
90
- ' ' * (tab_width*$&.length - $`.length % tab_width)
91
- } && $~
92
- line
93
- end.join("\n")
94
- end
95
-
96
- content << "\n" unless content[-1, 1] == "\n"
97
-
98
- set_input StringIO.new content
99
-
100
- @base_char_no = 0
101
- @char_no = 0
102
- @exp_line_no = @line_no = 1
103
- @here_readed = []
104
- @readed = []
105
- @current_readed = @readed
106
- @rests = []
107
- @seek = 0
108
-
109
- @indent = 0
110
- @indent_stack = []
111
- @lex_state = :EXPR_BEG
112
- @space_seen = false
113
-
114
- @continue = false
115
- @line = ""
116
-
117
- @skip_space = false
118
- @readed_auto_clean_up = false
119
- @exception_on_syntax_error = true
120
-
121
- @prompt = nil
122
- @prev_seek = nil
123
- @ltype = nil
124
- end
125
-
126
- # :stopdoc:
127
-
128
- def inspect # :nodoc:
129
- "#<%s:0x%x pos %d lex_state %p space_seen %p>" % [
130
- self.class, object_id,
131
- @io.pos, @lex_state, @space_seen,
132
- ]
133
- end
134
-
135
- attr_accessor :skip_space
136
- attr_accessor :readed_auto_clean_up
137
- attr_accessor :exception_on_syntax_error
138
-
139
- attr_reader :seek
140
- attr_reader :char_no
141
- attr_reader :line_no
142
- attr_reader :indent
143
-
144
- # io functions
145
- def set_input(io, p = nil, &block)
146
- @io = io
147
- if p.respond_to?(:call)
148
- @input = p
149
- elsif block_given?
150
- @input = block
151
- else
152
- @input = Proc.new{@io.gets}
153
- end
154
- end
155
-
156
- def get_readed
157
- if idx = @readed.rindex("\n")
158
- @base_char_no = @readed.size - (idx + 1)
159
- else
160
- @base_char_no += @readed.size
161
- end
162
-
163
- readed = @readed.join("")
164
- @readed.clear
165
- readed
166
- end
167
-
168
- def getc
169
- while @rests.empty?
170
- # return nil unless buf_input
171
- @rests.push nil unless buf_input
172
- end
173
- c = @rests.shift
174
- @current_readed.push c
175
- @seek += 1
176
- if c == "\n".freeze
177
- @line_no += 1
178
- @char_no = 0
179
- else
180
- @char_no += 1
181
- end
182
-
183
- c
184
- end
185
-
186
- def gets
187
- l = ""
188
- while c = getc
189
- l.concat(c)
190
- break if c == "\n"
191
- end
192
- return nil if l == "" and c.nil?
193
- l
194
- end
195
-
196
- def eof?
197
- @io.eof?
198
- end
199
-
200
- def getc_of_rests
201
- if @rests.empty?
202
- nil
203
- else
204
- getc
205
- end
206
- end
207
-
208
- def ungetc(c = nil)
209
- if @here_readed.empty?
210
- c2 = @readed.pop
211
- else
212
- c2 = @here_readed.pop
213
- end
214
- c = c2 unless c
215
- @rests.unshift c #c =
216
- @seek -= 1
217
- if c == "\n"
218
- @line_no -= 1
219
- if idx = @readed.rindex("\n")
220
- @char_no = idx + 1
221
- else
222
- @char_no = @base_char_no + @readed.size
223
- end
224
- else
225
- @char_no -= 1
226
- end
227
- end
228
-
229
- def peek_equal?(str)
230
- chrs = str.split(//)
231
- until @rests.size >= chrs.size
232
- return false unless buf_input
233
- end
234
- @rests[0, chrs.size] == chrs
235
- end
236
-
237
- def peek_match?(regexp)
238
- while @rests.empty?
239
- return false unless buf_input
240
- end
241
- regexp =~ @rests.join("")
242
- end
243
-
244
- def peek(i = 0)
245
- while @rests.size <= i
246
- return nil unless buf_input
247
- end
248
- @rests[i]
249
- end
250
-
251
- def buf_input
252
- prompt
253
- line = @input.call
254
- return nil unless line
255
- @rests.concat line.split(//)
256
- true
257
- end
258
- private :buf_input
259
-
260
- def set_prompt(p = nil, &block)
261
- p = block if block_given?
262
- if p.respond_to?(:call)
263
- @prompt = p
264
- else
265
- @prompt = Proc.new{print p}
266
- end
267
- end
268
-
269
- def prompt
270
- if @prompt
271
- @prompt.call(@ltype, @indent, @continue, @line_no)
272
- end
273
- end
274
-
275
- def initialize_input
276
- @ltype = nil
277
- @quoted = nil
278
- @indent = 0
279
- @indent_stack = []
280
- @lex_state = :EXPR_BEG
281
- @space_seen = false
282
- @current_readed = @readed
283
-
284
- @continue = false
285
- prompt
286
-
287
- @line = ""
288
- @exp_line_no = @line_no
289
- end
290
-
291
- def each_top_level_statement
292
- initialize_input
293
- catch(:TERM_INPUT) do
294
- loop do
295
- begin
296
- @continue = false
297
- prompt
298
- unless l = lex
299
- throw :TERM_INPUT if @line == ''
300
- else
301
- #p l
302
- @line.concat l
303
- if @ltype or @continue or @indent > 0
304
- next
305
- end
306
- end
307
- if @line != "\n"
308
- yield @line, @exp_line_no
309
- end
310
- break unless l
311
- @line = ''
312
- @exp_line_no = @line_no
313
-
314
- @indent = 0
315
- @indent_stack = []
316
- prompt
317
- rescue TerminateLineInput
318
- initialize_input
319
- prompt
320
- get_readed
321
- end
322
- end
323
- end
324
- end
325
-
326
- def lex
327
- until (((tk = token).kind_of?(TkNL) || tk.kind_of?(TkEND_OF_SCRIPT)) &&
328
- !@continue or
329
- tk.nil?)
330
- #p tk
331
- #p @lex_state
332
- #p self
333
- end
334
- line = get_readed
335
- # print self.inspect
336
- if line == "" and tk.kind_of?(TkEND_OF_SCRIPT) || tk.nil?
337
- nil
338
- else
339
- line
340
- end
341
- end
342
-
343
- def token
344
- # require "tracer"
345
- # Tracer.on
346
- @prev_seek = @seek
347
- @prev_line_no = @line_no
348
- @prev_char_no = @char_no
349
- begin
350
- begin
351
- tk = @OP.match(self)
352
- @space_seen = tk.kind_of?(TkSPACE)
353
- rescue SyntaxError => e
354
- raise Error, "syntax error: #{e.message}" if
355
- @exception_on_syntax_error
356
-
357
- tk = TkError.new(@seek, @line_no, @char_no)
358
- end
359
- end while @skip_space and tk.kind_of?(TkSPACE)
360
-
361
- if @readed_auto_clean_up
362
- get_readed
363
- end
364
- # Tracer.off
365
- tk
366
- end
367
-
368
- ENINDENT_CLAUSE = [
369
- "case", "class", "def", "do", "for", "if",
370
- "module", "unless", "until", "while", "begin" #, "when"
371
- ]
372
-
373
- DEINDENT_CLAUSE = ["end" #, "when"
374
- ]
375
-
376
- PERCENT_LTYPE = {
377
- "q" => "\'",
378
- "Q" => "\"",
379
- "x" => "\`",
380
- "r" => "/",
381
- "w" => "]",
382
- "W" => "]",
383
- "s" => ":"
384
- }
385
-
386
- PERCENT_PAREN = {
387
- "{" => "}",
388
- "[" => "]",
389
- "<" => ">",
390
- "(" => ")"
391
- }
392
-
393
- PERCENT_PAREN_REV = PERCENT_PAREN.invert
394
-
395
- Ltype2Token = {
396
- "\'" => TkSTRING,
397
- "\"" => TkSTRING,
398
- "\`" => TkXSTRING,
399
- "/" => TkREGEXP,
400
- "]" => TkDSTRING,
401
- ":" => TkSYMBOL
402
- }
403
- DLtype2Token = {
404
- "\"" => TkDSTRING,
405
- "\`" => TkDXSTRING,
406
- "/" => TkDREGEXP,
407
- }
408
-
409
- def lex_init()
410
- @OP = IRB::SLex.new
411
- @OP.def_rules("\0", "\004", "\032") do |op, io|
412
- Token(TkEND_OF_SCRIPT, '')
413
- end
414
-
415
- @OP.def_rules(" ", "\t", "\f", "\r", "\13") do |op, io|
416
- @space_seen = true
417
- str = op
418
- while (ch = getc) =~ /[ \t\f\r\13]/ do
419
- str << ch
420
- end
421
- ungetc
422
- Token TkSPACE, str
423
- end
424
-
425
- @OP.def_rule("#") do |op, io|
426
- identify_comment
427
- end
428
-
429
- @OP.def_rule("=begin",
430
- proc{|op, io| @prev_char_no == 0 && peek(0) =~ /\s/}) do
431
- |op, io|
432
- @ltype = "="
433
- res = ''
434
- nil until getc == "\n"
435
-
436
- until ( peek_equal?("=end") && peek(4) =~ /\s/ ) do
437
- (ch = getc)
438
- res << ch
439
- end
440
-
441
- gets # consume =end
442
-
443
- @ltype = nil
444
- Token(TkRD_COMMENT, res)
445
- end
446
-
447
- @OP.def_rule("\n") do |op, io|
448
- print "\\n\n" if RDoc::RubyLex.debug?
449
- case @lex_state
450
- when :EXPR_BEG, :EXPR_FNAME, :EXPR_DOT
451
- @continue = true
452
- else
453
- @continue = false
454
- @lex_state = :EXPR_BEG
455
- until (@indent_stack.empty? ||
456
- [TkLPAREN, TkLBRACK, TkLBRACE,
457
- TkfLPAREN, TkfLBRACK, TkfLBRACE].include?(@indent_stack.last))
458
- @indent_stack.pop
459
- end
460
- end
461
- @current_readed = @readed
462
- @here_readed.clear
463
- Token(TkNL)
464
- end
465
-
466
- @OP.def_rules("*", "**",
467
- "=", "==", "===",
468
- "=~", "<=>",
469
- "<", "<=",
470
- ">", ">=", ">>") do
471
- |op, io|
472
- case @lex_state
473
- when :EXPR_FNAME, :EXPR_DOT
474
- @lex_state = :EXPR_ARG
475
- else
476
- @lex_state = :EXPR_BEG
477
- end
478
- Token(op)
479
- end
480
-
481
- @OP.def_rules("!", "!=", "!~") do
482
- |op, io|
483
- @lex_state = :EXPR_BEG
484
- Token(op)
485
- end
486
-
487
- @OP.def_rules("<<") do
488
- |op, io|
489
- tk = nil
490
- if @lex_state != :EXPR_END && @lex_state != :EXPR_CLASS &&
491
- (@lex_state != :EXPR_ARG || @space_seen)
492
- c = peek(0)
493
- if /\S/ =~ c && (/["'`]/ =~ c || /\w/ =~ c || c == "-")
494
- tk = identify_here_document
495
- end
496
- end
497
- unless tk
498
- tk = Token(op)
499
- case @lex_state
500
- when :EXPR_FNAME, :EXPR_DOT
501
- @lex_state = :EXPR_ARG
502
- else
503
- @lex_state = :EXPR_BEG
504
- end
505
- end
506
- tk
507
- end
508
-
509
- @OP.def_rules("'", '"') do
510
- |op, io|
511
- identify_string(op)
512
- end
513
-
514
- @OP.def_rules("`") do
515
- |op, io|
516
- if @lex_state == :EXPR_FNAME
517
- @lex_state = :EXPR_END
518
- Token(op)
519
- else
520
- identify_string(op)
521
- end
522
- end
523
-
524
- @OP.def_rules('?') do
525
- |op, io|
526
- if @lex_state == :EXPR_END
527
- @lex_state = :EXPR_BEG
528
- Token(TkQUESTION)
529
- else
530
- ch = getc
531
- if @lex_state == :EXPR_ARG && ch =~ /\s/
532
- ungetc
533
- @lex_state = :EXPR_BEG;
534
- Token(TkQUESTION)
535
- else
536
- @lex_state = :EXPR_END
537
- Token(TkCHAR, "?#{ch}")
538
- end
539
- end
540
- end
541
-
542
- @OP.def_rules("&", "&&", "|", "||") do
543
- |op, io|
544
- @lex_state = :EXPR_BEG
545
- Token(op)
546
- end
547
-
548
- @OP.def_rules("+=", "-=", "*=", "**=",
549
- "&=", "|=", "^=", "<<=", ">>=", "||=", "&&=") do
550
- |op, io|
551
- @lex_state = :EXPR_BEG
552
- op =~ /^(.*)=$/
553
- Token(TkOPASGN, $1)
554
- end
555
-
556
- @OP.def_rule("+@", proc{|op, io| @lex_state == :EXPR_FNAME}) do
557
- |op, io|
558
- @lex_state = :EXPR_ARG
559
- Token(op)
560
- end
561
-
562
- @OP.def_rule("-@", proc{|op, io| @lex_state == :EXPR_FNAME}) do
563
- |op, io|
564
- @lex_state = :EXPR_ARG
565
- Token(op)
566
- end
567
-
568
- @OP.def_rules("+", "-") do
569
- |op, io|
570
- catch(:RET) do
571
- if @lex_state == :EXPR_ARG
572
- if @space_seen and peek(0) =~ /[0-9]/
573
- throw :RET, identify_number(op)
574
- else
575
- @lex_state = :EXPR_BEG
576
- end
577
- elsif @lex_state != :EXPR_END and peek(0) =~ /[0-9]/
578
- throw :RET, identify_number(op)
579
- else
580
- @lex_state = :EXPR_BEG
581
- end
582
- Token(op)
583
- end
584
- end
585
-
586
- @OP.def_rule(".") do
587
- |op, io|
588
- @lex_state = :EXPR_BEG
589
- if peek(0) =~ /[0-9]/
590
- ungetc
591
- identify_number
592
- else
593
- # for "obj.if" etc.
594
- @lex_state = :EXPR_DOT
595
- Token(TkDOT)
596
- end
597
- end
598
-
599
- @OP.def_rules("..", "...") do
600
- |op, io|
601
- @lex_state = :EXPR_BEG
602
- Token(op)
603
- end
604
-
605
- lex_int2
606
- end
607
-
608
- def lex_int2
609
- @OP.def_rules("]", "}", ")") do
610
- |op, io|
611
- @lex_state = :EXPR_END
612
- @indent -= 1
613
- @indent_stack.pop
614
- Token(op)
615
- end
616
-
617
- @OP.def_rule(":") do
618
- |op, io|
619
- if @lex_state == :EXPR_END || peek(0) =~ /\s/
620
- @lex_state = :EXPR_BEG
621
- Token(TkCOLON)
622
- else
623
- @lex_state = :EXPR_FNAME;
624
- Token(TkSYMBEG)
625
- end
626
- end
627
-
628
- @OP.def_rule("::") do
629
- |op, io|
630
- # p @lex_state.id2name, @space_seen
631
- if @lex_state == :EXPR_BEG or @lex_state == :EXPR_ARG && @space_seen
632
- @lex_state = :EXPR_BEG
633
- Token(TkCOLON3)
634
- else
635
- @lex_state = :EXPR_DOT
636
- Token(TkCOLON2)
637
- end
638
- end
639
-
640
- @OP.def_rule("/") do
641
- |op, io|
642
- if @lex_state == :EXPR_BEG || @lex_state == :EXPR_MID
643
- identify_string(op)
644
- elsif peek(0) == '='
645
- getc
646
- @lex_state = :EXPR_BEG
647
- Token(TkOPASGN, "/") #/)
648
- elsif @lex_state == :EXPR_ARG and @space_seen and peek(0) !~ /\s/
649
- identify_string(op)
650
- else
651
- @lex_state = :EXPR_BEG
652
- Token("/") #/)
653
- end
654
- end
655
-
656
- @OP.def_rules("^") do
657
- |op, io|
658
- @lex_state = :EXPR_BEG
659
- Token("^")
660
- end
661
-
662
- # @OP.def_rules("^=") do
663
- # @lex_state = :EXPR_BEG
664
- # Token(OP_ASGN, :^)
665
- # end
666
-
667
- @OP.def_rules(",") do
668
- |op, io|
669
- @lex_state = :EXPR_BEG
670
- Token(op)
671
- end
672
-
673
- @OP.def_rules(";") do
674
- |op, io|
675
- @lex_state = :EXPR_BEG
676
- until (@indent_stack.empty? ||
677
- [TkLPAREN, TkLBRACK, TkLBRACE,
678
- TkfLPAREN, TkfLBRACK, TkfLBRACE].include?(@indent_stack.last))
679
- @indent_stack.pop
680
- end
681
- Token(op)
682
- end
683
-
684
- @OP.def_rule("~") do
685
- |op, io|
686
- @lex_state = :EXPR_BEG
687
- Token("~")
688
- end
689
-
690
- @OP.def_rule("~@", proc{|op, io| @lex_state == :EXPR_FNAME}) do
691
- |op, io|
692
- @lex_state = :EXPR_BEG
693
- Token("~")
694
- end
695
-
696
- @OP.def_rule("(") do
697
- |op, io|
698
- @indent += 1
699
- if @lex_state == :EXPR_BEG || @lex_state == :EXPR_MID
700
- @lex_state = :EXPR_BEG
701
- tk_c = TkfLPAREN
702
- else
703
- @lex_state = :EXPR_BEG
704
- tk_c = TkLPAREN
705
- end
706
- @indent_stack.push tk_c
707
- Token tk_c
708
- end
709
-
710
- @OP.def_rule("[]", proc{|op, io| @lex_state == :EXPR_FNAME}) do
711
- |op, io|
712
- @lex_state = :EXPR_ARG
713
- Token("[]")
714
- end
715
-
716
- @OP.def_rule("[]=", proc{|op, io| @lex_state == :EXPR_FNAME}) do
717
- |op, io|
718
- @lex_state = :EXPR_ARG
719
- Token("[]=")
720
- end
721
-
722
- @OP.def_rule("[") do
723
- |op, io|
724
- @indent += 1
725
- if @lex_state == :EXPR_FNAME
726
- tk_c = TkfLBRACK
727
- else
728
- if @lex_state == :EXPR_BEG || @lex_state == :EXPR_MID
729
- tk_c = TkLBRACK
730
- elsif @lex_state == :EXPR_ARG && @space_seen
731
- tk_c = TkLBRACK
732
- else
733
- tk_c = TkfLBRACK
734
- end
735
- @lex_state = :EXPR_BEG
736
- end
737
- @indent_stack.push tk_c
738
- Token(tk_c)
739
- end
740
-
741
- @OP.def_rule("{") do
742
- |op, io|
743
- @indent += 1
744
- if @lex_state != :EXPR_END && @lex_state != :EXPR_ARG
745
- tk_c = TkLBRACE
746
- else
747
- tk_c = TkfLBRACE
748
- end
749
- @lex_state = :EXPR_BEG
750
- @indent_stack.push tk_c
751
- Token(tk_c)
752
- end
753
-
754
- @OP.def_rule('\\') do
755
- |op, io|
756
- if getc == "\n"
757
- @space_seen = true
758
- @continue = true
759
- Token(TkSPACE)
760
- else
761
- ungetc
762
- Token("\\")
763
- end
764
- end
765
-
766
- @OP.def_rule('%') do
767
- |op, io|
768
- if @lex_state == :EXPR_BEG || @lex_state == :EXPR_MID
769
- identify_quotation
770
- elsif peek(0) == '='
771
- getc
772
- Token(TkOPASGN, :%)
773
- elsif @lex_state == :EXPR_ARG and @space_seen and peek(0) !~ /\s/
774
- identify_quotation
775
- else
776
- @lex_state = :EXPR_BEG
777
- Token("%") #))
778
- end
779
- end
780
-
781
- @OP.def_rule('$') do
782
- |op, io|
783
- identify_gvar
784
- end
785
-
786
- @OP.def_rule('@') do
787
- |op, io|
788
- if peek(0) =~ /[\w@]/
789
- ungetc
790
- identify_identifier
791
- else
792
- Token("@")
793
- end
794
- end
795
-
796
- # @OP.def_rule("def", proc{|op, io| /\s/ =~ io.peek(0)}) do
797
- # |op, io|
798
- # @indent += 1
799
- # @lex_state = :EXPR_FNAME
800
- # # @lex_state = :EXPR_END
801
- # # until @rests[0] == "\n" or @rests[0] == ";"
802
- # # rests.shift
803
- # # end
804
- # end
805
-
806
- @OP.def_rule("_") do
807
- if peek_match?(/_END__/) and @lex_state == :EXPR_BEG then
808
- 6.times { getc }
809
- Token(TkEND_OF_SCRIPT, '__END__')
810
- else
811
- ungetc
812
- identify_identifier
813
- end
814
- end
815
-
816
- @OP.def_rule("") do
817
- |op, io|
818
- printf "MATCH: start %s: %s\n", op, io.inspect if RDoc::RubyLex.debug?
819
- if peek(0) =~ /[0-9]/
820
- t = identify_number
821
- else
822
- t = identify_identifier
823
- end
824
- printf "MATCH: end %s: %s\n", op, io.inspect if RDoc::RubyLex.debug?
825
- t
826
- end
827
-
828
- p @OP if RDoc::RubyLex.debug?
829
- end
830
-
831
- def identify_gvar
832
- @lex_state = :EXPR_END
833
-
834
- case ch = getc
835
- when /[~_*$?!@\/\\;,=:<>".]/ #"
836
- Token(TkGVAR, "$" + ch)
837
- when "-"
838
- Token(TkGVAR, "$-" + getc)
839
- when "&", "`", "'", "+"
840
- Token(TkBACK_REF, "$"+ch)
841
- when /[1-9]/
842
- ref = ch
843
- while (ch = getc) =~ /[0-9]/ do ref << ch end
844
- ungetc
845
- Token(TkNTH_REF, "$#{ref}")
846
- when /\w/
847
- ungetc
848
- ungetc
849
- identify_identifier
850
- else
851
- ungetc
852
- Token("$")
853
- end
854
- end
855
-
856
- IDENT_RE = eval '/[\w\u{0080}-\u{FFFFF}]/u'
857
-
858
- def identify_identifier
859
- token = ""
860
- if peek(0) =~ /[$@]/
861
- token.concat(c = getc)
862
- if c == "@" and peek(0) == "@"
863
- token.concat getc
864
- end
865
- end
866
-
867
- while (ch = getc) =~ IDENT_RE do
868
- print " :#{ch}: " if RDoc::RubyLex.debug?
869
- token.concat ch
870
- end
871
-
872
- ungetc
873
-
874
- if (ch == "!" || ch == "?") && token[0,1] =~ /\w/ && peek(0) != "="
875
- token.concat getc
876
- end
877
-
878
- # almost fix token
879
-
880
- case token
881
- when /^\$/
882
- return Token(TkGVAR, token)
883
- when /^\@\@/
884
- @lex_state = :EXPR_END
885
- # p Token(TkCVAR, token)
886
- return Token(TkCVAR, token)
887
- when /^\@/
888
- @lex_state = :EXPR_END
889
- return Token(TkIVAR, token)
890
- end
891
-
892
- if @lex_state != :EXPR_DOT
893
- print token, "\n" if RDoc::RubyLex.debug?
894
-
895
- token_c, *trans = TkReading2Token[token]
896
- if token_c
897
- # reserved word?
898
-
899
- if (@lex_state != :EXPR_BEG &&
900
- @lex_state != :EXPR_FNAME &&
901
- trans[1])
902
- # modifiers
903
- token_c = TkSymbol2Token[trans[1]]
904
- @lex_state = trans[0]
905
- else
906
- if @lex_state != :EXPR_FNAME
907
- if ENINDENT_CLAUSE.include?(token)
908
- valid = peek(0) != ':'
909
-
910
- # check for ``class = val'' etc.
911
- case token
912
- when "class"
913
- valid = false unless peek_match?(/^\s*(<<|\w|::)/)
914
- when "def"
915
- valid = false if peek_match?(/^\s*(([+-\/*&\|^]|<<|>>|\|\||\&\&)=|\&\&|\|\|)/)
916
- when "do"
917
- valid = false if peek_match?(/^\s*([+-\/*]?=|\*|<|>|\&)/)
918
- when *ENINDENT_CLAUSE
919
- valid = false if peek_match?(/^\s*([+-\/*]?=|\*|<|>|\&|\|)/)
920
- else
921
- # no nothing
922
- end if valid
923
-
924
- if valid
925
- if token == "do"
926
- if ![TkFOR, TkWHILE, TkUNTIL].include?(@indent_stack.last)
927
- @indent += 1
928
- @indent_stack.push token_c
929
- end
930
- else
931
- @indent += 1
932
- @indent_stack.push token_c
933
- end
934
- else
935
- token_c = TkIDENTIFIER
936
- end
937
-
938
- elsif DEINDENT_CLAUSE.include?(token)
939
- @indent -= 1
940
- @indent_stack.pop
941
- end
942
- @lex_state = trans[0]
943
- else
944
- @lex_state = :EXPR_END
945
- end
946
- end
947
- return Token(token_c, token)
948
- end
949
- end
950
-
951
- if @lex_state == :EXPR_FNAME
952
- @lex_state = :EXPR_END
953
- if peek(0) == '='
954
- token.concat getc
955
- end
956
- elsif @lex_state == :EXPR_BEG || @lex_state == :EXPR_DOT ||
957
- @lex_state == :EXPR_ARG
958
- @lex_state = :EXPR_ARG
959
- else
960
- @lex_state = :EXPR_END
961
- end
962
-
963
- if token[0, 1] =~ /[A-Z]/
964
- return Token(TkCONSTANT, token)
965
- elsif token[token.size - 1, 1] =~ /[!?]/
966
- return Token(TkFID, token)
967
- else
968
- return Token(TkIDENTIFIER, token)
969
- end
970
- end
971
-
972
- def identify_here_document
973
- ch = getc
974
- # if lt = PERCENT_LTYPE[ch]
975
- if ch == "-"
976
- ch = getc
977
- indent = true
978
- end
979
- if /['"`]/ =~ ch
980
- user_quote = lt = ch
981
- quoted = ""
982
- while (c = getc) && c != lt
983
- quoted.concat c
984
- end
985
- else
986
- user_quote = nil
987
- lt = '"'
988
- quoted = ch.dup
989
- while (c = getc) && c =~ /\w/
990
- quoted.concat c
991
- end
992
- ungetc
993
- end
994
-
995
- ltback, @ltype = @ltype, lt
996
- reserve = []
997
- while ch = getc
998
- reserve.push ch
999
- if ch == "\\"
1000
- reserve.push ch = getc
1001
- elsif ch == "\n"
1002
- break
1003
- end
1004
- end
1005
-
1006
- output_heredoc = reserve.join =~ /\A\r?\n\z/
1007
-
1008
- if output_heredoc then
1009
- doc = '<<'
1010
- doc << '-' if indent
1011
- doc << "#{user_quote}#{quoted}#{user_quote}\n"
1012
- else
1013
- doc = '"'
1014
- end
1015
-
1016
- @current_readed = @readed
1017
- while l = gets
1018
- l = l.sub(/(:?\r)?\n\z/, "\n")
1019
- if (indent ? l.strip : l.chomp) == quoted
1020
- break
1021
- end
1022
- doc << l
1023
- end
1024
-
1025
- if output_heredoc then
1026
- raise Error, "Missing terminating #{quoted} for string" unless l
1027
-
1028
- doc << l.chomp
1029
- else
1030
- doc << '"'
1031
- end
1032
-
1033
- @current_readed = @here_readed
1034
- @here_readed.concat reserve
1035
- while ch = reserve.pop
1036
- ungetc ch
1037
- end
1038
-
1039
- token_class = output_heredoc ? RDoc::RubyLex::TkHEREDOC : Ltype2Token[lt]
1040
- @ltype = ltback
1041
- @lex_state = :EXPR_END
1042
- Token(token_class, doc)
1043
- end
1044
-
1045
- def identify_quotation
1046
- type = ch = getc
1047
- if lt = PERCENT_LTYPE[type]
1048
- ch = getc
1049
- elsif type =~ /\W/
1050
- type = nil
1051
- lt = "\""
1052
- else
1053
- return Token(TkMOD, '%')
1054
- end
1055
- # if ch !~ /\W/
1056
- # ungetc
1057
- # next
1058
- # end
1059
- #@ltype = lt
1060
- @quoted = ch unless @quoted = PERCENT_PAREN[ch]
1061
- identify_string(lt, @quoted, type)
1062
- end
1063
-
1064
- def identify_number(op = "")
1065
- @lex_state = :EXPR_END
1066
-
1067
- num = op
1068
-
1069
- if peek(0) == "0" && peek(1) !~ /[.eE]/
1070
- num << getc
1071
-
1072
- case peek(0)
1073
- when /[xX]/
1074
- ch = getc
1075
- match = /[0-9a-fA-F_]/
1076
- when /[bB]/
1077
- ch = getc
1078
- match = /[01_]/
1079
- when /[oO]/
1080
- ch = getc
1081
- match = /[0-7_]/
1082
- when /[dD]/
1083
- ch = getc
1084
- match = /[0-9_]/
1085
- when /[0-7]/
1086
- match = /[0-7_]/
1087
- when /[89]/
1088
- raise Error, "Illegal octal digit"
1089
- else
1090
- return Token(TkINTEGER, num)
1091
- end
1092
-
1093
- num << ch if ch
1094
-
1095
- len0 = true
1096
- non_digit = false
1097
- while ch = getc
1098
- num << ch
1099
- if match =~ ch
1100
- if ch == "_"
1101
- if non_digit
1102
- raise Error, "trailing `#{ch}' in number"
1103
- else
1104
- non_digit = ch
1105
- end
1106
- else
1107
- non_digit = false
1108
- len0 = false
1109
- end
1110
- else
1111
- ungetc
1112
- num[-1, 1] = ''
1113
- if len0
1114
- raise Error, "numeric literal without digits"
1115
- end
1116
- if non_digit
1117
- raise Error, "trailing `#{non_digit}' in number"
1118
- end
1119
- break
1120
- end
1121
- end
1122
- return Token(TkINTEGER, num)
1123
- end
1124
-
1125
- type = TkINTEGER
1126
- allow_point = true
1127
- allow_e = true
1128
- non_digit = false
1129
- while ch = getc
1130
- num << ch
1131
- case ch
1132
- when /[0-9]/
1133
- non_digit = false
1134
- when "_"
1135
- non_digit = ch
1136
- when allow_point && "."
1137
- if non_digit
1138
- raise Error, "trailing `#{non_digit}' in number"
1139
- end
1140
- type = TkFLOAT
1141
- if peek(0) !~ /[0-9]/
1142
- type = TkINTEGER
1143
- ungetc
1144
- num[-1, 1] = ''
1145
- break
1146
- end
1147
- allow_point = false
1148
- when allow_e && "e", allow_e && "E"
1149
- if non_digit
1150
- raise Error, "trailing `#{non_digit}' in number"
1151
- end
1152
- type = TkFLOAT
1153
- if peek(0) =~ /[+-]/
1154
- num << getc
1155
- end
1156
- allow_e = false
1157
- allow_point = false
1158
- non_digit = ch
1159
- else
1160
- if non_digit
1161
- raise Error, "trailing `#{non_digit}' in number"
1162
- end
1163
- ungetc
1164
- num[-1, 1] = ''
1165
- break
1166
- end
1167
- end
1168
-
1169
- Token(type, num)
1170
- end
1171
-
1172
- def identify_string(ltype, quoted = ltype, type = nil)
1173
- close = PERCENT_PAREN.values.include?(quoted)
1174
- @ltype = ltype
1175
- @quoted = quoted
1176
-
1177
- str = if ltype == quoted and %w[" ' /].include? ltype then
1178
- ltype.dup
1179
- else
1180
- "%#{type or PERCENT_LTYPE.key ltype}#{PERCENT_PAREN_REV[quoted]||quoted}"
1181
- end
1182
-
1183
- subtype = nil
1184
- begin
1185
- nest = 0
1186
-
1187
- while ch = getc
1188
- str << ch
1189
-
1190
- if @quoted == ch and nest <= 0
1191
- break
1192
- elsif @ltype != "'" && @ltype != "]" && @ltype != ":" and ch == "#"
1193
- ch = getc
1194
- subtype = true
1195
- if ch == "{" then
1196
- str << ch << skip_inner_expression
1197
- next
1198
- else
1199
- ungetc
1200
- end
1201
- elsif ch == '\\'
1202
- if %w[' /].include? @ltype then
1203
- case ch = getc
1204
- when "\\", "\n", "'"
1205
- when @ltype
1206
- str << ch
1207
- else
1208
- ungetc
1209
- end
1210
- else
1211
- str << read_escape
1212
- end
1213
- end
1214
-
1215
- if close then
1216
- if PERCENT_PAREN[ch] == @quoted
1217
- nest += 1
1218
- elsif ch == @quoted
1219
- nest -= 1
1220
- end
1221
- end
1222
- end
1223
-
1224
- if @ltype == "/"
1225
- while peek(0) =~ /i|m|x|o|e|s|u|n/
1226
- str << getc
1227
- end
1228
- end
1229
-
1230
- if subtype
1231
- Token(DLtype2Token[ltype], str)
1232
- else
1233
- Token(Ltype2Token[ltype], str)
1234
- end
1235
- ensure
1236
- @ltype = nil
1237
- @quoted = nil
1238
- @lex_state = :EXPR_END
1239
- end
1240
- end
1241
-
1242
- def skip_inner_expression
1243
- res = ""
1244
- nest = 0
1245
- while ch = getc
1246
- res << ch
1247
- if ch == '}'
1248
- break if nest.zero?
1249
- nest -= 1
1250
- elsif ch == '{'
1251
- nest += 1
1252
- end
1253
- end
1254
- res
1255
- end
1256
-
1257
- def identify_comment
1258
- @ltype = "#"
1259
-
1260
- comment = '#'
1261
-
1262
- while ch = getc
1263
- # if ch == "\\" #"
1264
- # read_escape
1265
- # end
1266
- if ch == "\n"
1267
- @ltype = nil
1268
- ungetc
1269
- break
1270
- end
1271
-
1272
- comment << ch
1273
- end
1274
-
1275
- return Token(TkCOMMENT, comment)
1276
- end
1277
-
1278
- def read_escape
1279
- escape = ''
1280
- ch = getc
1281
-
1282
- case ch
1283
- when "\n", "\r", "\f"
1284
- escape << ch
1285
- when "\\", "n", "t", "r", "f", "v", "a", "e", "b", "s" #"
1286
- escape << ch
1287
- when /[0-7]/
1288
- ungetc ch
1289
- 3.times do
1290
- ch = getc
1291
- case ch
1292
- when /[0-7]/
1293
- escape << ch
1294
- when nil
1295
- break
1296
- else
1297
- ungetc
1298
- break
1299
- end
1300
- end
1301
-
1302
- when "x"
1303
- escape << ch
1304
-
1305
- 2.times do
1306
- ch = getc
1307
- case ch
1308
- when /[0-9a-fA-F]/
1309
- escape << ch
1310
- when nil
1311
- break
1312
- else
1313
- ungetc
1314
- break
1315
- end
1316
- end
1317
-
1318
- when "M"
1319
- escape << ch
1320
-
1321
- ch = getc
1322
- if ch != '-'
1323
- ungetc
1324
- else
1325
- escape << ch
1326
-
1327
- ch = getc
1328
- if ch == "\\" #"
1329
- ungetc
1330
- escape << read_escape
1331
- else
1332
- escape << ch
1333
- end
1334
- end
1335
-
1336
- when "C", "c" #, "^"
1337
- escape << ch
1338
-
1339
- if ch == "C"
1340
- ch = getc
1341
-
1342
- if ch == "-"
1343
- escape << ch
1344
- ch = getc
1345
- escape << ch
1346
-
1347
- escape << read_escape if ch == "\\"
1348
- else
1349
- ungetc
1350
- end
1351
- elsif (ch = getc) == "\\" #"
1352
- escape << ch << read_escape
1353
- end
1354
- else
1355
- escape << ch
1356
-
1357
- # other characters
1358
- end
1359
-
1360
- escape
1361
- end
1362
-
1363
- # :startdoc:
1364
-
1365
- end
1366
-
1367
- #RDoc::RubyLex.debug_level = 1