parser 2.0.0.pre7 → 2.0.0.pre8
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +1 -6
- data/Rakefile +1 -1
- data/lib/parser/lexer.rl +12 -9
- data/lib/parser/lexer/literal.rb +4 -5
- data/lib/parser/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 784e6ea2b211d0e66b2c9b557ac575c2f7204444
|
4
|
+
data.tar.gz: 381fae65cbb0abd8400e382c8bf926221f74929f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 720ec8f90cb16e1e38ddd02006afe4dda5ca2c9ccf31087a0906cafd406ba6865e57d5545be81f64dd17cc710c33d108e73476742475264147049d034c97c6c4
|
7
|
+
data.tar.gz: f0b89adbfa47c7ba825c9d54df1d32cb0c81dec28866caea61baebd77290eb860317f3e357c10f4953056b9b1339085d0b9f2bd418848de46053b961044479c0
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -15,12 +15,7 @@ Sponsored by [Evil Martians](http://evilmartians.com).
|
|
15
15
|
|
16
16
|
## Installation
|
17
17
|
|
18
|
-
|
19
|
-
[release schedule](https://github.com/whitequark/parser/issues/51), it stays in
|
20
|
-
the beta status for a while. However, it handles much more input than stable
|
21
|
-
1.x branch, and for new work it is advisable to use the beta versions.
|
22
|
-
|
23
|
-
$ gem install parser --pre
|
18
|
+
$ gem install parser -v=2.0
|
24
19
|
|
25
20
|
## Usage
|
26
21
|
|
data/Rakefile
CHANGED
data/lib/parser/lexer.rl
CHANGED
@@ -157,7 +157,17 @@ class Parser::Lexer
|
|
157
157
|
@source_buffer = source_buffer
|
158
158
|
|
159
159
|
if @source_buffer
|
160
|
-
@source = @source_buffer.source
|
160
|
+
@source = @source_buffer.source
|
161
|
+
|
162
|
+
if defined?(Encoding)
|
163
|
+
@encoding = @source.encoding
|
164
|
+
|
165
|
+
# This is a workaround for 1.9.2, which (without force_encoding)
|
166
|
+
# would convert the result to UTF-8 (source encoding of lexer.rl).
|
167
|
+
@source += "\0".force_encoding(@encoding)
|
168
|
+
else
|
169
|
+
@source += "\0"
|
170
|
+
end
|
161
171
|
|
162
172
|
if defined?(Encoding) && @source.encoding == Encoding::UTF_8
|
163
173
|
@source_pts = @source.unpack('U*')
|
@@ -165,10 +175,6 @@ class Parser::Lexer
|
|
165
175
|
@source_pts = @source.unpack('C*')
|
166
176
|
end
|
167
177
|
|
168
|
-
if defined?(Encoding)
|
169
|
-
@encoding = @source.encoding
|
170
|
-
end
|
171
|
-
|
172
178
|
if @source_pts.size > 1_000_000 && @source.respond_to?(:encode)
|
173
179
|
# A heuristic: if the buffer is larger than 1M, then
|
174
180
|
# store it in UTF-32 and convert the tokens as they're
|
@@ -229,11 +235,8 @@ class Parser::Lexer
|
|
229
235
|
|
230
236
|
# Ugly, but dependent on Ragel output. Consider refactoring it somehow.
|
231
237
|
_lex_trans_keys = self.class.send :_lex_trans_keys
|
232
|
-
|
233
|
-
_lex_key_offsets = self.class.send :_lex_key_offsets
|
238
|
+
_lex_key_spans = self.class.send :_lex_key_spans
|
234
239
|
_lex_index_offsets = self.class.send :_lex_index_offsets
|
235
|
-
_lex_single_lengths = self.class.send :_lex_single_lengths
|
236
|
-
_lex_range_lengths = self.class.send :_lex_range_lengths
|
237
240
|
_lex_indicies = self.class.send :_lex_indicies
|
238
241
|
_lex_trans_targs = self.class.send :_lex_trans_targs
|
239
242
|
_lex_trans_actions = self.class.send :_lex_trans_actions
|
data/lib/parser/lexer/literal.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# encoding:
|
1
|
+
# encoding: binary
|
2
2
|
|
3
3
|
module Parser
|
4
4
|
|
@@ -40,8 +40,8 @@ module Parser
|
|
40
40
|
|
41
41
|
# DELIMITERS and TYPES are hashes with keys encoded in binary.
|
42
42
|
# Coerce incoming data to the same encoding.
|
43
|
-
str_type
|
44
|
-
delimiter
|
43
|
+
str_type = coerce_encoding(str_type)
|
44
|
+
delimiter = coerce_encoding(delimiter)
|
45
45
|
|
46
46
|
unless TYPES.include?(str_type)
|
47
47
|
message = ERRORS[:unexpected_percent_str] % { :type => str_type }
|
@@ -204,8 +204,7 @@ module Parser
|
|
204
204
|
|
205
205
|
def coerce_encoding(string)
|
206
206
|
if defined?(Encoding)
|
207
|
-
string.
|
208
|
-
:invalid => :replace, :undef => :replace)
|
207
|
+
string.dup.force_encoding(Encoding::BINARY)
|
209
208
|
else
|
210
209
|
string
|
211
210
|
end
|
data/lib/parser/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.pre8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Zotov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ast
|