rdoc 8.0.0 → 8.1.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 (114) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +1 -3
  3. data/RI.md +75 -75
  4. data/exe/rdoc +2 -2
  5. data/lib/rdoc/code_object/alias.rb +71 -69
  6. data/lib/rdoc/code_object/any_method.rb +305 -303
  7. data/lib/rdoc/code_object/attr.rb +150 -148
  8. data/lib/rdoc/code_object/class_module.rb +798 -792
  9. data/lib/rdoc/code_object/constant.rb +175 -173
  10. data/lib/rdoc/code_object/context/section.rb +142 -138
  11. data/lib/rdoc/code_object/context.rb +926 -958
  12. data/lib/rdoc/code_object/extend.rb +7 -5
  13. data/lib/rdoc/code_object/include.rb +7 -5
  14. data/lib/rdoc/code_object/method_attr.rb +326 -319
  15. data/lib/rdoc/code_object/mixin.rb +97 -95
  16. data/lib/rdoc/code_object/normal_class.rb +77 -78
  17. data/lib/rdoc/code_object/normal_module.rb +61 -59
  18. data/lib/rdoc/code_object/require.rb +23 -39
  19. data/lib/rdoc/code_object/single_class.rb +21 -19
  20. data/lib/rdoc/code_object/top_level.rb +212 -219
  21. data/lib/rdoc/code_object.rb +305 -303
  22. data/lib/rdoc/comment.rb +275 -273
  23. data/lib/rdoc/cross_reference.rb +192 -190
  24. data/lib/rdoc/encoding.rb +105 -103
  25. data/lib/rdoc/erb_partial.rb +13 -11
  26. data/lib/rdoc/erbio.rb +29 -27
  27. data/lib/rdoc/generator/aliki.rb +161 -153
  28. data/lib/rdoc/generator/darkfish.rb +645 -635
  29. data/lib/rdoc/generator/json_index.rb +233 -229
  30. data/lib/rdoc/generator/markup.rb +164 -146
  31. data/lib/rdoc/generator/pot/message_extractor.rb +57 -51
  32. data/lib/rdoc/generator/pot/po.rb +52 -51
  33. data/lib/rdoc/generator/pot/po_entry.rb +138 -132
  34. data/lib/rdoc/generator/pot.rb +85 -81
  35. data/lib/rdoc/generator/ri.rb +23 -19
  36. data/lib/rdoc/generator/template/aliki/DESIGN.md +6 -4
  37. data/lib/rdoc/generator/template/aliki/_footer.rhtml +1 -1
  38. data/lib/rdoc/generator/template/aliki/_head.rhtml +10 -10
  39. data/lib/rdoc/generator/template/aliki/_header.rhtml +29 -44
  40. data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +4 -4
  41. data/lib/rdoc/generator/template/aliki/css/rdoc.css +207 -178
  42. data/lib/rdoc/generator/template/aliki/js/aliki.js +60 -84
  43. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +1 -1
  44. data/lib/rdoc/generator.rb +48 -46
  45. data/lib/rdoc/i18n/locale.rb +99 -95
  46. data/lib/rdoc/i18n/text.rb +109 -105
  47. data/lib/rdoc/i18n.rb +7 -5
  48. data/lib/rdoc/markdown/byte_runtime.rb +80 -0
  49. data/lib/rdoc/markdown.kpeg +15 -11
  50. data/lib/rdoc/markdown.rb +40 -47
  51. data/lib/rdoc/markup/block_quote.rb +12 -8
  52. data/lib/rdoc/markup/document.rb +127 -123
  53. data/lib/rdoc/markup/formatter.rb +219 -215
  54. data/lib/rdoc/markup/include.rb +33 -29
  55. data/lib/rdoc/markup/indented_paragraph.rb +37 -33
  56. data/lib/rdoc/markup/inline_parser.rb +281 -277
  57. data/lib/rdoc/markup/list.rb +80 -88
  58. data/lib/rdoc/markup/list_item.rb +73 -85
  59. data/lib/rdoc/markup/paragraph.rb +23 -19
  60. data/lib/rdoc/markup/parser.rb +501 -497
  61. data/lib/rdoc/markup/pre_process.rb +283 -279
  62. data/lib/rdoc/markup/raw.rb +2 -2
  63. data/lib/rdoc/markup/rule.rb +16 -12
  64. data/lib/rdoc/markup/to_ansi.rb +143 -139
  65. data/lib/rdoc/markup/to_bs.rb +72 -68
  66. data/lib/rdoc/markup/to_html.rb +594 -565
  67. data/lib/rdoc/markup/to_html_crossref.rb +234 -230
  68. data/lib/rdoc/markup/to_html_snippet.rb +232 -227
  69. data/lib/rdoc/markup/to_joined_paragraph.rb +36 -32
  70. data/lib/rdoc/markup/to_label.rb +63 -59
  71. data/lib/rdoc/markup/to_markdown.rb +212 -208
  72. data/lib/rdoc/markup/to_rdoc.rb +336 -332
  73. data/lib/rdoc/markup/to_table_of_contents.rb +66 -62
  74. data/lib/rdoc/markup/to_test.rb +60 -56
  75. data/lib/rdoc/markup/to_tt_only.rb +84 -80
  76. data/lib/rdoc/markup/verbatim.rb +62 -58
  77. data/lib/rdoc/markup.rb +198 -196
  78. data/lib/rdoc/options.rb +1063 -1061
  79. data/lib/rdoc/parser/c.rb +1039 -1037
  80. data/lib/rdoc/parser/changelog.rb +319 -315
  81. data/lib/rdoc/parser/markdown.rb +17 -13
  82. data/lib/rdoc/parser/rbs.rb +239 -235
  83. data/lib/rdoc/parser/rd.rb +17 -13
  84. data/lib/rdoc/parser/ruby.rb +1245 -1124
  85. data/lib/rdoc/parser/ruby_colorizer.rb +263 -213
  86. data/lib/rdoc/parser/simple.rb +31 -27
  87. data/lib/rdoc/parser/text.rb +12 -8
  88. data/lib/rdoc/parser.rb +228 -220
  89. data/lib/rdoc/rbs_helper.rb +1 -1
  90. data/lib/rdoc/rd/inline.rb +57 -53
  91. data/lib/rdoc/rd.rb +90 -88
  92. data/lib/rdoc/rdoc.rb +500 -491
  93. data/lib/rdoc/ri/driver.rb +1140 -1135
  94. data/lib/rdoc/ri/formatter.rb +7 -3
  95. data/lib/rdoc/ri/paths.rb +140 -136
  96. data/lib/rdoc/ri/servlet.rb +354 -350
  97. data/lib/rdoc/ri/store.rb +4 -2
  98. data/lib/rdoc/ri/task.rb +55 -51
  99. data/lib/rdoc/ri.rb +14 -12
  100. data/lib/rdoc/rubygems_hook.rb +183 -181
  101. data/lib/rdoc/server.rb +349 -347
  102. data/lib/rdoc/stats/normal.rb +46 -42
  103. data/lib/rdoc/stats/quiet.rb +39 -35
  104. data/lib/rdoc/stats/verbose.rb +35 -31
  105. data/lib/rdoc/stats.rb +365 -363
  106. data/lib/rdoc/store.rb +888 -902
  107. data/lib/rdoc/task.rb +260 -256
  108. data/lib/rdoc/text.rb +135 -133
  109. data/lib/rdoc/token_stream.rb +101 -93
  110. data/lib/rdoc/tom_doc.rb +203 -201
  111. data/lib/rdoc/version.rb +1 -1
  112. metadata +4 -5
  113. data/lib/rdoc/markdown/literals.kpeg +0 -21
  114. data/lib/rdoc/markdown/literals.rb +0 -454
data/lib/rdoc/text.rb CHANGED
@@ -5,29 +5,30 @@
5
5
 
6
6
  require 'strscan'
7
7
 
8
- ##
9
- # Methods for manipulating comment text
8
+ module RDoc
9
+ ##
10
+ # Methods for manipulating comment text
10
11
 
11
- module RDoc::Text
12
+ module Text
12
13
 
13
- ##
14
- # The language for this text. This affects stripping comments
15
- # markers.
14
+ ##
15
+ # The language for this text. This affects stripping comments
16
+ # markers.
16
17
 
17
- attr_accessor :language
18
+ attr_accessor :language
18
19
 
19
- ##
20
- # Maps markup formats to classes that can parse them. If the format is
21
- # unknown, "rdoc" format is used.
20
+ ##
21
+ # Maps markup formats to classes that can parse them. If the format is
22
+ # unknown, "rdoc" format is used.
22
23
 
23
- MARKUP_FORMAT = {
24
- 'markdown' => RDoc::Markdown,
25
- 'rdoc' => RDoc::Markup,
26
- 'rd' => RDoc::RD,
27
- 'tomdoc' => RDoc::TomDoc,
28
- }
24
+ MARKUP_FORMAT = {
25
+ 'markdown' => Markdown,
26
+ 'rdoc' => Markup,
27
+ 'rd' => RD,
28
+ 'tomdoc' => TomDoc,
29
+ }
29
30
 
30
- MARKUP_FORMAT.default = RDoc::Markup
31
+ MARKUP_FORMAT.default = Markup
31
32
 
32
33
  ##
33
34
  # Expands tab characters in +text+ to eight spaces
@@ -38,7 +39,7 @@ module RDoc::Text
38
39
  text.each_line do |line|
39
40
  nil while line.gsub!(/(?:\G|\r)((?:.{8})*?)([^\t\r\n]{0,7})\t/) do
40
41
  r = "#{$1}#{$2}#{' ' * (8 - $2.size)}"
41
- r = RDoc::Encoding.change_encoding r, text.encoding
42
+ r = Encoding.change_encoding r, text.encoding
42
43
  r
43
44
  end
44
45
 
@@ -48,160 +49,160 @@ module RDoc::Text
48
49
  expanded.join
49
50
  end
50
51
 
51
- ##
52
- # Flush +text+ left based on the shortest line
52
+ ##
53
+ # Flush +text+ left based on the shortest line
53
54
 
54
- def flush_left(text)
55
- indent = 9999
55
+ def flush_left(text)
56
+ indent = 9999
56
57
 
57
- text.each_line do |line|
58
- line_indent = line =~ /\S/ || 9999
59
- indent = line_indent if indent > line_indent
60
- end
58
+ text.each_line do |line|
59
+ line_indent = line =~ /\S/ || 9999
60
+ indent = line_indent if indent > line_indent
61
+ end
61
62
 
62
- empty = ''
63
- empty = RDoc::Encoding.change_encoding empty, text.encoding
63
+ empty = ''
64
+ empty = Encoding.change_encoding empty, text.encoding
64
65
 
65
- text.gsub(/^ {0,#{indent}}/, empty)
66
- end
66
+ text.gsub(/^ {0,#{indent}}/, empty)
67
+ end
67
68
 
68
- ##
69
- # Convert a string in markup format into HTML.
70
- #
71
- # Requires the including class to implement #formatter
69
+ ##
70
+ # Convert a string in markup format into HTML.
71
+ #
72
+ # Requires the including class to implement #formatter
72
73
 
73
- def markup(text)
74
- if @store.options
75
- locale = @store.options.locale
76
- else
77
- locale = nil
78
- end
79
- if locale
80
- i18n_text = RDoc::I18n::Text.new(text)
81
- text = i18n_text.translate(locale)
74
+ def markup(text)
75
+ if @store.options
76
+ locale = @store.options.locale
77
+ else
78
+ locale = nil
79
+ end
80
+ if locale
81
+ i18n_text = I18n::Text.new(text)
82
+ text = i18n_text.translate(locale)
83
+ end
84
+ parse(text).accept formatter
82
85
  end
83
- parse(text).accept formatter
84
- end
85
86
 
86
- ##
87
- # Strips hashes, expands tabs then flushes +text+ to the left
87
+ ##
88
+ # Strips hashes, expands tabs then flushes +text+ to the left
88
89
 
89
- def normalize_comment(text)
90
- return text if text.empty?
90
+ def normalize_comment(text)
91
+ return text if text.empty?
91
92
 
92
- case language
93
- when :ruby
94
- text = strip_hashes text
95
- when :c
96
- text = strip_stars text
93
+ case language
94
+ when :ruby
95
+ text = strip_hashes text
96
+ when :c
97
+ text = strip_stars text
98
+ end
99
+ text = expand_tabs text
100
+ text = flush_left text
101
+ text = strip_newlines text
102
+ text
97
103
  end
98
- text = expand_tabs text
99
- text = flush_left text
100
- text = strip_newlines text
101
- text
102
- end
103
104
 
104
- ##
105
- # Normalizes +text+ then builds a RDoc::Markup::Document from it
105
+ ##
106
+ # Normalizes +text+ then builds a RDoc::Markup::Document from it
106
107
 
107
- def parse(text, format = 'rdoc')
108
- return text if RDoc::Markup::Document === text
109
- return text.parse if RDoc::Comment === text
108
+ def parse(text, format = 'rdoc')
109
+ return text if Markup::Document === text
110
+ return text.parse if Comment === text
110
111
 
111
- text = normalize_comment text # TODO remove, should not be necessary
112
+ text = normalize_comment text # TODO remove, should not be necessary
112
113
 
113
- return RDoc::Markup::Document.new if text =~ /\A\n*\z/
114
+ return Markup::Document.new if text =~ /\A\n*\z/
114
115
 
115
- MARKUP_FORMAT[format].parse text
116
- end
116
+ MARKUP_FORMAT[format].parse text
117
+ end
117
118
 
118
- ##
119
- # The first +limit+ characters of +text+ as HTML
119
+ ##
120
+ # The first +limit+ characters of +text+ as HTML
120
121
 
121
- def snippet(text, limit = 100)
122
- document = parse text
122
+ def snippet(text, limit = 100)
123
+ document = parse text
123
124
 
124
- RDoc::Markup::ToHtmlSnippet.new(limit).convert document
125
- end
125
+ Markup::ToHtmlSnippet.new(limit).convert document
126
+ end
126
127
 
127
- ##
128
- # Strips leading # characters from +text+
128
+ ##
129
+ # Strips leading # characters from +text+
129
130
 
130
- def strip_hashes(text)
131
- return text if text =~ /^(?>\s*)[^\#]/
131
+ def strip_hashes(text)
132
+ return text if text =~ /^(?>\s*)[^\#]/
132
133
 
133
- empty = ''
134
- empty = RDoc::Encoding.change_encoding empty, text.encoding
134
+ empty = ''
135
+ empty = Encoding.change_encoding empty, text.encoding
135
136
 
136
- text.gsub(/^\s*(#+)/) { $1.tr '#', ' ' }.gsub(/^\s+$/, empty)
137
- end
137
+ text.gsub(/^\s*(#+)/) { $1.tr '#', ' ' }.gsub(/^\s+$/, empty)
138
+ end
138
139
 
139
- ##
140
- # Strips leading and trailing \n characters from +text+
140
+ ##
141
+ # Strips leading and trailing \n characters from +text+
141
142
 
142
- def strip_newlines(text)
143
- text.gsub(/\A\n*(.*?)\n*\z/m) do $1 end # block preserves String encoding
144
- end
143
+ def strip_newlines(text)
144
+ text.gsub(/\A\n*(.*?)\n*\z/m) do $1 end # block preserves String encoding
145
+ end
145
146
 
146
- ##
147
- # Strips /* */ style comments
147
+ ##
148
+ # Strips /* */ style comments
148
149
 
149
- def strip_stars(text)
150
- return text unless text =~ %r%/\*.*\*/%m
150
+ def strip_stars(text)
151
+ return text unless text =~ %r%/\*.*\*/%m
151
152
 
152
- encoding = text.encoding
153
+ encoding = text.encoding
153
154
 
154
- text = text.gsub %r%Document-method:\s+[\w:.#=!?|^&<>~+\-/*\%@`\[\]]+%, ''
155
+ text = text.gsub %r%Document-method:\s+[\w:.#=!?|^&<>~+\-/*\%@`\[\]]+%, ''
155
156
 
156
- space = ' '
157
- space = RDoc::Encoding.change_encoding space, encoding if encoding
157
+ space = ' '
158
+ space = Encoding.change_encoding space, encoding if encoding
158
159
 
159
- text.sub! %r%/\*+% do space * $&.length end
160
- text.sub! %r%\*+/% do space * $&.length end
161
- text.gsub! %r%^[ \t]*\*%m do space * $&.length end
160
+ text.sub! %r%/\*+% do space * $&.length end
161
+ text.sub! %r%\*+/% do space * $&.length end
162
+ text.gsub! %r%^[ \t]*\*%m do space * $&.length end
162
163
 
163
- empty = ''
164
- empty = RDoc::Encoding.change_encoding empty, encoding if encoding
165
- text.gsub(/^\s+$/, empty)
166
- end
164
+ empty = ''
165
+ empty = Encoding.change_encoding empty, encoding if encoding
166
+ text.gsub(/^\s+$/, empty)
167
+ end
167
168
 
168
- ##
169
- # Wraps +txt+ to +line_len+
170
-
171
- def wrap(txt, line_len = 76)
172
- res = []
173
- sp = 0
174
- ep = txt.length
175
-
176
- while sp < ep
177
- # scan back for a space
178
- p = sp + line_len - 1
179
- if p >= ep
180
- p = ep
181
- else
182
- while p > sp and txt[p] != ?\s
183
- p -= 1
184
- end
185
- if p <= sp
186
- p = sp + line_len
187
- while p < ep and txt[p] != ?\s
188
- p += 1
169
+ ##
170
+ # Wraps +txt+ to +line_len+
171
+
172
+ def wrap(txt, line_len = 76)
173
+ res = []
174
+ sp = 0
175
+ ep = txt.length
176
+
177
+ while sp < ep
178
+ # scan back for a space
179
+ p = sp + line_len - 1
180
+ if p >= ep
181
+ p = ep
182
+ else
183
+ while p > sp and txt[p] != ?\s
184
+ p -= 1
185
+ end
186
+ if p <= sp
187
+ p = sp + line_len
188
+ while p < ep and txt[p] != ?\s
189
+ p += 1
190
+ end
189
191
  end
190
192
  end
193
+ res << txt[sp...p] << "\n"
194
+ sp = p
195
+ sp += 1 while sp < ep and txt[sp] == ?\s
191
196
  end
192
- res << txt[sp...p] << "\n"
193
- sp = p
194
- sp += 1 while sp < ep and txt[sp] == ?\s
197
+
198
+ res.join.strip
195
199
  end
196
200
 
197
- res.join.strip
198
- end
201
+ ##
202
+ # Character class to be separated by a space when concatenating
203
+ # lines.
199
204
 
200
- ##
201
- # Character class to be separated by a space when concatenating
202
- # lines.
203
-
204
- SPACE_SEPARATED_LETTER_CLASS = /[\p{Nd}\p{Lc}\p{Pc}]|[!-~&&\W]/
205
+ SPACE_SEPARATED_LETTER_CLASS = /[\p{Nd}\p{Lc}\p{Pc}]|[!-~&&\W]/
205
206
 
206
207
  ##
207
208
  # Converts +text+ to a GitHub-style anchor ID:
@@ -241,4 +242,5 @@ module RDoc::Text
241
242
  label
242
243
  end
243
244
 
245
+ end
244
246
  end
@@ -1,104 +1,112 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ##
4
- # A TokenStream is a list of tokens, gathered during the parse of some entity
5
- # (say a method). Entities populate these streams by being registered with the
6
- # lexer. Any class can collect tokens by including TokenStream. From the
7
- # outside, you use such an object by calling the start_collecting_tokens
8
- # method, followed by calls to add_token and pop_token.
9
-
10
- module RDoc::TokenStream
11
-
3
+ module RDoc
12
4
  ##
13
- # Converts +token_stream+ to HTML wrapping various tokens with
14
- # <tt><span></tt> elements. Some tokens types are wrapped in spans
15
- # with the given class names. Other token types are not wrapped in spans.
16
-
17
- def self.to_html(token_stream)
18
- token_stream.map do |t|
19
- next unless t
20
-
21
- style = case t[:kind]
22
- when :operator then 'ruby-operator'
23
- when :keyword then 'ruby-keyword'
24
- when :constant then 'ruby-constant'
25
- when :ivar then 'ruby-ivar'
26
- when :comment then 'ruby-comment'
27
- when :value then 'ruby-value'
28
- when :string then 'ruby-string'
29
- when :symbol then 'ruby-value'
30
- when :x_string then 'ruby-string'
31
- when :regexp then 'ruby-regexp'
32
- when :identifier then 'ruby-identifier'
33
- end
34
-
35
- text = t[:text]
36
-
37
- text = CGI.escapeHTML text
38
-
39
- if style then
40
- end_with_newline = text.end_with?("\n")
41
- text = text.chomp if end_with_newline
42
- "<span class=\"#{style}\">#{text}</span>#{"\n" if end_with_newline}"
43
- else
44
- text
5
+ # A TokenStream is a list of tokens, gathered during the parse of some entity
6
+ # (say a method). Entities populate these streams by being registered with the
7
+ # lexer. Any class can collect tokens by including TokenStream. From the
8
+ # outside, you use such an object by calling the start_collecting_tokens
9
+ # method, followed by calls to add_token and pop_token.
10
+
11
+ module TokenStream
12
+
13
+ ##
14
+ # Converts +token_stream+ to HTML wrapping various tokens with
15
+ # <tt><span></tt> elements. Some tokens types are wrapped in spans
16
+ # with the given class names. Other token types are not wrapped in spans.
17
+
18
+ def self.to_html(token_stream)
19
+ token_stream.map do |t|
20
+ next unless t
21
+
22
+ style = case t[:kind]
23
+ when :operator then 'ruby-operator'
24
+ when :keyword then 'ruby-keyword'
25
+ when :constant then 'ruby-constant'
26
+ when :ivar then 'ruby-ivar'
27
+ when :comment then 'ruby-comment'
28
+ when :value then 'ruby-value'
29
+ when :string then 'ruby-string'
30
+ when :symbol then 'ruby-value'
31
+ when :x_string then 'ruby-string'
32
+ when :regexp then 'ruby-regexp'
33
+ when :identifier then 'ruby-identifier'
34
+ end
35
+
36
+ text = t[:text]
37
+
38
+ text = CGI.escapeHTML text
39
+
40
+ if style
41
+ end_with_newline = text.end_with?("\n")
42
+ text = text.chomp if end_with_newline
43
+ "<span class=\"#{style}\">#{text}</span>#{"\n" if end_with_newline}"
44
+ else
45
+ text
46
+ end
47
+ end.join
48
+ end
49
+
50
+ ##
51
+ # Adds +tokens+ to the collected tokens
52
+
53
+ def add_tokens(tokens)
54
+ token_stream.concat(tokens)
55
+ end
56
+
57
+ ##
58
+ # Adds one +token+ to the collected tokens
59
+
60
+ def add_token(token)
61
+ token_stream.push(token)
62
+ end
63
+
64
+ ##
65
+ # Starts collecting tokens
66
+ #
67
+ # The optional +loader+ is called once on first access and its result is reused.
68
+
69
+ def collect_tokens(language, loader: nil)
70
+ @token_stream = []
71
+ @token_stream_loader = loader
72
+ @token_stream_language = language
73
+ end
74
+
75
+ alias start_collecting_tokens collect_tokens
76
+
77
+ ##
78
+ # Remove the last token from the collected tokens
79
+
80
+ def pop_token
81
+ token_stream.pop
82
+ end
83
+
84
+ ##
85
+ # Current token stream
86
+
87
+ def token_stream
88
+ if @token_stream_loader
89
+ @token_stream = @token_stream_loader.call
90
+ @token_stream_loader = nil
45
91
  end
46
- end.join
47
- end
48
-
49
- ##
50
- # Adds +tokens+ to the collected tokens
51
-
52
- def add_tokens(tokens)
53
- @token_stream.concat(tokens)
54
- end
92
+ @token_stream
93
+ end
55
94
 
56
- ##
57
- # Adds one +token+ to the collected tokens
95
+ ##
96
+ # Returns a string representation of the token stream
58
97
 
59
- def add_token(token)
60
- @token_stream.push(token)
61
- end
98
+ def tokens_to_s
99
+ (token_stream or return '').compact.map { |token| token[:text] }.join ''
100
+ end
62
101
 
63
- ##
64
- # Starts collecting tokens
65
- #
102
+ ##
103
+ # Returns the source language of the token stream as a string
104
+ #
105
+ # Returns 'c' or 'ruby'
66
106
 
67
- def collect_tokens(language)
68
- @token_stream = []
69
- @token_stream_language = language
70
- end
71
-
72
- alias start_collecting_tokens collect_tokens
73
-
74
- ##
75
- # Remove the last token from the collected tokens
107
+ def source_language
108
+ @token_stream_language == :c ? 'c' : 'ruby'
109
+ end
76
110
 
77
- def pop_token
78
- @token_stream.pop
79
111
  end
80
-
81
- ##
82
- # Current token stream
83
-
84
- def token_stream
85
- @token_stream
86
- end
87
-
88
- ##
89
- # Returns a string representation of the token stream
90
-
91
- def tokens_to_s
92
- (token_stream or return '').compact.map { |token| token[:text] }.join ''
93
- end
94
-
95
- ##
96
- # Returns the source language of the token stream as a string
97
- #
98
- # Returns 'c' or 'ruby'
99
-
100
- def source_language
101
- @token_stream_language == :c ? 'c' : 'ruby'
102
- end
103
-
104
112
  end