parsby 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/LICENSE +21 -0
- data/lib/parsby.rb +2 -31
- data/lib/parsby/combinators.rb +1 -6
- data/lib/parsby/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf70b52f0fa6d5df40b932bc176dd97dde08c111
|
4
|
+
data.tar.gz: a6944091c5c965a9ba64e820c3430dbf288e3ac2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a7bd7de34f69fce4d52a0d4351eaf6b956332734ca22dcbfb8f61620d96b7290472c0073729dd05e593002ad15fde844934bfe5841401b972e5ab6bcce4c7b1
|
7
|
+
data.tar.gz: 3ca273a3e9364884fba9af7f6af1239640f170b0d5fe516096df133cd1937bd512bfe1f69a3791d17cfa37d66cbd0115731fbcfc7196e4f8db5e58d6b2d21a86
|
data/.gitignore
CHANGED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) [year] [fullname]
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/lib/parsby.rb
CHANGED
@@ -374,31 +374,6 @@ class Parsby
|
|
374
374
|
end
|
375
375
|
end
|
376
376
|
|
377
|
-
class Token
|
378
|
-
attr_reader :name
|
379
|
-
|
380
|
-
# Makes a token with the given name.
|
381
|
-
def initialize(name)
|
382
|
-
@name = name
|
383
|
-
end
|
384
|
-
|
385
|
-
# Renders token name by surrounding it in angle brackets.
|
386
|
-
def to_s
|
387
|
-
"<#{name}>"
|
388
|
-
end
|
389
|
-
|
390
|
-
# Compare tokens
|
391
|
-
def ==(t)
|
392
|
-
t.is_a?(self.class) && t.name == name
|
393
|
-
end
|
394
|
-
|
395
|
-
# Flipped version of Parsby#%, so you can specify the token of a parser
|
396
|
-
# at the beginning of a parser expression.
|
397
|
-
def %(p)
|
398
|
-
p % self
|
399
|
-
end
|
400
|
-
end
|
401
|
-
|
402
377
|
class Backup < StringIO
|
403
378
|
def with_saved_pos(&b)
|
404
379
|
saved = pos
|
@@ -620,14 +595,10 @@ class Parsby
|
|
620
595
|
|
621
596
|
# The parser's label. It's an "unknown" token by default.
|
622
597
|
def label
|
623
|
-
@label ||
|
598
|
+
@label || "unknown"
|
624
599
|
end
|
625
600
|
|
626
|
-
|
627
|
-
# Parsby::Token.
|
628
|
-
def label=(name)
|
629
|
-
@label = name.is_a?(Symbol) ? Token.new(name) : name
|
630
|
-
end
|
601
|
+
attr_writer :label
|
631
602
|
|
632
603
|
# Initialize parser with optional label argument, and parsing block. The
|
633
604
|
# parsing block is given an IO as argument, and its result is the result
|
data/lib/parsby/combinators.rb
CHANGED
@@ -108,7 +108,7 @@ class Parsby
|
|
108
108
|
|
109
109
|
# Parses a decimal number as matched by \d+.
|
110
110
|
define_combinator :decimal do
|
111
|
-
many_1(decimal_digit).fmap {|ds| ds.join.to_i }
|
111
|
+
many_1(decimal_digit).fmap {|ds| ds.join.to_i }
|
112
112
|
end
|
113
113
|
|
114
114
|
# This is taken from the Json subparser for numbers.
|
@@ -375,10 +375,5 @@ class Parsby
|
|
375
375
|
end
|
376
376
|
end
|
377
377
|
end
|
378
|
-
|
379
|
-
# Makes a token with the given name.
|
380
|
-
def token(name)
|
381
|
-
Parsby::Token.new name
|
382
|
-
end
|
383
378
|
end
|
384
379
|
end
|
data/lib/parsby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parsby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jorge Luis Martinez Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -79,6 +79,7 @@ files:
|
|
79
79
|
- ".travis.yml"
|
80
80
|
- Gemfile
|
81
81
|
- Gemfile.lock
|
82
|
+
- LICENSE
|
82
83
|
- README.md
|
83
84
|
- Rakefile
|
84
85
|
- bin/all-methods
|