parslet 1.8.2 → 2.0.0
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 +5 -5
- data/HISTORY.txt +10 -1
- data/README +1 -1
- data/example/mathn.rb +5 -2
- data/lib/parslet/atoms/dsl.rb +0 -8
- data/lib/parslet/atoms/infix.rb +2 -9
- data/lib/parslet/slice.rb +1 -4
- data/parslet.gemspec +1 -1
- data/spec/parslet/atoms/dsl_spec.rb +0 -18
- data/spec/parslet/slice_spec.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 4c354ef695d473ab9e07696a3c43328ee5d8a90172582c90529ed2c2b00fe86a
|
|
4
|
+
data.tar.gz: b5c22e9142d9393b17569b872640010673cc6c0d835a5519d6b81c8ce7f8b64a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7757ff468d6b982c9f2ff94096059e318cabccecc1fcd49695c93862f845222e81219baea8a5b6bec79cef720782f40af21f6afda89b0ebe1c96b5c6642bd892
|
|
7
|
+
data.tar.gz: b4be31a47471eb81f29fc8ddf118dd498bc144f96086d70ccb04e1d27ae12a21fd66a31c5155fbcb26d1dd6a8e5d94402ab302fc805285aeac1c021cb155165b
|
data/HISTORY.txt
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
|
|
2
|
-
= 2.0 /
|
|
2
|
+
= 2.0 / 16Feb2020
|
|
3
|
+
|
|
4
|
+
This release is essentially what is called a 'done' release, meaning I consider
|
|
5
|
+
that parslet meets its goals and doesn't need (much) more evolution.
|
|
3
6
|
|
|
4
7
|
- prsnt? and absnt? are now finally banned into oblivion. Wasting vocals for
|
|
5
8
|
the win.
|
|
9
|
+
|
|
10
|
+
- Because Ruby 2.6 broke Integer() conversion for non-Strings, we've removed
|
|
11
|
+
to_int for slices; to assert Integer type, you must now 'Integer(slice.to_s)'.
|
|
12
|
+
(Broken? How? Integer now (2.6) calls to_int - and when that fails - to_i.
|
|
13
|
+
A class that has both will never raise an exception. Incientially, this makes
|
|
14
|
+
String a unicorn class.)
|
|
6
15
|
|
|
7
16
|
= 1.8.2 / 13Feb2018
|
|
8
17
|
|
data/README
CHANGED
data/example/mathn.rb
CHANGED
|
@@ -38,7 +38,10 @@ attempt_parse
|
|
|
38
38
|
puts 'it terminates before we require mathn'
|
|
39
39
|
|
|
40
40
|
puts "requiring mathn now"
|
|
41
|
-
|
|
41
|
+
# mathn was deprecated as of Ruby 2.5
|
|
42
|
+
if RUBY_VERSION.gsub(/[^\d]/, '').to_i < 250
|
|
43
|
+
require 'mathn'
|
|
44
|
+
end
|
|
42
45
|
puts "and trying again (will hang without the fix)"
|
|
43
46
|
attempt_parse # but it doesn't terminate after requiring mathn
|
|
44
|
-
puts "okay!"
|
|
47
|
+
puts "okay!"
|
data/lib/parslet/atoms/dsl.rb
CHANGED
|
@@ -89,14 +89,6 @@ module Parslet::Atoms::DSL
|
|
|
89
89
|
Parslet::Atoms::Lookahead.new(self, true)
|
|
90
90
|
end
|
|
91
91
|
|
|
92
|
-
# Alias for present? that will disappear in 2.0 (deprecated)
|
|
93
|
-
#
|
|
94
|
-
alias prsnt? present?
|
|
95
|
-
|
|
96
|
-
# Alias for absent? that will disappear in 2.0 (deprecated)
|
|
97
|
-
#
|
|
98
|
-
alias absnt? absent?
|
|
99
|
-
|
|
100
92
|
# Marks a parslet atom as important for the tree output. This must be used
|
|
101
93
|
# to achieve meaningful output from the #parse method.
|
|
102
94
|
#
|
data/lib/parslet/atoms/infix.rb
CHANGED
|
@@ -10,7 +10,7 @@ class Parslet::Atoms::Infix < Parslet::Atoms::Base
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def try(source, context, consume_all)
|
|
13
|
-
return
|
|
13
|
+
return catch(:error) {
|
|
14
14
|
return succ(
|
|
15
15
|
produce_tree(
|
|
16
16
|
precedence_climb(source, context, consume_all)))
|
|
@@ -56,7 +56,7 @@ class Parslet::Atoms::Infix < Parslet::Atoms::Base
|
|
|
56
56
|
success, value = @element.apply(source, context, false)
|
|
57
57
|
|
|
58
58
|
unless success
|
|
59
|
-
|
|
59
|
+
throw :error, context.err(self, source, "#{@element.inspect} was expected", [value])
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
result << flatten(value, true)
|
|
@@ -108,13 +108,6 @@ class Parslet::Atoms::Infix < Parslet::Atoms::Base
|
|
|
108
108
|
return nil
|
|
109
109
|
end
|
|
110
110
|
|
|
111
|
-
def abort(error)
|
|
112
|
-
throw :error, error
|
|
113
|
-
end
|
|
114
|
-
def catch_error
|
|
115
|
-
catch(:error) { yield }
|
|
116
|
-
end
|
|
117
|
-
|
|
118
111
|
def to_s_inner(prec)
|
|
119
112
|
ops = @operations.map { |o, _, _| o.inspect }.join(', ')
|
|
120
113
|
"infix_expression(#{@element.inspect}, [#{ops}])"
|
data/lib/parslet/slice.rb
CHANGED
data/parslet.gemspec
CHANGED
|
@@ -3,23 +3,5 @@ require 'spec_helper'
|
|
|
3
3
|
describe Parslet::Atoms::DSL do
|
|
4
4
|
describe "deprecated methods" do
|
|
5
5
|
let(:parslet) { Parslet.str('foo') }
|
|
6
|
-
describe "<- #absnt?" do
|
|
7
|
-
slet(:absnt) { parslet.absnt? }
|
|
8
|
-
it '#bound_parslet' do
|
|
9
|
-
absnt.bound_parslet.should == parslet
|
|
10
|
-
end
|
|
11
|
-
it 'should be a negative lookahead' do
|
|
12
|
-
absnt.positive.should == false
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
describe "<- #prsnt?" do
|
|
16
|
-
slet(:prsnt) { parslet.prsnt? }
|
|
17
|
-
it '#bound_parslet' do
|
|
18
|
-
prsnt.bound_parslet.should == parslet
|
|
19
|
-
end
|
|
20
|
-
it 'should be a positive lookahead' do
|
|
21
|
-
prsnt.positive.should == true
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
6
|
end
|
|
25
7
|
end
|
data/spec/parslet/slice_spec.rb
CHANGED
|
@@ -112,8 +112,8 @@ describe Parslet::Slice do
|
|
|
112
112
|
s.to_i.should == 1234
|
|
113
113
|
end
|
|
114
114
|
it "should fail when Integer would fail on a string" do
|
|
115
|
-
lambda { Integer(slice) }.should raise_error(ArgumentError, /invalid value/)
|
|
116
|
-
end
|
|
115
|
+
lambda { Integer(slice.to_s) }.should raise_error(ArgumentError, /invalid value/)
|
|
116
|
+
end
|
|
117
117
|
it "should turn into zero when a string would" do
|
|
118
118
|
slice.to_i.should == 0
|
|
119
119
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: parslet
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kaspar Schiess
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2020-02-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description:
|
|
14
14
|
email: kaspar.schiess@absurd.li
|
|
@@ -187,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
187
187
|
version: '0'
|
|
188
188
|
requirements: []
|
|
189
189
|
rubyforge_project:
|
|
190
|
-
rubygems_version:
|
|
190
|
+
rubygems_version: 3.0.0.beta2
|
|
191
191
|
signing_key:
|
|
192
192
|
specification_version: 4
|
|
193
193
|
summary: Parser construction library with great error reporting in Ruby.
|