farseer 0.7.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +25 -0
- data/SECURITY.md +2 -2
- data/lib/farseer/and.rb +4 -2
- data/lib/farseer/any.rb +2 -0
- data/lib/farseer/char.rb +2 -0
- data/lib/farseer/chars.rb +2 -0
- data/lib/farseer/empty.rb +15 -0
- data/lib/farseer/many.rb +2 -0
- data/lib/farseer/map.rb +17 -0
- data/lib/farseer/map_factory.rb +7 -0
- data/lib/farseer/opt.rb +2 -0
- data/lib/farseer/or.rb +2 -0
- data/lib/farseer/regexp.rb +2 -0
- data/lib/farseer/result.rb +3 -3
- data/lib/farseer/version.rb +1 -1
- data/lib/farseer/word.rb +2 -0
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f6d2e808d2e8ac8a9b119598834508dc1482f0cfaf68c34737fefb4bd261db6
|
4
|
+
data.tar.gz: 7282626a92655eb5b4044edef19689042127e22fb83e7751b5128c80f3749a89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f970a3b6804799587f2e715de0bff16efbaa6904e86259f735f6d417c5590cf0eb8bda85349509782c0258a215405c55c285159f7e31905406d08340891c3453
|
7
|
+
data.tar.gz: 7c5eaffc7d1b135bff0eae234f1322c1ded4971e0c8a68bfcd47cd43783037193d242a39e3fd2a59e06d76a267e8543967e1cde846f5dea7f2db03deb08d5ef9
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
## [0.9.0] - 2024-06-11
|
11
|
+
### Added
|
12
|
+
- `Farseer::Empty` which always succeeds and parses nothing, returning the whole
|
13
|
+
string as rest.
|
14
|
+
|
15
|
+
### Changed
|
16
|
+
- Change usage of `#eql?` to `#==` in `Farseer::Result`.
|
17
|
+
- `Farseer::And` does not join the resulting tokens anymore, but rather return
|
18
|
+
an array of tokens.
|
19
|
+
- Remove all development dependencies from `Gemfile` in favor of having
|
20
|
+
`lollipop` in the `gemspec`.
|
21
|
+
|
22
|
+
## [0.8.0] - 2024-06-04
|
23
|
+
### Added
|
24
|
+
- `Farseer::Map` which is a parser with a callback to map the resulting token
|
25
|
+
into something else.
|
26
|
+
- `Farseer::MapFactory` which adds `#map`, a factory method for new parsers with
|
27
|
+
callbacks. It creates a new instance of `Farseer::Map`.
|
28
|
+
- Included `Farseer::MapFactory` into all parsers.
|
29
|
+
|
30
|
+
|
10
31
|
## [0.7.0] - 2024-06-04
|
11
32
|
### Added
|
12
33
|
- `Farseer::And` to run a sequence of parsers that must all succeed.
|
@@ -23,6 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
23
44
|
### Changed
|
24
45
|
- Update development dependencies.
|
25
46
|
|
47
|
+
|
26
48
|
## [0.6.0] - 2024-06-03
|
27
49
|
### Added
|
28
50
|
- `Farseer::Opt` to parse `0` to `1` times the wrapped parser. (`?`)
|
@@ -37,6 +59,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
37
59
|
### Changed
|
38
60
|
- Updated development dependencies
|
39
61
|
|
62
|
+
|
40
63
|
## [0.5.0] - 2024-06-03
|
41
64
|
### Added
|
42
65
|
- `Farseer::Char` as a single character parser.
|
@@ -54,6 +77,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
54
77
|
### Changed
|
55
78
|
- Update `muina` version requirement to `~> 0.5`
|
56
79
|
|
80
|
+
|
57
81
|
## [0.4.0] - 2024-06-03
|
58
82
|
### Added
|
59
83
|
- `Farseer.any_char_parser` to parse a single character from a given set.
|
@@ -64,6 +88,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
64
88
|
- Stop using `module_function` and change methods into singleton methods.
|
65
89
|
- Update `bundler` version.
|
66
90
|
|
91
|
+
|
67
92
|
## [0.3.0] - 2024-06-02
|
68
93
|
### Added
|
69
94
|
- `Farseer#ws_parser` to parse all leading whitespace.
|
data/SECURITY.md
CHANGED
data/lib/farseer/and.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
module Farseer
|
4
4
|
class And
|
5
|
+
include MapFactory
|
6
|
+
|
5
7
|
def initialize(*parsers)
|
6
8
|
@parsers = parsers.flatten
|
7
9
|
freeze
|
@@ -10,7 +12,7 @@ module Farseer
|
|
10
12
|
def parse(input)
|
11
13
|
return Maybe.none if @parsers.empty?
|
12
14
|
|
13
|
-
initial = Maybe.return(Result.new(
|
15
|
+
initial = Maybe.return(Result.new([], input))
|
14
16
|
|
15
17
|
@parsers.reduce(initial) do |maybe_acc, parser|
|
16
18
|
bind_accumulator(maybe_acc, parser)
|
@@ -30,7 +32,7 @@ module Farseer
|
|
30
32
|
end
|
31
33
|
|
32
34
|
def combine_results(acc_result, result)
|
33
|
-
combined_tokens = acc_result.token + result.token
|
35
|
+
combined_tokens = acc_result.token + [result.token]
|
34
36
|
Maybe.return(Result.new(combined_tokens, result.rest))
|
35
37
|
end
|
36
38
|
end
|
data/lib/farseer/any.rb
CHANGED
data/lib/farseer/char.rb
CHANGED
data/lib/farseer/chars.rb
CHANGED
data/lib/farseer/many.rb
CHANGED
data/lib/farseer/map.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Farseer
|
4
|
+
class Map
|
5
|
+
include MapFactory
|
6
|
+
|
7
|
+
def initialize(parser, &map)
|
8
|
+
@parser = parser
|
9
|
+
@map = map
|
10
|
+
freeze
|
11
|
+
end
|
12
|
+
|
13
|
+
def parse(input)
|
14
|
+
@parser.parse(input).map { |r| Result.new(@map.call(r.token), r.rest) }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/farseer/opt.rb
CHANGED
data/lib/farseer/or.rb
CHANGED
data/lib/farseer/regexp.rb
CHANGED
data/lib/farseer/result.rb
CHANGED
@@ -9,11 +9,11 @@ module Farseer
|
|
9
9
|
end
|
10
10
|
attr_reader :token, :rest
|
11
11
|
|
12
|
-
def
|
12
|
+
def ==(other)
|
13
13
|
self.class.eql?(other.class) and
|
14
|
-
token
|
14
|
+
token == (other.token) and
|
15
15
|
rest.eql?(other.rest)
|
16
16
|
end
|
17
|
-
alias
|
17
|
+
alias eql? ==
|
18
18
|
end
|
19
19
|
end
|
data/lib/farseer/version.rb
CHANGED
data/lib/farseer/word.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: farseer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vaporyhumo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: muina
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: lollipop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.5'
|
41
55
|
description: Functional Parsing Library for Ruby
|
42
56
|
email:
|
43
57
|
- roanvilina@gmail.com
|
@@ -54,7 +68,10 @@ files:
|
|
54
68
|
- lib/farseer/any.rb
|
55
69
|
- lib/farseer/char.rb
|
56
70
|
- lib/farseer/chars.rb
|
71
|
+
- lib/farseer/empty.rb
|
57
72
|
- lib/farseer/many.rb
|
73
|
+
- lib/farseer/map.rb
|
74
|
+
- lib/farseer/map_factory.rb
|
58
75
|
- lib/farseer/opt.rb
|
59
76
|
- lib/farseer/or.rb
|
60
77
|
- lib/farseer/regexp.rb
|