raldred-coderay 0.9.3391 → 0.9.3431
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.
data/lib/coderay/encoders/xml.rb
CHANGED
@@ -129,6 +129,7 @@ module Scanners
|
|
129
129
|
# TODO: keyword arguments
|
130
130
|
kind = :ident if last_token_dot
|
131
131
|
kind = check(/\(/) ? :ident : :keyword if kind == :old_keyword
|
132
|
+
kind = :ident if kind == :predefined && check(/=/)
|
132
133
|
|
133
134
|
elsif scan(/@[a-zA-Z0-9_.]+[lL]?/)
|
134
135
|
kind = :decorator
|
@@ -31,18 +31,18 @@ module Scanners
|
|
31
31
|
add(RESERVED_WORDS, :reserved).
|
32
32
|
add(PREDEFINED_CONSTANTS, :pre_constant)
|
33
33
|
|
34
|
-
IDENT = /[
|
34
|
+
IDENT = /[^\W\d]\w*/
|
35
35
|
|
36
36
|
METHOD_NAME = / #{IDENT} [?!]? /ox
|
37
37
|
METHOD_NAME_OPERATOR = /
|
38
38
|
\*\*? # multiplication and power
|
39
|
-
| [-+~]@? # plus, minus, tilde with and without
|
40
|
-
| [\/%&|^`] # division, modulo or format strings,
|
39
|
+
| [-+~]@? # plus, minus, tilde with and without at sign
|
40
|
+
| [\/%&|^`] # division, modulo or format strings, and, or, xor, system
|
41
41
|
| \[\]=? # array getter and setter
|
42
42
|
| << | >> # append or shift left, shift right
|
43
43
|
| <=?>? | >=? # comparison, rocket operator
|
44
44
|
| ===? | =~ # simple equality, case equality, match
|
45
|
-
| ![~=@]? # negation with and without
|
45
|
+
| ![~=@]? # negation with and without at sign, not-equal and not-match
|
46
46
|
/ox
|
47
47
|
METHOD_NAME_EX = / #{IDENT} (?:[?!]|=(?!>))? | #{METHOD_NAME_OPERATOR} /ox
|
48
48
|
INSTANCE_VARIABLE = / @ #{IDENT} /ox
|
@@ -21,6 +21,10 @@ module Scanners
|
|
21
21
|
file_extension 'rb'
|
22
22
|
|
23
23
|
helper :patterns
|
24
|
+
|
25
|
+
if not defined? EncodingError
|
26
|
+
EncodingError = Class.new Exception
|
27
|
+
end
|
24
28
|
|
25
29
|
private
|
26
30
|
def scan_tokens tokens, options
|
@@ -31,9 +35,10 @@ module Scanners
|
|
31
35
|
state = :initial
|
32
36
|
depth = nil
|
33
37
|
inline_block_stack = []
|
34
|
-
|
38
|
+
unicode = string.respond_to?(:encoding) && string.encoding.name == 'UTF-8'
|
39
|
+
|
35
40
|
patterns = Patterns # avoid constant lookup
|
36
|
-
|
41
|
+
|
37
42
|
until eos?
|
38
43
|
match = nil
|
39
44
|
kind = nil
|
@@ -161,7 +166,8 @@ module Scanners
|
|
161
166
|
elsif state == :initial
|
162
167
|
|
163
168
|
# IDENTS #
|
164
|
-
if match = scan(/#{patterns::METHOD_NAME}/
|
169
|
+
if match = scan(unicode ? /#{patterns::METHOD_NAME}/uo :
|
170
|
+
/#{patterns::METHOD_NAME}/o)
|
165
171
|
if last_token_dot
|
166
172
|
kind = if match[/^[A-Z]/] and not match?(/\(/) then :constant else :ident end
|
167
173
|
else
|
@@ -175,7 +181,7 @@ module Scanners
|
|
175
181
|
## experimental!
|
176
182
|
value_expected = :set if check(/#{patterns::VALUE_FOLLOWS}/o)
|
177
183
|
|
178
|
-
elsif last_token_dot and match = scan(/#{patterns::METHOD_NAME_OPERATOR}/o)
|
184
|
+
elsif last_token_dot and match = scan(/#{patterns::METHOD_NAME_OPERATOR}|\(/o)
|
179
185
|
kind = :ident
|
180
186
|
value_expected = :set if check(/#{patterns::VALUE_FOLLOWS}/o)
|
181
187
|
|
@@ -281,13 +287,19 @@ module Scanners
|
|
281
287
|
|
282
288
|
else
|
283
289
|
kind = :error
|
284
|
-
match = getch
|
290
|
+
match = (scan(/./mu) rescue nil) || getch
|
291
|
+
if !unicode && match.size > 1
|
292
|
+
unicode = true
|
293
|
+
unscan
|
294
|
+
next
|
295
|
+
end
|
285
296
|
|
286
297
|
end
|
287
298
|
|
288
299
|
elsif state == :def_expected
|
289
300
|
state = :initial
|
290
|
-
if match = scan(/(?>#{patterns::METHOD_NAME_EX})(?!\.|::)/
|
301
|
+
if match = scan(unicode ? /(?>#{patterns::METHOD_NAME_EX})(?!\.|::)/uo :
|
302
|
+
/(?>#{patterns::METHOD_NAME_EX})(?!\.|::)/o)
|
291
303
|
kind = :method
|
292
304
|
else
|
293
305
|
next
|
@@ -327,7 +339,14 @@ module Scanners
|
|
327
339
|
end
|
328
340
|
|
329
341
|
elsif state == :alias_expected
|
330
|
-
|
342
|
+
begin
|
343
|
+
match = scan(unicode ? /(#{patterns::METHOD_NAME_OR_SYMBOL})([ \t]+)(#{patterns::METHOD_NAME_OR_SYMBOL})/uo :
|
344
|
+
/(#{patterns::METHOD_NAME_OR_SYMBOL})([ \t]+)(#{patterns::METHOD_NAME_OR_SYMBOL})/o)
|
345
|
+
rescue EncodingError
|
346
|
+
raise if $DEBUG
|
347
|
+
end
|
348
|
+
|
349
|
+
if match
|
331
350
|
tokens << [self[1], (self[1][0] == ?: ? :symbol : :method)]
|
332
351
|
tokens << [self[2], :space]
|
333
352
|
tokens << [self[3], (self[3][0] == ?: ? :symbol : :method)]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: raldred-coderay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3431
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- murphy
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-06-09 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|