File: assertion_converter.rb

package info (click to toggle)
ruby-js-regex 3.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 164 kB
  • sloc: ruby: 1,002; makefile: 3
file content (37 lines) | stat: -rw-r--r-- 928 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require_relative 'base'
require_relative 'group_converter'

class JsRegex
  module Converter
    #
    # Template class implementation.
    #
    # Note the inheritance from GroupConverter.
    #
    class AssertionConverter < JsRegex::Converter::GroupConverter
      private

      def convert_data
        case subtype
        when :lookahead, :nlookahead
          keep_as_is
        when :lookbehind
          return keep_as_is if context.es_2018_or_higher?

          warn_of_unsupported_feature('lookbehind', min_target: Target::ES2018)
          build_passive_group
        when :nlookbehind
          return keep_as_is if context.es_2018_or_higher?

          warn_of_unsupported_feature('negative lookbehind', min_target: Target::ES2018)
        else
          warn_of_unsupported_feature
        end
      end

      def keep_as_is
        build_group(head: pass_through, capturing: false)
      end
    end
  end
end