parser 2.0.0.pre7 → 2.0.0.pre8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 776614b2c048d80ca7eadd5fd3c3f914c51d88ec
4
- data.tar.gz: 01ddc7d4877aa4198de7685707d410febc010c29
3
+ metadata.gz: 784e6ea2b211d0e66b2c9b557ac575c2f7204444
4
+ data.tar.gz: 381fae65cbb0abd8400e382c8bf926221f74929f
5
5
  SHA512:
6
- metadata.gz: bab2b3791e25cfe5a13fc6cd844375377c3d678f302b79f3580d10fad2cb6dda60d5d371c8388142899eb803a238c84c9ccc2d2d46d3d2d00f80b53c08df7afc
7
- data.tar.gz: be57c964d5423e2b7f53a39db34a7e668f31fe5f9fe032678e1f4d83030f304ba3150f345c6c4b4ccfa64ffde2c652df9adc179febc7d2bfa0a8a2cb3e464eaa
6
+ metadata.gz: 720ec8f90cb16e1e38ddd02006afe4dda5ca2c9ccf31087a0906cafd406ba6865e57d5545be81f64dd17cc710c33d108e73476742475264147049d034c97c6c4
7
+ data.tar.gz: f0b89adbfa47c7ba825c9d54df1d32cb0c81dec28866caea61baebd77290eb860317f3e357c10f4953056b9b1339085d0b9f2bd418848de46053b961044479c0
@@ -1,6 +1,12 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ v2.0.0.pre8 (2013-09-15)
5
+ ------------------------
6
+
7
+ API modifications:
8
+ * lexer.rl: make lexing faster and improve parsing speed by ~60%. (Peter Zotov)
9
+
4
10
  v2.0.0.pre7 (2013-09-10)
5
11
  ------------------------
6
12
 
data/README.md CHANGED
@@ -15,12 +15,7 @@ Sponsored by [Evil Martians](http://evilmartians.com).
15
15
 
16
16
  ## Installation
17
17
 
18
- Most recent version of Parser is 2.0; however, per
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
@@ -114,7 +114,7 @@ task :changelog do
114
114
  end
115
115
 
116
116
  rule '.rb' => '.rl' do |t|
117
- sh "ragel -R #{t.source} -o #{t.name}"
117
+ sh "ragel -F1 -R #{t.source} -o #{t.name}"
118
118
  end
119
119
 
120
120
  rule '.rb' => '.y' do |t|
@@ -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 + "\0"
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
- _lex_actions = self.class.send :_lex_actions
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
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
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 = coerce_encoding(str_type)
44
- delimiter = coerce_encoding(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.encode(Encoding::UTF_8,
208
- :invalid => :replace, :undef => :replace)
207
+ string.dup.force_encoding(Encoding::BINARY)
209
208
  else
210
209
  string
211
210
  end
@@ -1,3 +1,3 @@
1
1
  module Parser
2
- VERSION = '2.0.0.pre7'
2
+ VERSION = '2.0.0.pre8'
3
3
  end
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.pre7
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-09 00:00:00.000000000 Z
11
+ date: 2013-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ast