coderay 1.0.0 → 1.0.0.598.pre

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 (79) hide show
  1. data/FOLDERS +49 -0
  2. data/Rakefile +6 -5
  3. data/bin/coderay +74 -190
  4. data/bin/coderay_stylesheet +4 -0
  5. data/{README_INDEX.rdoc → lib/README} +20 -10
  6. data/lib/coderay.rb +60 -62
  7. data/lib/coderay/duo.rb +55 -2
  8. data/lib/coderay/encoder.rb +39 -52
  9. data/lib/coderay/encoders/_map.rb +7 -11
  10. data/lib/coderay/encoders/comment_filter.rb +61 -0
  11. data/lib/coderay/encoders/count.rb +26 -11
  12. data/lib/coderay/encoders/debug.rb +60 -11
  13. data/lib/coderay/encoders/div.rb +8 -9
  14. data/lib/coderay/encoders/filter.rb +52 -12
  15. data/lib/coderay/encoders/html.rb +113 -106
  16. data/lib/coderay/encoders/html/css.rb +7 -2
  17. data/lib/coderay/encoders/html/numbering.rb +27 -24
  18. data/lib/coderay/encoders/html/output.rb +58 -15
  19. data/lib/coderay/encoders/json.rb +44 -37
  20. data/lib/coderay/encoders/lines_of_code.rb +56 -9
  21. data/lib/coderay/encoders/null.rb +13 -6
  22. data/lib/coderay/encoders/page.rb +8 -8
  23. data/lib/coderay/encoders/span.rb +9 -10
  24. data/lib/coderay/encoders/statistic.rb +114 -51
  25. data/lib/coderay/encoders/terminal.rb +10 -7
  26. data/lib/coderay/encoders/text.rb +36 -17
  27. data/lib/coderay/encoders/token_kind_filter.rb +58 -1
  28. data/lib/coderay/encoders/xml.rb +11 -13
  29. data/lib/coderay/encoders/yaml.rb +14 -16
  30. data/lib/coderay/for_redcloth.rb +1 -1
  31. data/lib/coderay/helpers/file_type.rb +240 -125
  32. data/lib/coderay/helpers/gzip_simple.rb +123 -0
  33. data/lib/coderay/helpers/plugin.rb +307 -241
  34. data/lib/coderay/helpers/word_list.rb +126 -65
  35. data/lib/coderay/scanner.rb +103 -153
  36. data/lib/coderay/scanners/_map.rb +16 -18
  37. data/lib/coderay/scanners/c.rb +13 -13
  38. data/lib/coderay/scanners/cpp.rb +6 -6
  39. data/lib/coderay/scanners/css.rb +48 -47
  40. data/lib/coderay/scanners/debug.rb +55 -9
  41. data/lib/coderay/scanners/delphi.rb +4 -4
  42. data/lib/coderay/scanners/diff.rb +25 -43
  43. data/lib/coderay/scanners/groovy.rb +2 -2
  44. data/lib/coderay/scanners/html.rb +30 -107
  45. data/lib/coderay/scanners/java.rb +5 -6
  46. data/lib/coderay/scanners/java/builtin_types.rb +0 -2
  47. data/lib/coderay/scanners/java_script.rb +6 -6
  48. data/lib/coderay/scanners/json.rb +6 -7
  49. data/lib/coderay/scanners/nitro_xhtml.rb +136 -0
  50. data/lib/coderay/scanners/php.rb +12 -13
  51. data/lib/coderay/scanners/plaintext.rb +26 -0
  52. data/lib/coderay/scanners/python.rb +4 -4
  53. data/lib/coderay/scanners/{erb.rb → rhtml.rb} +11 -19
  54. data/lib/coderay/scanners/ruby.rb +208 -219
  55. data/lib/coderay/scanners/ruby/patterns.rb +85 -18
  56. data/lib/coderay/scanners/scheme.rb +136 -0
  57. data/lib/coderay/scanners/sql.rb +22 -29
  58. data/lib/coderay/scanners/yaml.rb +10 -11
  59. data/lib/coderay/styles/_map.rb +2 -2
  60. data/lib/coderay/styles/alpha.rb +104 -102
  61. data/lib/coderay/styles/cycnus.rb +143 -0
  62. data/lib/coderay/styles/murphy.rb +123 -0
  63. data/lib/coderay/token_kinds.rb +86 -87
  64. data/lib/coderay/tokens.rb +169 -26
  65. data/test/functional/basic.rb +14 -200
  66. data/test/functional/examples.rb +14 -20
  67. data/test/functional/for_redcloth.rb +8 -15
  68. data/test/functional/load_plugin_scanner.rb +11 -0
  69. data/test/functional/suite.rb +6 -9
  70. data/test/functional/vhdl.rb +126 -0
  71. data/test/functional/word_list.rb +79 -0
  72. metadata +129 -107
  73. data/lib/coderay/helpers/gzip.rb +0 -41
  74. data/lib/coderay/scanners/clojure.rb +0 -217
  75. data/lib/coderay/scanners/haml.rb +0 -168
  76. data/lib/coderay/scanners/ruby/string_state.rb +0 -71
  77. data/lib/coderay/scanners/text.rb +0 -26
  78. data/lib/coderay/tokens_proxy.rb +0 -55
  79. data/lib/coderay/version.rb +0 -3
@@ -9,7 +9,7 @@ module Scanners
9
9
  register_for :delphi
10
10
  file_extension 'pas'
11
11
 
12
- KEYWORDS = [
12
+ RESERVED_WORDS = [
13
13
  'and', 'array', 'as', 'at', 'asm', 'at', 'begin', 'case', 'class',
14
14
  'const', 'constructor', 'destructor', 'dispinterface', 'div', 'do',
15
15
  'downto', 'else', 'end', 'except', 'exports', 'file', 'finalization',
@@ -33,11 +33,11 @@ module Scanners
33
33
  'virtual', 'write', 'writeonly',
34
34
  ] # :nodoc:
35
35
 
36
- IDENT_KIND = WordList::CaseIgnoring.new(:ident).
37
- add(KEYWORDS, :keyword).
36
+ IDENT_KIND = CaseIgnoringWordList.new(:ident).
37
+ add(RESERVED_WORDS, :reserved).
38
38
  add(DIRECTIVES, :directive) # :nodoc:
39
39
 
40
- NAME_FOLLOWS = WordList::CaseIgnoring.new(false).
40
+ NAME_FOLLOWS = CaseIgnoringWordList.new(false).
41
41
  add(%w(procedure function .)) # :nodoc:
42
42
 
43
43
  protected
@@ -11,7 +11,7 @@ module Scanners
11
11
 
12
12
  DEFAULT_OPTIONS = {
13
13
  :highlight_code => true,
14
- :inline_diff => true,
14
+ :inline_diff => true,
15
15
  }
16
16
 
17
17
  protected
@@ -50,9 +50,7 @@ module Scanners
50
50
  if match = scan(/.*?(?=$|[\t\n\x00]| \(revision)/)
51
51
  encoder.text_token match, :filename
52
52
  if options[:highlight_code]
53
- file_type = FileType.fetch(match, :text)
54
- file_type = :text if file_type == :diff
55
- content_scanner = scanners[file_type]
53
+ content_scanner = scanners[FileType.fetch(match, :plaintext)]
56
54
  content_scanner_entry_state = nil
57
55
  end
58
56
  end
@@ -69,10 +67,13 @@ module Scanners
69
67
  next unless match = scan(/.+/)
70
68
  encoder.text_token match, :plain
71
69
  state = :added
72
- elsif match = scan(/\\ .*/)
73
- encoder.text_token match, :comment
70
+ elsif match = scan(/\\ /)
71
+ encoder.begin_line line_kind = :change
72
+ encoder.text_token match, :change
73
+ next unless match = scan(/.+/)
74
+ encoder.text_token match, :plain
74
75
  elsif match = scan(/@@(?>[^@\n]*)@@/)
75
- content_scanner.state = :initial unless match?(/\n\+/)
76
+ content_scanner.instance_variable_set(:@state, :initial) unless match?(/\n\+/)
76
77
  content_scanner_entry_state = nil
77
78
  if check(/\n|$/)
78
79
  encoder.begin_line line_kind = :change
@@ -80,7 +81,7 @@ module Scanners
80
81
  encoder.begin_group :change
81
82
  end
82
83
  encoder.text_token match[0,2], :change
83
- encoder.text_token match[2...-2], :plain
84
+ encoder.text_token match[2...-2], :plain if match.size > 4
84
85
  encoder.text_token match[-2,2], :change
85
86
  encoder.end_group :change unless line_kind
86
87
  next unless match = scan(/.+/)
@@ -105,39 +106,36 @@ module Scanners
105
106
  encoder.begin_line line_kind = :delete
106
107
  encoder.text_token match, :delete
107
108
  if options[:inline_diff] && deleted_lines == 1 && check(/(?>.*)\n\+(?>.*)$(?!\n\+)/)
108
- content_scanner_entry_state = content_scanner.state
109
- skip(/(.*)\n\+(.*)$/)
110
- head, deletion, insertion, tail = diff self[1], self[2]
111
- pre, deleted, post = content_scanner.tokenize [head, deletion, tail], :tokens => Tokens.new
112
- encoder.tokens pre
113
- unless deleted.empty?
114
- encoder.begin_group :eyecatcher
115
- encoder.tokens deleted
116
- encoder.end_group :eyecatcher
109
+ if content_scanner.instance_variable_defined?(:@state)
110
+ content_scanner_entry_state = content_scanner.instance_variable_get(:@state)
117
111
  end
112
+ skip(/(.*)(.*?)(.*)\n\+\1(.*)\3$/)
113
+ pre, deleted, post = content_scanner.tokenize [self[1], self[2], self[3]], :tokens => Tokens.new
114
+ encoder.tokens pre
115
+ encoder.begin_group :eyecatcher
116
+ encoder.tokens deleted
117
+ encoder.end_group :eyecatcher
118
118
  encoder.tokens post
119
119
  encoder.end_line line_kind
120
120
  encoder.text_token "\n", :space
121
121
  encoder.begin_line line_kind = :insert
122
122
  encoder.text_token '+', :insert
123
- content_scanner.state = content_scanner_entry_state || :initial
124
- pre, inserted, post = content_scanner.tokenize [head, insertion, tail], :tokens => Tokens.new
123
+ content_scanner.instance_variable_set(:@state, content_scanner_entry_state || :initial)
124
+ pre, inserted, post = content_scanner.tokenize [self[1], self[4], self[3]], :tokens => Tokens.new
125
125
  encoder.tokens pre
126
- unless inserted.empty?
127
- encoder.begin_group :eyecatcher
128
- encoder.tokens inserted
129
- encoder.end_group :eyecatcher
130
- end
126
+ encoder.begin_group :eyecatcher
127
+ encoder.tokens inserted
128
+ encoder.end_group :eyecatcher
131
129
  encoder.tokens post
132
130
  elsif match = scan(/.*/)
133
131
  if options[:highlight_code]
134
- if deleted_lines == 1
135
- content_scanner_entry_state = content_scanner.state
132
+ if deleted_lines == 1 && content_scanner.instance_variable_defined?(:@state)
133
+ content_scanner_entry_state = content_scanner.instance_variable_get(:@state)
136
134
  end
137
135
  content_scanner.tokenize match, :tokens => encoder unless match.empty?
138
136
  if !match?(/\n-/)
139
137
  if match?(/\n\+/)
140
- content_scanner.state = content_scanner_entry_state || :initial
138
+ content_scanner.instance_variable_set(:@state, content_scanner_entry_state || :initial)
141
139
  end
142
140
  content_scanner_entry_state = nil
143
141
  end
@@ -179,22 +177,6 @@ module Scanners
179
177
  encoder
180
178
  end
181
179
 
182
- private
183
-
184
- def diff a, b
185
- # i will be the index of the leftmost difference from the left.
186
- i_max = [a.size, b.size].min
187
- i = 0
188
- i += 1 while i < i_max && a[i] == b[i]
189
- # j_min will be the index of the leftmost difference from the right.
190
- j_min = i - i_max
191
- # j will be the index of the rightmost difference from the right which
192
- # does not precede the leftmost one from the left.
193
- j = -1
194
- j -= 1 while j >= j_min && a[j] == b[j]
195
- return a[0...i], a[i..j], b[i..j], (j < -1) ? a[j+1..-1] : ''
196
- end
197
-
198
180
  end
199
181
 
200
182
  end
@@ -130,7 +130,7 @@ module Scanners
130
130
  if match = scan(/0[xX][0-9A-Fa-f]+/)
131
131
  encoder.text_token match, :hex
132
132
  elsif match = scan(/(?>0[0-7]+)(?![89.eEfF])/)
133
- encoder.text_token match, :octal
133
+ encoder.text_token match, :oct
134
134
  elsif match = scan(/\d+[fFdD]|\d*\.\d+(?:[eE][+-]?\d+)?[fFdD]?|\d+[eE][+-]?\d+[fFdD]?/)
135
135
  encoder.text_token match, :float
136
136
  elsif match = scan(/\d+[lLgG]?/)
@@ -220,7 +220,7 @@ module Scanners
220
220
  encoder.text_token match, :content
221
221
 
222
222
  elsif match = scan(/ \\. /mx)
223
- encoder.text_token match, :content # TODO: Shouldn't this be :error?
223
+ encoder.text_token match, :content # FIXME: Shouldn't this be :error?
224
224
 
225
225
  elsif match = scan(/ \\ | \n /x)
226
226
  encoder.end_group state
@@ -13,28 +13,10 @@ module Scanners
13
13
  KINDS_NOT_LOC = [
14
14
  :comment, :doctype, :preprocessor,
15
15
  :tag, :attribute_name, :operator,
16
- :attribute_value, :string,
16
+ :attribute_value, :delimiter, :content,
17
17
  :plain, :entity, :error,
18
18
  ] # :nodoc:
19
19
 
20
- EVENT_ATTRIBUTES = %w(
21
- onabort onafterprint onbeforeprint onbeforeunload onblur oncanplay
22
- oncanplaythrough onchange onclick oncontextmenu oncuechange ondblclick
23
- ondrag ondragdrop ondragend ondragenter ondragleave ondragover
24
- ondragstart ondrop ondurationchange onemptied onended onerror onfocus
25
- onformchange onforminput onhashchange oninput oninvalid onkeydown
26
- onkeypress onkeyup onload onloadeddata onloadedmetadata onloadstart
27
- onmessage onmousedown onmousemove onmouseout onmouseover onmouseup
28
- onmousewheel onmove onoffline ononline onpagehide onpageshow onpause
29
- onplay onplaying onpopstate onprogress onratechange onreadystatechange
30
- onredo onreset onresize onscroll onseeked onseeking onselect onshow
31
- onstalled onstorage onsubmit onsuspend ontimeupdate onundo onunload
32
- onvolumechange onwaiting
33
- )
34
-
35
- IN_ATTRIBUTE = WordList::CaseIgnoring.new(nil).
36
- add(EVENT_ATTRIBUTES, :script)
37
-
38
20
  ATTR_NAME = /[\w.:-]+/ # :nodoc:
39
21
  TAG_END = /\/?>/ # :nodoc:
40
22
  HEX = /[0-9a-fA-F]/ # :nodoc:
@@ -58,10 +40,10 @@ module Scanners
58
40
  '"' => /[^&">\n]+/,
59
41
  } # :nodoc:
60
42
 
61
- def reset
43
+ def reset # :nodoc:
44
+ # FIXME: why not overwrite reset_instance?
62
45
  super
63
46
  @state = :initial
64
- @plain_string_content = nil
65
47
  end
66
48
 
67
49
  protected
@@ -71,25 +53,14 @@ module Scanners
71
53
  @plain_string_content = nil
72
54
  end
73
55
 
74
- def scan_java_script encoder, code
75
- if code && !code.empty?
76
- @java_script_scanner ||= Scanners::JavaScript.new '', :keep_tokens => true
77
- # encoder.begin_group :inline
78
- @java_script_scanner.tokenize code, :tokens => encoder
79
- # encoder.end_group :inline
80
- end
81
- end
82
-
83
56
  def scan_tokens encoder, options
84
- state = options[:state] || @state
85
- plain_string_content = @plain_string_content
86
- in_tag = in_attribute = nil
87
57
 
88
- encoder.begin_group :string if state == :attribute_value_string
58
+ state = @state
59
+ plain_string_content = @plain_string_content
89
60
 
90
61
  until eos?
91
62
 
92
- if state != :in_special_tag && match = scan(/\s+/m)
63
+ if match = scan(/\s+/m)
93
64
  encoder.text_token match, :space
94
65
 
95
66
  else
@@ -97,61 +68,49 @@ module Scanners
97
68
  case state
98
69
 
99
70
  when :initial
100
- if match = scan(/<!--(?:.*?-->|.*)/m)
71
+ if match = scan(/<!--.*?-->/m)
101
72
  encoder.text_token match, :comment
102
- elsif match = scan(/<!DOCTYPE(?:.*?>|.*)/m)
73
+ elsif match = scan(/<!DOCTYPE.*?>/m)
103
74
  encoder.text_token match, :doctype
104
- elsif match = scan(/<\?xml(?:.*?\?>|.*)/m)
75
+ elsif match = scan(/<\?xml.*?\?>/m)
105
76
  encoder.text_token match, :preprocessor
106
- elsif match = scan(/<\?(?:.*?\?>|.*)/m)
77
+ elsif match = scan(/<\?.*?\?>|<%.*?%>/m)
107
78
  encoder.text_token match, :comment
108
- elsif match = scan(/<\/[-\w.:]*>?/m)
109
- in_tag = nil
79
+ elsif match = scan(/<\/[-\w.:]*>/m)
110
80
  encoder.text_token match, :tag
111
- elsif match = scan(/<(?:(script)|[-\w.:]+)(>)?/m)
81
+ elsif match = scan(/<[-\w.:]+>?/m)
112
82
  encoder.text_token match, :tag
113
- in_tag = self[1]
114
- if self[2]
115
- state = :in_special_tag if in_tag
116
- else
117
- state = :attribute
118
- end
83
+ state = :attribute unless match[-1] == ?>
119
84
  elsif match = scan(/[^<>&]+/)
120
85
  encoder.text_token match, :plain
121
86
  elsif match = scan(/#{ENTITY}/ox)
122
87
  encoder.text_token match, :entity
123
88
  elsif match = scan(/[<>&]/)
124
- in_tag = nil
125
89
  encoder.text_token match, :error
126
90
  else
127
91
  raise_inspect '[BUG] else-case reached with state %p' % [state], encoder
128
92
  end
129
93
 
130
94
  when :attribute
131
- if match = scan(/#{TAG_END}/o)
95
+ if match = scan(/#{TAG_END}/)
132
96
  encoder.text_token match, :tag
133
- in_attribute = nil
134
- if in_tag
135
- state = :in_special_tag
136
- else
137
- state = :initial
138
- end
97
+ state = :initial
139
98
  elsif match = scan(/#{ATTR_NAME}/o)
140
- in_attribute = IN_ATTRIBUTE[match]
141
99
  encoder.text_token match, :attribute_name
142
100
  state = :attribute_equal
143
101
  else
144
- in_tag = nil
145
102
  encoder.text_token getch, :error
146
103
  end
147
104
 
148
105
  when :attribute_equal
149
- if match = scan(/=/) #/
106
+ if match = scan(/=/)
150
107
  encoder.text_token match, :operator
151
108
  state = :attribute_value
152
- elsif scan(/#{ATTR_NAME}/o) || scan(/#{TAG_END}/o)
153
- state = :attribute
154
- next
109
+ elsif match = scan(/#{ATTR_NAME}/o)
110
+ encoder.text_token match, :attribute_name
111
+ elsif match = scan(/#{TAG_END}/o)
112
+ encoder.text_token match, :tag
113
+ state = :initial
155
114
  else
156
115
  encoder.text_token getch, :error
157
116
  state = :attribute
@@ -162,26 +121,11 @@ module Scanners
162
121
  encoder.text_token match, :attribute_value
163
122
  state = :attribute
164
123
  elsif match = scan(/["']/)
165
- if in_attribute == :script
166
- encoder.begin_group :inline
167
- encoder.text_token match, :inline_delimiter
168
- if scan(/javascript:[ \t]*/)
169
- encoder.text_token matched, :comment
170
- end
171
- code = scan_until(match == '"' ? /(?="|\z)/ : /(?='|\z)/)
172
- scan_java_script encoder, code
173
- match = scan(/["']/)
174
- encoder.text_token match, :inline_delimiter if match
175
- encoder.end_group :inline
176
- state = :attribute
177
- in_attribute = nil
178
- else
179
- encoder.begin_group :string
180
- state = :attribute_value_string
181
- plain_string_content = PLAIN_STRING_CONTENT[match]
182
- encoder.text_token match, :delimiter
183
- end
184
- elsif match = scan(/#{TAG_END}/o)
124
+ encoder.begin_group :string
125
+ state = :attribute_value_string
126
+ plain_string_content = PLAIN_STRING_CONTENT[match]
127
+ encoder.text_token match, :delimiter
128
+ elsif scan(/#{TAG_END}/o)
185
129
  encoder.text_token match, :tag
186
130
  state = :initial
187
131
  else
@@ -205,29 +149,6 @@ module Scanners
205
149
  encoder.text_token match, :error
206
150
  end
207
151
 
208
- when :in_special_tag
209
- case in_tag
210
- when 'script'
211
- encoder.text_token match, :space if match = scan(/[ \t]*\n/)
212
- if scan(/(\s*<!--)(?:(.*?)(-->)|(.*))/m)
213
- code = self[2] || self[4]
214
- closing = self[3]
215
- encoder.text_token self[1], :comment
216
- else
217
- code = scan_until(/(?=(?:\n\s*)?<\/script>)|\z/)
218
- closing = false
219
- end
220
- unless code.empty?
221
- encoder.begin_group :inline
222
- scan_java_script encoder, code
223
- encoder.end_group :inline
224
- end
225
- encoder.text_token closing, :comment if closing
226
- state = :initial
227
- else
228
- raise 'unknown special tag: %p' % [in_tag]
229
- end
230
-
231
152
  else
232
153
  raise_inspect 'Unknown state: %p' % [state], encoder
233
154
 
@@ -240,10 +161,12 @@ module Scanners
240
161
  if options[:keep_state]
241
162
  @state = state
242
163
  @plain_string_content = plain_string_content
164
+ else
165
+ if state == :attribute_value_string
166
+ encoder.end_group :string
167
+ end
243
168
  end
244
169
 
245
- encoder.end_group :string if state == :attribute_value_string
246
-
247
170
  encoder
248
171
  end
249
172
 
@@ -3,10 +3,9 @@ module Scanners
3
3
 
4
4
  # Scanner for Java.
5
5
  class Java < Scanner
6
-
6
+
7
7
  register_for :java
8
-
9
- autoload :BuiltinTypes, 'coderay/scanners/java/builtin_types'
8
+ helper :builtin_types
10
9
 
11
10
  # http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html
12
11
  KEYWORDS = %w[
@@ -30,10 +29,10 @@ module Scanners
30
29
  IDENT_KIND = WordList.new(:ident).
31
30
  add(KEYWORDS, :keyword).
32
31
  add(RESERVED, :reserved).
33
- add(CONSTANTS, :predefined_constant).
32
+ add(CONSTANTS, :pre_constant).
34
33
  add(MAGIC_VARIABLES, :local_variable).
35
34
  add(TYPES, :type).
36
- add(BuiltinTypes::List, :predefined_type).
35
+ add(BuiltinTypes::List, :pre_type).
37
36
  add(BuiltinTypes::List.select { |builtin| builtin[/(Error|Exception)$/] }, :exception).
38
37
  add(DIRECTIVES, :directive) # :nodoc:
39
38
 
@@ -107,7 +106,7 @@ module Scanners
107
106
  if match = scan(/0[xX][0-9A-Fa-f]+/)
108
107
  encoder.text_token match, :hex
109
108
  elsif match = scan(/(?>0[0-7]+)(?![89.eEfF])/)
110
- encoder.text_token match, :octal
109
+ encoder.text_token match, :oct
111
110
  elsif match = scan(/\d+[fFdD]|\d*\.\d+(?:[eE][+-]?\d+)?[fFdD]?|\d+[eE][+-]?\d+[fFdD]?/)
112
111
  encoder.text_token match, :float
113
112
  elsif match = scan(/\d+[lL]?/)
@@ -3,7 +3,6 @@ module Scanners
3
3
 
4
4
  module Java::BuiltinTypes # :nodoc:
5
5
 
6
- #:nocov:
7
6
  List = %w[
8
7
  AbstractAction AbstractBorder AbstractButton AbstractCellEditor AbstractCollection
9
8
  AbstractColorChooserPanel AbstractDocument AbstractExecutorService AbstractInterruptibleChannel
@@ -413,7 +412,6 @@ module Scanners
413
412
  XPathFactoryConfigurationException XPathFunction XPathFunctionException XPathFunctionResolver
414
413
  XPathVariableResolver ZipEntry ZipException ZipFile ZipInputStream ZipOutputStream ZoneView
415
414
  ]
416
- #:nocov:
417
415
 
418
416
  end
419
417
 
@@ -35,7 +35,7 @@ module Scanners
35
35
 
36
36
  IDENT_KIND = WordList.new(:ident).
37
37
  add(RESERVED_WORDS, :reserved).
38
- add(PREDEFINED_CONSTANTS, :predefined_constant).
38
+ add(PREDEFINED_CONSTANTS, :pre_constant).
39
39
  add(MAGIC_VARIABLES, :local_variable).
40
40
  add(KEYWORDS, :keyword) # :nodoc:
41
41
 
@@ -48,8 +48,8 @@ module Scanners
48
48
  '/' => /[^\\\/]+/,
49
49
  } # :nodoc:
50
50
  KEY_CHECK_PATTERN = {
51
- "'" => / (?> [^\\']* (?: \\. [^\\']* )* ) ' \s* : /mx,
52
- '"' => / (?> [^\\"]* (?: \\. [^\\"]* )* ) " \s* : /mx,
51
+ "'" => / [^\\']* (?: \\.? [^\\']* )* '? \s* : /x,
52
+ '"' => / [^\\"]* (?: \\.? [^\\"]* )* "? \s* : /x,
53
53
  } # :nodoc:
54
54
 
55
55
  protected
@@ -81,7 +81,7 @@ module Scanners
81
81
  if match = scan(/0[xX][0-9A-Fa-f]+/)
82
82
  encoder.text_token match, :hex
83
83
  elsif match = scan(/(?>0[0-7]+)(?![89.eEfF])/)
84
- encoder.text_token match, :octal
84
+ encoder.text_token match, :oct
85
85
  elsif match = scan(/\d+[fF]|\d*\.\d+(?:[eE][+-]?\d+)?[fF]?|\d+[eE][+-]?\d+[fF]?/)
86
86
  encoder.text_token match, :float
87
87
  elsif match = scan(/\d+/)
@@ -89,7 +89,7 @@ module Scanners
89
89
  end
90
90
 
91
91
  elsif value_expected && match = scan(/<([[:alpha:]]\w*) (?: [^\/>]*\/> | .*?<\/\1>)/xim)
92
- # TODO: scan over nested tags
92
+ # FIXME: scan over nested tags
93
93
  xml_scanner.tokenize match, :tokens => encoder
94
94
  value_expected = false
95
95
  next
@@ -134,7 +134,7 @@ module Scanners
134
134
  string_delimiter = match
135
135
  encoder.text_token match, :delimiter
136
136
 
137
- elsif value_expected && (match = scan(/\//))
137
+ elsif value_expected && (match = scan(/\/(?=\S)/))
138
138
  encoder.begin_group :regexp
139
139
  state = :regexp
140
140
  string_delimiter = '/'