• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

type-ruby / t-ruby / 20560733162

28 Dec 2025 10:59PM UTC coverage: 79.076% (+1.7%) from 77.331%
20560733162

Pull #29

github

web-flow
Merge 5e12f0648 into fda099366
Pull Request #29: refactor: migrate parser from regex to token-based parser combinator

1849 of 2098 new or added lines in 53 files covered. (88.13%)

6 existing lines in 2 files now uncovered.

6644 of 8402 relevant lines covered (79.08%)

908.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.67
/lib/t_ruby/parser_combinator/parse_result.rb
1
# frozen_string_literal: true
2

3
module TRuby
1✔
4
  module ParserCombinator
1✔
5
    # Parse result - either success or failure
6
    class ParseResult
1✔
7
      attr_reader :value, :remaining, :position, :error
1✔
8

9
      def initialize(success:, value: nil, remaining: "", position: 0, error: nil)
1✔
10
        @success = success
357,407✔
11
        @value = value
357,407✔
12
        @remaining = remaining
357,407✔
13
        @position = position
357,407✔
14
        @error = error
357,407✔
15
      end
16

17
      def success?
1✔
18
        @success
102,966✔
19
      end
20

21
      def failure?
1✔
22
        !@success
563,352✔
23
      end
24

25
      def self.success(value, remaining, position)
1✔
26
        new(success: true, value: value, remaining: remaining, position: position)
242,509✔
27
      end
28

29
      def self.failure(error, remaining, position)
1✔
30
        new(success: false, error: error, remaining: remaining, position: position)
114,898✔
31
      end
32

33
      def map
1✔
34
        return self if failure?
168,488✔
35

36
        ParseResult.success(yield(value), remaining, position)
84,601✔
37
      end
38

39
      def flat_map
1✔
NEW
40
        return self if failure?
×
41

NEW
42
        yield(value, remaining, position)
×
43
      end
44
    end
45
  end
46
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc