ios_parser 0.3.1 → 0.3.3

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: b9c3428424b6fff808e5dcd94412c3d1e0d17ada
4
- data.tar.gz: a5cda3521efcc1c2f7f2826fb9985b9be384a8f1
3
+ metadata.gz: 171eddd89d5cab8faaa45c3d6a913df8c7b6bc28
4
+ data.tar.gz: 6bda5b3e474d03a3fa4a02a6399b62ddd89bbc9a
5
5
  SHA512:
6
- metadata.gz: aaeda92fb563f4416c18fc26e2118e30c90f9dc45e7e9da9559c7f84a6adf46e9c57ac3e0b9ffe0adfca38cef089d20bcb20cd0e6e4bebdf5afa63d3f939d598
7
- data.tar.gz: 881b58760c2426e08c49e5cad4db0db21e1fb95f14ddeb31ea465853cd81aa14fca33c5a1d04ec0ee2396b9fec99e27022156b693998eeb666bc664bc54b55af
6
+ metadata.gz: 310aa7caec14048c544f0f65073a37e9deb6687fe372ead09a1c63a07b7d7189be4f91cbeba4ce40d3ab75264f45358d039980494572ab2077a8ed98dfb2a14e
7
+ data.tar.gz: 5df2bf63775bb0cba0ad20734494d7252751bb5357761fc28e8defe80eaa9bfec75565206a0011c6cf806749bfb5f26fe7a961678a3339ffb05f2bff713a6b9d
data/.travis.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.0.0
4
- - 2.1.8
5
- - 2.2.4
6
- - 2.3.0
4
+ - 2.1.10
5
+ - 2.2.5
6
+ - 2.3.1
7
+ bundler_args: --without guard
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.3.3 (2016-05-17)
2
+
3
+ Bugfixes:
4
+
5
+ - raise parse error for unterminated quoted string
6
+
1
7
  ## 0.3.1 (2016-03-07)
2
8
 
3
9
  Bugfixes:
data/Gemfile CHANGED
@@ -1,2 +1,9 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
  gemspec
3
+
4
+ group :guard do
5
+ gem 'guard', '~>2.0'
6
+ gem 'guard-rake', '~>1.0'
7
+ gem 'guard-rspec', '~>4.5'
8
+ gem 'guard-rubocop', '~>1.2'
9
+ end
@@ -2,6 +2,7 @@
2
2
 
3
3
  static VALUE rb_mIOSParser;
4
4
  static VALUE rb_cCLexer;
5
+ VALUE rb_eLexError;
5
6
 
6
7
  typedef enum lex_token_state {
7
8
  LEX_STATE_ROOT,
@@ -451,6 +452,13 @@ static VALUE call(VALUE self, VALUE input_text) {
451
452
  }
452
453
  }
453
454
 
455
+ if (lex->token_state == LEX_STATE_QUOTED_STRING) {
456
+ rb_raise(rb_eLexError,
457
+ "Unterminated quoted string starting at %d: %.*s",
458
+ (int)lex->token_start,
459
+ (int)lex->token_length, &lex->text[lex->token_start]);
460
+ }
461
+
454
462
  delimit(lex);
455
463
  lex->token_start = lex->pos;
456
464
 
@@ -464,6 +472,8 @@ static VALUE call(VALUE self, VALUE input_text) {
464
472
  void Init_c_lexer() {
465
473
  rb_mIOSParser = rb_define_module("IOSParser");
466
474
  rb_cCLexer = rb_define_class_under(rb_mIOSParser, "CLexer", rb_cObject);
475
+ rb_eLexError = rb_define_class_under(rb_mIOSParser, "LexError",
476
+ rb_eStandardError);
467
477
  rb_define_alloc_func(rb_cCLexer, allocate);
468
478
  rb_define_method(rb_cCLexer, "initialize", initialize, 0);
469
479
  rb_define_method(rb_cCLexer, "call", call, 1);
data/ios_parser.gemspec CHANGED
@@ -17,9 +17,5 @@ Gem::Specification.new do |s|
17
17
 
18
18
  s.add_development_dependency 'rspec', '~>3.2'
19
19
  s.add_development_dependency 'rubocop', '~>0.37'
20
- s.add_development_dependency 'guard', '~>2.0'
21
- s.add_development_dependency 'guard-rake', '~>1.0'
22
- s.add_development_dependency 'guard-rspec', '~>4.5'
23
- s.add_development_dependency 'guard-rubocop', '~>1.2'
24
20
  s.add_development_dependency 'rake-compiler', '~>0.9'
25
21
  end
@@ -1,5 +1,7 @@
1
1
  module IOSParser
2
2
  class PureLexer
3
+ LexError = IOSParser::LexError
4
+
3
5
  attr_accessor :tokens, :token, :indents, :indent, :state, :char,
4
6
  :string_terminator
5
7
 
@@ -23,10 +25,7 @@ module IOSParser
23
25
  send(state)
24
26
  end
25
27
 
26
- delimit
27
- update_indentation
28
- scrub_banner_garbage
29
- tokens
28
+ finalize
30
29
  end
31
30
 
32
31
  ROOT_TRANSITIONS = [
@@ -289,6 +288,17 @@ module IOSParser
289
288
  indents.push(indent)
290
289
  end
291
290
 
292
- class LexError < StandardError; end
291
+ def finalize
292
+ if state == :quoted_string
293
+ pos = @text.rindex(string_terminator)
294
+ raise LexError, "Unterminated quoted string starting at #{pos}: "\
295
+ "#{@text[pos..pos + 20]}"
296
+ end
297
+
298
+ delimit
299
+ update_indentation
300
+ scrub_banner_garbage
301
+ tokens
302
+ end
293
303
  end # class PureLexer
294
304
  end # module IOSParser
@@ -1,7 +1,7 @@
1
1
  module IOSParser
2
2
  class << self
3
3
  def version
4
- '0.3.1'
4
+ '0.3.3'
5
5
  end
6
6
  end
7
7
  end
data/lib/ios_parser.rb CHANGED
@@ -11,6 +11,7 @@ module IOSParser
11
11
  end
12
12
 
13
13
  Lexer = lexer
14
+ class LexError < StandardError; end
14
15
  end
15
16
 
16
17
  require_relative 'ios_parser/ios'
@@ -264,6 +264,18 @@ END
264
264
  it { expect(subject_pure.map(&:last)).to eq output }
265
265
  it { expect(subject.map(&:last)).to eq output }
266
266
  end
267
+
268
+ context 'unterminated quoted string' do
269
+ let(:input) { '"asdf' }
270
+ it 'raises a lex error' do
271
+ expect { subject_pure }.to raise_error IOSParser::LexError
272
+ expect { subject }.to raise_error IOSParser::LexError
273
+
274
+ pattern = /Unterminated quoted string starting at 0: #{input}/
275
+ expect { subject_pure }.to raise_error(pattern)
276
+ expect { subject }.to raise_error(pattern)
277
+ end
278
+ end
267
279
  end
268
280
  end
269
281
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ios_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Miller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-07 00:00:00.000000000 Z
11
+ date: 2016-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -38,62 +38,6 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.37'
41
- - !ruby/object:Gem::Dependency
42
- name: guard
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '2.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '2.0'
55
- - !ruby/object:Gem::Dependency
56
- name: guard-rake
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1.0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '1.0'
69
- - !ruby/object:Gem::Dependency
70
- name: guard-rspec
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '4.5'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '4.5'
83
- - !ruby/object:Gem::Dependency
84
- name: guard-rubocop
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '1.2'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '1.2'
97
41
  - !ruby/object:Gem::Dependency
98
42
  name: rake-compiler
99
43
  requirement: !ruby/object:Gem::Requirement