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 +4 -4
- data/.travis.yml +4 -3
- data/CHANGELOG.md +6 -0
- data/Gemfile +8 -1
- data/ext/ios_parser/c_lexer/lexer.c +10 -0
- data/ios_parser.gemspec +0 -4
- data/lib/ios_parser/lexer.rb +15 -5
- data/lib/ios_parser/version.rb +1 -1
- data/lib/ios_parser.rb +1 -0
- data/spec/lib/ios_parser/lexer_spec.rb +12 -0
- metadata +2 -58
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 171eddd89d5cab8faaa45c3d6a913df8c7b6bc28
|
4
|
+
data.tar.gz: 6bda5b3e474d03a3fa4a02a6399b62ddd89bbc9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 310aa7caec14048c544f0f65073a37e9deb6687fe372ead09a1c63a07b7d7189be4f91cbeba4ce40d3ab75264f45358d039980494572ab2077a8ed98dfb2a14e
|
7
|
+
data.tar.gz: 5df2bf63775bb0cba0ad20734494d7252751bb5357761fc28e8defe80eaa9bfec75565206a0011c6cf806749bfb5f26fe7a961678a3339ffb05f2bff713a6b9d
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -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
|
data/lib/ios_parser/lexer.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
data/lib/ios_parser/version.rb
CHANGED
data/lib/ios_parser.rb
CHANGED
@@ -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.
|
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-
|
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
|