dolos 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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 map_value: [B](^(A) -> B) -> Parser[B]
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
@@ -1,6 +1,6 @@
1
1
  module Dolos
2
2
  class ParserState
3
- attr_reader input: Dolos::StringIOWrapper
3
+ attr_reader input: StringIOWrapper
4
4
  attr_accessor last_success_position: Integer
5
5
 
6
6
  def initialize: (String) -> void
@@ -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.2.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-19 00:00:00.000000000 Z
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/nested_json.json
28
- - docs/dolos_stable_diff.png
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