kpeg 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +7 -0
- data/lib/kpeg/format_parser.rb +3 -4
- data/lib/kpeg/position.rb +3 -4
- data/lib/kpeg/string_escape.rb +3 -4
- data/lib/kpeg.rb +1 -1
- data/test/test_kpeg_compiled_parser.rb +10 -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: 80dd9b2ed08c2a2ccc37ad658fe0f14864dc5ad8ef4e36d108a243a68a4baa5f
|
4
|
+
data.tar.gz: 5dec03b1e86a4ff5d0d10ed7818d561b12c6c71022eed7de16786d0a90160de9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb96b6bcd8c7f92a6c11355d4022c95a285cf75872b5608fbb6fdc47233c342b42d3a91da524f6fb1678ae78d54109300e1607d7940ae5462c9282757d1bdc25
|
7
|
+
data.tar.gz: 9f7e844e84c119ce755e95a4034fcd67c251f90e2f4623a34bdba6f94e568f34adbb92011f96b1efe55b02be4a3191be6414c12aed93e083d705d82d27b95c4f
|
data/History.txt
CHANGED
data/lib/kpeg/format_parser.rb
CHANGED
@@ -30,16 +30,15 @@ class KPeg::FormatParser
|
|
30
30
|
if [].respond_to? :bsearch_index
|
31
31
|
def current_line(target=pos)
|
32
32
|
unless @line_offsets
|
33
|
-
@line_offsets = [
|
33
|
+
@line_offsets = []
|
34
34
|
total = 0
|
35
35
|
string.each_line do |line|
|
36
|
-
@line_offsets << total
|
37
36
|
total += line.size
|
37
|
+
@line_offsets << total
|
38
38
|
end
|
39
|
-
@line_offsets << total
|
40
39
|
end
|
41
40
|
|
42
|
-
@line_offsets.bsearch_index {|x| x >= target } || -1
|
41
|
+
@line_offsets.bsearch_index {|x| x >= target } + 1 || -1
|
43
42
|
end
|
44
43
|
else
|
45
44
|
def current_line(target=pos)
|
data/lib/kpeg/position.rb
CHANGED
@@ -13,16 +13,15 @@ module KPeg
|
|
13
13
|
if [].respond_to? :bsearch_index
|
14
14
|
def current_line(target=pos)
|
15
15
|
unless @line_offsets
|
16
|
-
@line_offsets = [
|
16
|
+
@line_offsets = []
|
17
17
|
total = 0
|
18
18
|
string.each_line do |line|
|
19
|
-
@line_offsets << total
|
20
19
|
total += line.size
|
20
|
+
@line_offsets << total
|
21
21
|
end
|
22
|
-
@line_offsets << total
|
23
22
|
end
|
24
23
|
|
25
|
-
@line_offsets.bsearch_index {|x| x >= target } || -1
|
24
|
+
@line_offsets.bsearch_index {|x| x >= target } + 1 || -1
|
26
25
|
end
|
27
26
|
else
|
28
27
|
def current_line(target=pos)
|
data/lib/kpeg/string_escape.rb
CHANGED
@@ -38,16 +38,15 @@ class KPeg::StringEscape
|
|
38
38
|
if [].respond_to? :bsearch_index
|
39
39
|
def current_line(target=pos)
|
40
40
|
unless @line_offsets
|
41
|
-
@line_offsets = [
|
41
|
+
@line_offsets = []
|
42
42
|
total = 0
|
43
43
|
string.each_line do |line|
|
44
|
-
@line_offsets << total
|
45
44
|
total += line.size
|
45
|
+
@line_offsets << total
|
46
46
|
end
|
47
|
-
@line_offsets << total
|
48
47
|
end
|
49
48
|
|
50
|
-
@line_offsets.bsearch_index {|x| x >= target } || -1
|
49
|
+
@line_offsets.bsearch_index {|x| x >= target } + 1 || -1
|
51
50
|
end
|
52
51
|
else
|
53
52
|
def current_line(target=pos)
|
data/lib/kpeg.rb
CHANGED
@@ -7,6 +7,7 @@ class TestKPegCompiledParser < Minitest::Test
|
|
7
7
|
|
8
8
|
gram = <<-GRAM
|
9
9
|
letter = [a-z]
|
10
|
+
number = [0-9]
|
10
11
|
root = letter
|
11
12
|
GRAM
|
12
13
|
|
@@ -14,7 +15,7 @@ class TestKPegCompiledParser < Minitest::Test
|
|
14
15
|
|
15
16
|
gram = <<-GRAM
|
16
17
|
%test = TestKPegCompiledParser::TestParser
|
17
|
-
root = %test.letter "!"
|
18
|
+
root = %test.letter %test.number? "!"
|
18
19
|
GRAM
|
19
20
|
|
20
21
|
KPeg.compile gram, "CompTestParser", self
|
@@ -78,4 +79,12 @@ class TestKPegCompiledParser < Minitest::Test
|
|
78
79
|
assert_equal expected, r.failure_oneline
|
79
80
|
end
|
80
81
|
|
82
|
+
def test_composite_two_char_error
|
83
|
+
r = CompTestParser.new "aa"
|
84
|
+
assert_nil r.parse, "should not parse"
|
85
|
+
|
86
|
+
expected = "@1:2 failed rule 'TestKPegCompiledParser::TestParser#_number', got 'a'"
|
87
|
+
assert_equal expected, r.failure_oneline
|
88
|
+
end
|
89
|
+
|
81
90
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kpeg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Phoenix
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|