modl 0.3.22 → 0.3.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/grammar_tests/base_tests.json +10 -0
- data/lib/modl/parser/unicode_escapes.rb +45 -2
- data/lib/modl/parser/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6e08595e87f2b8fccd3ab9abfde857bd268bf2ca1c8fa1b00069d81c5644701
|
4
|
+
data.tar.gz: c725b89c8d561e3c84404f55d74c94d1fdf605474aa58c2fb5bc255255d7a816
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17d4f8fc520fb5cc16737ab869a52b1ee532b5050dc404153da7dd6c6f71f79befd6aaaddaf1857b41e317be763ca404851d8419d254041397f2cd6290ee1957
|
7
|
+
data.tar.gz: 6ba10d6e62a742b0c7ec38c2a82ab8f9231168a7d9ed8102ea45fe3a0f45209e2f753f980551de919eba18d7762c4dfc0ca1b3ee0530de40cfb7a90fed15c26b
|
data/CHANGELOG.md
CHANGED
@@ -3160,5 +3160,15 @@
|
|
3160
3160
|
"object_ref"
|
3161
3161
|
],
|
3162
3162
|
"minimised_modl": "_C=gb;_L=en;*load=\"http://modules.num.uk/1/rcf.txt!\";o(c[fb=abc;tw=abc])"
|
3163
|
+
},
|
3164
|
+
{
|
3165
|
+
"id": "332",
|
3166
|
+
"input": "test=~u1f60000",
|
3167
|
+
"expected_output": "{\n \"test\": \"\uD83D\uDE0000\"\n}",
|
3168
|
+
"tested_features": [
|
3169
|
+
"unicode",
|
3170
|
+
"escapes"
|
3171
|
+
],
|
3172
|
+
"minimised_modl": "test=\\~u1f60000"
|
3163
3173
|
}
|
3164
3174
|
]
|
@@ -55,15 +55,58 @@ module MODL
|
|
55
55
|
next if uni_str_idx > 0 && result[uni_str_idx - 1] == '~'
|
56
56
|
next if uni_str_idx > 0 && result[uni_str_idx - 1] == '\\'
|
57
57
|
|
58
|
-
value = result
|
58
|
+
(value, len) = try_parse(result, uni_str_idx + 2)
|
59
59
|
uni_val = value.chr(Encoding::UTF_8)
|
60
60
|
left = result.slice(0, uni_str_idx)
|
61
|
-
right = result.slice(uni_str_idx +
|
61
|
+
right = result.slice(uni_str_idx + (2 + len), result.length)
|
62
62
|
result = left + uni_val + right unless right.nil?
|
63
63
|
result = left + uni_val if right.nil?
|
64
64
|
end
|
65
65
|
result
|
66
66
|
end
|
67
|
+
|
68
|
+
def self.enough_digits?(str, idx, n)
|
69
|
+
i = 0
|
70
|
+
chars = str.chars
|
71
|
+
while i < n && (idx + i) < str.length
|
72
|
+
c = chars[idx + i]
|
73
|
+
unless (('0'..'9').include? c) || (('a'..'f').include? c) || (('A'..'F').include? c)
|
74
|
+
return false
|
75
|
+
end
|
76
|
+
i += 1
|
77
|
+
end
|
78
|
+
(i == n) ? true : false
|
79
|
+
end
|
80
|
+
|
81
|
+
# unicode can be 4 to 6 characters
|
82
|
+
def self.try_parse(str, idx)
|
83
|
+
if enough_digits?(str, idx, 6)
|
84
|
+
value = str.slice(idx, 6).to_i(16)
|
85
|
+
if valid_range? value
|
86
|
+
return [value, 6]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
if enough_digits?(str, idx, 5)
|
90
|
+
value = str.slice(idx, 5).to_i(16)
|
91
|
+
if valid_range? value
|
92
|
+
return [value, 5]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
if enough_digits?(str, idx, 4)
|
96
|
+
value = str.slice(idx, 4).to_i(16)
|
97
|
+
if valid_range? value
|
98
|
+
return [value, 4]
|
99
|
+
end
|
100
|
+
if valid_range? value
|
101
|
+
return [value, 4]
|
102
|
+
end
|
103
|
+
end
|
104
|
+
[0, 4]
|
105
|
+
end
|
106
|
+
|
107
|
+
def self.valid_range?(value)
|
108
|
+
return ((0x100000..0x10ffff).include? value) || ((0x10000..0xfffff).include? value) || ((0..0xd7ff).include? value) || ((0xe000..0xffff).include? value) ? true : false
|
109
|
+
end
|
67
110
|
end
|
68
111
|
end
|
69
112
|
end
|
data/lib/modl/parser/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: modl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Walmsley
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|