class_docstr: For Ruby source code.
class_docstr_tok: ["For","Ruby","source","code","."]
code: def gen_rubystrings_rules():
      def intp_regex_callback(self, match, ctx):
          yield match.start(1), String.Regex, match.group(1)  # begin
          nctx = LexerContext(match.group(3), 0, ["interpolated-regex"])
          for i, t, v in self.get_tokens_unprocessed(context=nctx):
              yield match.start(3) + i, t, v
          yield match.start(4), String.Regex, match.group(
              4
          )  # end[mixounse]*
          ctx.pos = match.end()
  
      def intp_string_callback(self, match, ctx):
          yield match.start(1), String.Other, match.group(1)
          nctx = LexerContext(
              match.group(3), 0, ["interpolated-string"]
          )
          for i, t, v in self.get_tokens_unprocessed(context=nctx):
              yield match.start(3) + i, t, v
          yield match.start(4), String.Other, match.group(4)  # end
          ctx.pos = match.end()
  
      states = {}
      states["strings"] = [
          # easy ones
          (r"\:@{0,2}[a-zA-Z_]\w*[!?]?", String.Symbol),
          (words(RUBY_OPERATORS, prefix=r"\:@{0,2}"), String.Symbol),
          (r":'(\\\\|\\[^\\]|[^'\\])*'", String.Symbol),
          (r':"', String.Symbol, "simple-sym"),
          (
              r"([a-zA-Z_]\w*)(:)(?!:)",
              bygroups(String.Symbol, Punctuation),
          ),  # Since Ruby 1.9
          (r'"', String.Double, "simple-string-double"),
          (r"'", String.Single, "simple-string-single"),
          (r"(?<!\.)`", String.Backtick, "simple-backtick"),
      ]
  
      # quoted string and symbol
      for name, ttype, end in (
          ("string-double", String.Double, '"'),
          ("string-single", String.Single, "'"),
          ("sym", String.Symbol, '"'),
          ("backtick", String.Backtick, "`"),
      ):
          states["simple-" + name] = [
              include("string-intp-escaped"),
              (r"[^\\%s#]+" % end, ttype),
              (r"[\\#]", ttype),
              (end, ttype, "#pop"),
          ]
  
      # braced quoted strings
      for lbrace, rbrace, bracecc, name in (
          ("\\{", "\\}", "{}", "cb"),
          ("\\[", "\\]", "\\[\\]", "sb"),
          ("\\(", "\\)", "()", "pa"),
          ("<", ">", "<>", "ab"),
      ):
          states[name + "-intp-string"] = [
              (r"\\[\\" + bracecc + "]", String.Other),
              (lbrace, String.Other, "#push"),
              (rbrace, String.Other, "#pop"),
              include("string-intp-escaped"),
              (r"[\\#" + bracecc + "]", String.Other),
              (r"[^\\#" + bracecc + "]+", String.Other),
          ]
          states["strings"].append(
              (r"%[QWx]?" + lbrace, String.Other, name + "-intp-string")
          )
          states[name + "-string"] = [
              (r"\\[\\" + bracecc + "]", String.Other),
              (lbrace, String.Other, "#push"),
              (rbrace, String.Other, "#pop"),
              (r"[\\#" + bracecc + "]", String.Other),
              (r"[^\\#" + bracecc + "]+", String.Other),
          ]
          states["strings"].append(
              (r"%[qsw]" + lbrace, String.Other, name + "-string")
          )
          states[name + "-regex"] = [
              (r"\\[\\" + bracecc + "]", String.Regex),
              (lbrace, String.Regex, "#push"),
              (rbrace + "[mixounse]*", String.Regex, "#pop"),
              include("string-intp"),
              (r"[\\#" + bracecc + "]", String.Regex),
              (r"[^\\#" + bracecc + "]+", String.Regex),
          ]
          states["strings"].append(
              (r"%r" + lbrace, String.Regex, name + "-regex")
          )
  
      # these must come after %<brace>!
      states["strings"] += [
          # %r regex
          (
              r"(%r([\W_]))((?:\\\2|(?!\2).)*)(\2[mixounse]*)",
              intp_regex_callback,
          ),
          # regular fancy strings with qsw
          (r"%[qsw]([\W_])((?:\\\1|(?!\1).)*)\1", String.Other),
          (
              r"(%[QWx]([\W_]))((?:\\\2|(?!\2).)*)(\2)",
              intp_string_callback,
          ),
          # special forms of fancy strings after operators or
          # in method calls with braces
          (
              r"(?<=[-+/*%=<>&!^|~,(])(\s*)(%([\t ])(?:(?:\\\3|(?!\3).)*)\3)",
              bygroups(Whitespace, String.Other, None),
          ),
          # and because of fixed width lookbehinds the whole thing a
          # second time for line startings...
          (
              r"^(\s*)(%([\t ])(?:(?:\\\3|(?!\3).)*)\3)",
              bygroups(Whitespace, String.Other, None),
          ),
          # all regular fancy strings without qsw
          (
              r"(%([^a-zA-Z0-9\s]))((?:\\\2|(?!\2).)*)(\2)",
              intp_string_callback,
          ),
      ]
  
      return states
  
file_path: catboost/contrib/python/Pygments/py3/pygments/lexers/ruby.py
imports: import re
  from pygments.lexer import Lexer, RegexLexer, ExtendedRegexLexer, include, bygroups, default, LexerContext, do_insertions, words, line_re
  from pygments.token import Text, Comment, Operator, Keyword, Name, String, Number, Punctuation, Error, Generic, Whitespace
  from pygments.util import shebang_matches
label_desc: Use image node_id 2 for calling the RubyLexer obj's underlying member method code with example usage: obj.gen_rubystrings_rules() and returns: states