Sha256: d0b4870e24d53b0551a101d251911230c6257275814ac420fac59ddf52824684

Contents?: true

Size: 1.09 KB

Versions: 9

Compression:

Stored size: 1.09 KB

Contents

%%{
  machine re_char_type;

  single_codepoint_char_type = [dDhHsSwW];
  multi_codepoint_char_type  = [RX];

  char_type_char = single_codepoint_char_type | multi_codepoint_char_type;

  # Char types scanner
  # --------------------------------------------------------------------------
  char_type := |*
    char_type_char {
      case text = text(data, ts, te, 1).first
      when '\d'; emit(:type, :digit,      text, ts - 1, te)
      when '\D'; emit(:type, :nondigit,   text, ts - 1, te)
      when '\h'; emit(:type, :hex,        text, ts - 1, te)
      when '\H'; emit(:type, :nonhex,     text, ts - 1, te)
      when '\s'; emit(:type, :space,      text, ts - 1, te)
      when '\S'; emit(:type, :nonspace,   text, ts - 1, te)
      when '\w'; emit(:type, :word,       text, ts - 1, te)
      when '\W'; emit(:type, :nonword,    text, ts - 1, te)
      when '\R'; emit(:type, :linebreak,  text, ts - 1, te)
      when '\X'; emit(:type, :xgrapheme,  text, ts - 1, te)
      else
        raise ScannerError.new(
          "Unexpected character in type at #{text} (char #{ts})")
      end
      fret;
    };
  *|;
}%%

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
regexp_parser-1.5.0 lib/regexp_parser/scanner/char_type.rl
tdiary-5.0.13 vendor/bundle/gems/regexp_parser-1.3.0/lib/regexp_parser/scanner/char_type.rl
regexp_parser-1.4.0 lib/regexp_parser/scanner/char_type.rl
tdiary-5.0.12.1 vendor/bundle/gems/regexp_parser-1.3.0/lib/regexp_parser/scanner/char_type.rl
tdiary-5.0.11 vendor/bundle/gems/regexp_parser-1.3.0/lib/regexp_parser/scanner/char_type.rl
regexp_parser-1.3.0 lib/regexp_parser/scanner/char_type.rl
regexp_parser-1.2.0 lib/regexp_parser/scanner/char_type.rl
regexp_parser-1.1.0 lib/regexp_parser/scanner/char_type.rl
regexp_parser-1.0.0 lib/regexp_parser/scanner/char_type.rl