dolos 0.2.0 → 0.3.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 +4 -4
- data/.rubocop.yml +2 -0
- data/README.md +20 -8
- data/benchmarks/json/json.rb +31 -8
- data/benchmarks/json/nested_json_1m.json +20557 -0
- data/benchmarks/letter.rb +78 -0
- data/docs/.nojekyll +0 -0
- data/docs/README.md +22 -0
- data/docs/_sidebar.md +4 -0
- data/docs/getting_started.md +52 -0
- data/docs/index.html +26 -0
- data/examples/letter.rb +3 -3
- data/lib/dolos/common.rb +44 -0
- data/lib/dolos/parsers.rb +25 -16
- data/lib/dolos/result.rb +12 -3
- data/lib/dolos/string_io_wrapper.rb +3 -8
- data/lib/dolos/version.rb +1 -1
- data/lib/dolos.rb +53 -45
- data/sig/dolos/common_parsers.rbs +11 -0
- data/sig/dolos/parser.rbs +6 -2
- data/sig/dolos/parser_state.rbs +1 -1
- data/sig/dolos/parsers.rbs +4 -0
- data/sig/dolos/result.rbs +7 -0
- metadata +13 -5
- data/lib/dolos_common_parsers/common_parsers.rb +0 -34
- /data/benchmarks/json/{nested_json.json → nested_json_166.json} +0 -0
- /data/docs/{dolos_stable_diff.png → images/dolos_stable_diff.png} +0 -0
@@ -1,5 +1,16 @@
|
|
1
1
|
module Dolos
|
2
2
|
module CommonParsers
|
3
|
+
def digit: -> Parser[String]
|
4
|
+
def digits: -> Parser[String]
|
5
|
+
|
6
|
+
def int: -> Parser[Integer]
|
7
|
+
|
8
|
+
def eol: -> Parser[String]
|
9
|
+
|
3
10
|
def ws: -> Parser[String]
|
11
|
+
def ws_rep0: -> Parser[String]
|
12
|
+
|
13
|
+
def alpha: -> Parser[String]
|
14
|
+
def alphanum: -> Parser[String]
|
4
15
|
end
|
5
16
|
end
|
data/sig/dolos/parser.rbs
CHANGED
@@ -4,16 +4,20 @@ module Dolos
|
|
4
4
|
def initialize: (^(ParserState) -> Result[A]) -> Parser[A]
|
5
5
|
def capture!: -> Parser[A]
|
6
6
|
def choice: [B](Parser[B])-> Parser[A | B]
|
7
|
+
def combine: [B](^(A, B) -> Parser[B]) -> Parser[B]
|
7
8
|
def flat_map: [B](Parser[A], ^(A) -> Parser[B]) -> Parser[B]
|
8
9
|
def flatten: -> Parser[A]
|
9
10
|
def map: [B](^(A) -> B) -> Parser[B]
|
10
|
-
def
|
11
|
+
def map_captures: [B](^(A) -> B) -> Parser[B]
|
11
12
|
def optional: -> Parser[A?]
|
12
13
|
def product: [B](Parser[A]) -> Parser[B]
|
14
|
+
def product_l: [B](Parser[B]) -> Parser[B]
|
15
|
+
def product_r: [B](Parser[B]) -> Parser[A]
|
13
16
|
def run: (String) -> Result[A]
|
14
17
|
def run_with_state: (ParserState) -> Result[A]
|
15
|
-
def repeat: (Integer, Integer)-> Parser[Array[A]]
|
18
|
+
def repeat: [B](Integer, Integer, Parser[B]?)-> Parser[Array[A]]
|
16
19
|
def zero_or_more: -> Parser[Array[A]]
|
17
20
|
def one_or_more: (Integer?) -> Parser[Array[A]]
|
21
|
+
def lazy: -> Parser[A]
|
18
22
|
end
|
19
23
|
end
|
data/sig/dolos/parser_state.rbs
CHANGED
data/sig/dolos/parsers.rbs
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
module Dolos
|
2
2
|
module Parsers
|
3
3
|
def any_char: -> Parser[String]
|
4
|
+
def char_in: -> Parser[String]
|
5
|
+
def char_while : -> Parser[String]
|
6
|
+
def recursive: [A,B,C]() { (Parser[A]) -> Parser[B] } -> Parser[C]
|
7
|
+
|
4
8
|
def regex: (Regexp) -> Parser[String]
|
5
9
|
def string: (String)-> Parser[String]
|
6
10
|
end
|
data/sig/dolos/result.rbs
CHANGED
@@ -15,6 +15,11 @@ module Dolos
|
|
15
15
|
end
|
16
16
|
|
17
17
|
class Failure < Result[bot]
|
18
|
+
@message_proc: ^-> String
|
19
|
+
@message_evaluated: bool
|
20
|
+
@message_value: String
|
21
|
+
@state: ParserState
|
22
|
+
|
18
23
|
attr_reader committed: bool
|
19
24
|
attr_reader error_position: Integer
|
20
25
|
attr_reader message: String
|
@@ -25,6 +30,8 @@ module Dolos
|
|
25
30
|
|
26
31
|
def map: [B](^(bot) -> B) -> Result[B]
|
27
32
|
|
33
|
+
def pretty_print: -> String
|
34
|
+
|
28
35
|
def success?: -> bool
|
29
36
|
end
|
30
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dolos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- benetis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Parser combinators library for Ruby. In active development, not stable
|
14
14
|
yet.
|
@@ -19,21 +19,29 @@ extensions: []
|
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
21
|
- ".rspec"
|
22
|
+
- ".rubocop.yml"
|
22
23
|
- CHANGELOG.md
|
23
24
|
- LICENSE.txt
|
24
25
|
- README.md
|
25
26
|
- Rakefile
|
26
27
|
- benchmarks/json/json.rb
|
27
|
-
- benchmarks/json/
|
28
|
-
-
|
28
|
+
- benchmarks/json/nested_json_166.json
|
29
|
+
- benchmarks/json/nested_json_1m.json
|
30
|
+
- benchmarks/letter.rb
|
31
|
+
- docs/.nojekyll
|
32
|
+
- docs/README.md
|
33
|
+
- docs/_sidebar.md
|
34
|
+
- docs/getting_started.md
|
35
|
+
- docs/images/dolos_stable_diff.png
|
36
|
+
- docs/index.html
|
29
37
|
- examples/letter.rb
|
30
38
|
- lib/dolos.rb
|
39
|
+
- lib/dolos/common.rb
|
31
40
|
- lib/dolos/parser_state.rb
|
32
41
|
- lib/dolos/parsers.rb
|
33
42
|
- lib/dolos/result.rb
|
34
43
|
- lib/dolos/string_io_wrapper.rb
|
35
44
|
- lib/dolos/version.rb
|
36
|
-
- lib/dolos_common_parsers/common_parsers.rb
|
37
45
|
- sig/dolos.rbs
|
38
46
|
- sig/dolos/common_parsers.rbs
|
39
47
|
- sig/dolos/parser.rbs
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Dolos
|
4
|
-
module CommonParsers
|
5
|
-
def ws
|
6
|
-
regex(/\s/)
|
7
|
-
end
|
8
|
-
|
9
|
-
def eol
|
10
|
-
regex(/\n|\r\n|\r/)
|
11
|
-
end
|
12
|
-
|
13
|
-
def digit
|
14
|
-
regex(/\d/)
|
15
|
-
end
|
16
|
-
|
17
|
-
def int
|
18
|
-
digit.map(&:to_i)
|
19
|
-
end
|
20
|
-
|
21
|
-
# Capture as string
|
22
|
-
def digits
|
23
|
-
regex(/\d+/)
|
24
|
-
end
|
25
|
-
|
26
|
-
def alpha_num
|
27
|
-
regex(/[a-zA-Z0-9]/)
|
28
|
-
end
|
29
|
-
|
30
|
-
def alpha
|
31
|
-
regex(/[a-zA-Z]/)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
File without changes
|
File without changes
|