Blame src/prelexer.hpp

Packit Service 7770af
#ifndef SASS_PRELEXER_H
Packit Service 7770af
#define SASS_PRELEXER_H
Packit Service 7770af
Packit Service 7770af
#include <cstring>
Packit Service 7770af
#include "lexer.hpp"
Packit Service 7770af
Packit Service 7770af
namespace Sass {
Packit Service 7770af
  // using namespace Lexer;
Packit Service 7770af
  namespace Prelexer {
Packit Service 7770af
Packit Service 7770af
    //####################################
Packit Service 7770af
    // KEYWORD "REGEX" MATCHERS
Packit Service 7770af
    //####################################
Packit Service 7770af
Packit Service 7770af
    // Match Sass boolean keywords.
Packit Service 7770af
    const char* kwd_true(const char* src);
Packit Service 7770af
    const char* kwd_false(const char* src);
Packit Service 7770af
    const char* kwd_only(const char* src);
Packit Service 7770af
    const char* kwd_and(const char* src);
Packit Service 7770af
    const char* kwd_or(const char* src);
Packit Service 7770af
    const char* kwd_not(const char* src);
Packit Service 7770af
    const char* kwd_eq(const char* src);
Packit Service 7770af
    const char* kwd_neq(const char* src);
Packit Service 7770af
    const char* kwd_gt(const char* src);
Packit Service 7770af
    const char* kwd_gte(const char* src);
Packit Service 7770af
    const char* kwd_lt(const char* src);
Packit Service 7770af
    const char* kwd_lte(const char* src);
Packit Service 7770af
Packit Service 7770af
    // Match standard control chars
Packit Service 7770af
    const char* kwd_at(const char* src);
Packit Service 7770af
    const char* kwd_dot(const char* src);
Packit Service 7770af
    const char* kwd_comma(const char* src);
Packit Service 7770af
    const char* kwd_colon(const char* src);
Packit Service 7770af
    const char* kwd_slash(const char* src);
Packit Service 7770af
    const char* kwd_star(const char* src);
Packit Service 7770af
    const char* kwd_plus(const char* src);
Packit Service 7770af
    const char* kwd_minus(const char* src);
Packit Service 7770af
Packit Service 7770af
    //####################################
Packit Service 7770af
    // SPECIAL "REGEX" CONSTRUCTS
Packit Service 7770af
    //####################################
Packit Service 7770af
Packit Service 7770af
    // Match a sequence of characters delimited by the supplied chars.
Packit Service 7770af
    template <char beg, char end, bool esc>
Packit Service 7770af
    const char* delimited_by(const char* src) {
Packit Service 7770af
      src = exactly<beg>(src);
Packit Service 7770af
      if (!src) return 0;
Packit Service 7770af
      const char* stop;
Packit Service 7770af
      while (true) {
Packit Service 7770af
        if (!*src) return 0;
Packit Service 7770af
        stop = exactly<end>(src);
Packit Service 7770af
        if (stop && (!esc || *(src - 1) != '\\')) return stop;
Packit Service 7770af
        src = stop ? stop : src + 1;
Packit Service 7770af
      }
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // skip to delimiter (mx) inside given range
Packit Service 7770af
    // this will savely skip over all quoted strings
Packit Service 7770af
    // recursive skip stuff delimited by start/stop
Packit Service 7770af
    // first start/opener must be consumed already!
Packit Service 7770af
    template<prelexer start, prelexer stop>
Packit Service 7770af
    const char* skip_over_scopes(const char* src, const char* end) {
Packit Service 7770af
Packit Service 7770af
      size_t level = 0;
Packit Service 7770af
      bool in_squote = false;
Packit Service 7770af
      bool in_dquote = false;
Packit Service 7770af
      // bool in_braces = false;
Packit Service 7770af
Packit Service 7770af
      while (*src) {
Packit Service 7770af
Packit Service 7770af
        // check for abort condition
Packit Service 7770af
        if (end && src >= end) break;
Packit Service 7770af
Packit Service 7770af
        // has escaped sequence?
Packit Service 7770af
        if (*src == '\\') {
Packit Service 7770af
          ++ src; // skip this (and next)
Packit Service 7770af
        }
Packit Service 7770af
        else if (*src == '"') {
Packit Service 7770af
          in_dquote = ! in_dquote;
Packit Service 7770af
        }
Packit Service 7770af
        else if (*src == '\'') {
Packit Service 7770af
          in_squote = ! in_squote;
Packit Service 7770af
        }
Packit Service 7770af
        else if (in_dquote || in_squote) {
Packit Service 7770af
          // take everything literally
Packit Service 7770af
        }
Packit Service 7770af
Packit Service 7770af
        // find another opener inside?
Packit Service 7770af
        else if (const char* pos = start(src)) {
Packit Service 7770af
          ++ level; // increase counter
Packit Service 7770af
          src = pos - 1; // advance position
Packit Service 7770af
        }
Packit Service 7770af
Packit Service 7770af
        // look for the closer (maybe final, maybe not)
Packit Service 7770af
        else if (const char* final = stop(src)) {
Packit Service 7770af
          // only close one level?
Packit Service 7770af
          if (level > 0) -- level;
Packit Service 7770af
          // return position at end of stop
Packit Service 7770af
          // delimiter may be multiple chars
Packit Service 7770af
          else return final;
Packit Service 7770af
          // advance position
Packit Service 7770af
          src = final - 1;
Packit Service 7770af
        }
Packit Service 7770af
Packit Service 7770af
        // next
Packit Service 7770af
        ++ src;
Packit Service 7770af
      }
Packit Service 7770af
Packit Service 7770af
      return 0;
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // skip to a skip delimited by parentheses
Packit Service 7770af
    // uses smart `skip_over_scopes` internally
Packit Service 7770af
    const char* parenthese_scope(const char* src);
Packit Service 7770af
Packit Service 7770af
    // skip to delimiter (mx) inside given range
Packit Service 7770af
    // this will savely skip over all quoted strings
Packit Service 7770af
    // recursive skip stuff delimited by start/stop
Packit Service 7770af
    // first start/opener must be consumed already!
Packit Service 7770af
    template<prelexer start, prelexer stop>
Packit Service 7770af
    const char* skip_over_scopes(const char* src) {
Packit Service 7770af
      return skip_over_scopes<start, stop>(src, 0);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // Match a sequence of characters delimited by the supplied chars.
Packit Service 7770af
    template <prelexer start, prelexer stop>
Packit Service 7770af
    const char* recursive_scopes(const char* src) {
Packit Service 7770af
      // parse opener
Packit Service 7770af
      src = start(src);
Packit Service 7770af
      // abort if not found
Packit Service 7770af
      if (!src) return 0;
Packit Service 7770af
      // parse the rest until final closer
Packit Service 7770af
      return skip_over_scopes<start, stop>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // Match a sequence of characters delimited by the supplied strings.
Packit Service 7770af
    template <const char* beg, const char* end, bool esc>
Packit Service 7770af
    const char* delimited_by(const char* src) {
Packit Service 7770af
      src = exactly<beg>(src);
Packit Service 7770af
      if (!src) return 0;
Packit Service 7770af
      const char* stop;
Packit Service 7770af
      while (true) {
Packit Service 7770af
        if (!*src) return 0;
Packit Service 7770af
        stop = exactly<end>(src);
Packit Service 7770af
        if (stop && (!esc || *(src - 1) != '\\')) return stop;
Packit Service 7770af
        src = stop ? stop : src + 1;
Packit Service 7770af
      }
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // Tries to match a certain number of times (between the supplied interval).
Packit Service 7770af
    template<prelexer mx, size_t lo, size_t hi>
Packit Service 7770af
    const char* between(const char* src) {
Packit Service 7770af
      for (size_t i = 0; i < lo; ++i) {
Packit Service 7770af
        src = mx(src);
Packit Service 7770af
        if (!src) return 0;
Packit Service 7770af
      }
Packit Service 7770af
      for (size_t i = lo; i <= hi; ++i) {
Packit Service 7770af
        const char* new_src = mx(src);
Packit Service 7770af
        if (!new_src) return src;
Packit Service 7770af
        src = new_src;
Packit Service 7770af
      }
Packit Service 7770af
      return src;
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // equivalent of STRING_REGULAR_EXPRESSIONS
Packit Service 7770af
    const char* re_string_double_open(const char* src);
Packit Service 7770af
    const char* re_string_double_close(const char* src);
Packit Service 7770af
    const char* re_string_single_open(const char* src);
Packit Service 7770af
    const char* re_string_single_close(const char* src);
Packit Service 7770af
    const char* re_string_uri_open(const char* src);
Packit Service 7770af
    const char* re_string_uri_close(const char* src);
Packit Service 7770af
Packit Service 7770af
    // Match a line comment.
Packit Service 7770af
    const char* line_comment(const char* src);
Packit Service 7770af
Packit Service 7770af
    // Match a block comment.
Packit Service 7770af
    const char* block_comment(const char* src);
Packit Service 7770af
    // Match either.
Packit Service 7770af
    const char* comment(const char* src);
Packit Service 7770af
    // Match double- and single-quoted strings.
Packit Service 7770af
    const char* double_quoted_string(const char* src);
Packit Service 7770af
    const char* single_quoted_string(const char* src);
Packit Service 7770af
    const char* quoted_string(const char* src);
Packit Service 7770af
    // Match interpolants.
Packit Service 7770af
    const char* interpolant(const char* src);
Packit Service 7770af
    // Match number prefix ([\+\-]+)
Packit Service 7770af
    const char* number_prefix(const char* src);
Packit Service 7770af
Packit Service 7770af
    // Match zero plus white-space or line_comments
Packit Service 7770af
    const char* optional_css_whitespace(const char* src);
Packit Service 7770af
    const char* css_whitespace(const char* src);
Packit Service 7770af
    // Match optional_css_whitepace plus block_comments
Packit Service 7770af
    const char* optional_css_comments(const char* src);
Packit Service 7770af
    const char* css_comments(const char* src);
Packit Service 7770af
Packit Service 7770af
    // Match one backslash escaped char
Packit Service 7770af
    const char* escape_seq(const char* src);
Packit Service 7770af
Packit Service 7770af
    // Match CSS css variables.
Packit Service 7770af
    const char* custom_property_name(const char* src);
Packit Service 7770af
    // Match a CSS identifier.
Packit Service 7770af
    const char* identifier(const char* src);
Packit Service 7770af
    const char* identifier_alpha(const char* src);
Packit Service 7770af
    const char* identifier_alnum(const char* src);
Packit Service 7770af
    const char* strict_identifier(const char* src);
Packit Service 7770af
    const char* strict_identifier_alpha(const char* src);
Packit Service 7770af
    const char* strict_identifier_alnum(const char* src);
Packit Service 7770af
    // Match a CSS unit identifier.
Packit Service 7770af
    const char* one_unit(const char* src);
Packit Service 7770af
    const char* multiple_units(const char* src);
Packit Service 7770af
    const char* unit_identifier(const char* src);
Packit Service 7770af
    // const char* strict_identifier_alnums(const char* src);
Packit Service 7770af
    // Match reference selector.
Packit Service 7770af
    const char* re_reference_combinator(const char* src);
Packit Service 7770af
    const char* static_reference_combinator(const char* src);
Packit Service 7770af
    const char* schema_reference_combinator(const char* src);
Packit Service 7770af
Packit Service 7770af
    // Match interpolant schemas
Packit Service 7770af
    const char* identifier_schema(const char* src);
Packit Service 7770af
    const char* value_schema(const char* src);
Packit Service 7770af
    const char* sass_value(const char* src);
Packit Service 7770af
    // const char* filename(const char* src);
Packit Service 7770af
    // const char* filename_schema(const char* src);
Packit Service 7770af
    // const char* url_schema(const char* src);
Packit Service 7770af
    // const char* url_value(const char* src);
Packit Service 7770af
    const char* vendor_prefix(const char* src);
Packit Service 7770af
Packit Service 7770af
    const char* re_special_directive(const char* src);
Packit Service 7770af
    const char* re_prefixed_directive(const char* src);
Packit Service 7770af
    const char* re_almost_any_value_token(const char* src);
Packit Service 7770af
Packit Service 7770af
    // Match CSS '@' keywords.
Packit Service 7770af
    const char* at_keyword(const char* src);
Packit Service 7770af
    const char* kwd_import(const char* src);
Packit Service 7770af
    const char* kwd_at_root(const char* src);
Packit Service 7770af
    const char* kwd_with_directive(const char* src);
Packit Service 7770af
    const char* kwd_without_directive(const char* src);
Packit Service 7770af
    const char* kwd_media(const char* src);
Packit Service 7770af
    const char* kwd_supports_directive(const char* src);
Packit Service 7770af
    // const char* keyframes(const char* src);
Packit Service 7770af
    // const char* keyf(const char* src);
Packit Service 7770af
    const char* kwd_mixin(const char* src);
Packit Service 7770af
    const char* kwd_function(const char* src);
Packit Service 7770af
    const char* kwd_return_directive(const char* src);
Packit Service 7770af
    const char* kwd_include_directive(const char* src);
Packit Service 7770af
    const char* kwd_content_directive(const char* src);
Packit Service 7770af
    const char* kwd_charset_directive(const char* src);
Packit Service 7770af
    const char* kwd_extend(const char* src);
Packit Service 7770af
Packit Service 7770af
    const char* unicode_seq(const char* src);
Packit Service 7770af
Packit Service 7770af
    const char* kwd_if_directive(const char* src);
Packit Service 7770af
    const char* kwd_else_directive(const char* src);
Packit Service 7770af
    const char* elseif_directive(const char* src);
Packit Service 7770af
Packit Service 7770af
    const char* kwd_for_directive(const char* src);
Packit Service 7770af
    const char* kwd_from(const char* src);
Packit Service 7770af
    const char* kwd_to(const char* src);
Packit Service 7770af
    const char* kwd_through(const char* src);
Packit Service 7770af
Packit Service 7770af
    const char* kwd_each_directive(const char* src);
Packit Service 7770af
    const char* kwd_in(const char* src);
Packit Service 7770af
Packit Service 7770af
    const char* kwd_while_directive(const char* src);
Packit Service 7770af
Packit Service 7770af
    const char* re_nothing(const char* src);
Packit Service 7770af
    const char* re_type_selector2(const char* src);
Packit Service 7770af
Packit Service 7770af
    const char* re_special_fun(const char* src);
Packit Service 7770af
Packit Service 7770af
    const char* kwd_warn(const char* src);
Packit Service 7770af
    const char* kwd_err(const char* src);
Packit Service 7770af
    const char* kwd_dbg(const char* src);
Packit Service 7770af
Packit Service 7770af
    const char* kwd_null(const char* src);
Packit Service 7770af
Packit Service 7770af
    const char* re_selector_list(const char* src);
Packit Service 7770af
    const char* re_type_selector(const char* src);
Packit Service 7770af
    const char* re_static_expression(const char* src);
Packit Service 7770af
Packit Service 7770af
    // identifier that can start with hyphens
Packit Service 7770af
    const char* css_identifier(const char* src);
Packit Service 7770af
    const char* css_ip_identifier(const char* src);
Packit Service 7770af
Packit Service 7770af
    // Match CSS type selectors
Packit Service 7770af
    const char* namespace_schema(const char* src);
Packit Service 7770af
    const char* namespace_prefix(const char* src);
Packit Service 7770af
    const char* type_selector(const char* src);
Packit Service 7770af
    const char* hyphens_and_identifier(const char* src);
Packit Service 7770af
    const char* hyphens_and_name(const char* src);
Packit Service 7770af
    const char* universal(const char* src);
Packit Service 7770af
    // Match CSS id names.
Packit Service 7770af
    const char* id_name(const char* src);
Packit Service 7770af
    // Match CSS class names.
Packit Service 7770af
    const char* class_name(const char* src);
Packit Service 7770af
    // Attribute name in an attribute selector
Packit Service 7770af
    const char* attribute_name(const char* src);
Packit Service 7770af
    // Match placeholder selectors.
Packit Service 7770af
    const char* placeholder(const char* src);
Packit Service 7770af
    // Match CSS numeric constants.
Packit Service 7770af
    const char* op(const char* src);
Packit Service 7770af
    const char* sign(const char* src);
Packit Service 7770af
    const char* unsigned_number(const char* src);
Packit Service 7770af
    const char* number(const char* src);
Packit Service 7770af
    const char* coefficient(const char* src);
Packit Service 7770af
    const char* binomial(const char* src);
Packit Service 7770af
    const char* percentage(const char* src);
Packit Service 7770af
    const char* ampersand(const char* src);
Packit Service 7770af
    const char* dimension(const char* src);
Packit Service 7770af
    const char* hex(const char* src);
Packit Service 7770af
    const char* hexa(const char* src);
Packit Service 7770af
    const char* hex0(const char* src);
Packit Service 7770af
    // const char* rgb_prefix(const char* src);
Packit Service 7770af
    // Match CSS uri specifiers.
Packit Service 7770af
    const char* uri_prefix(const char* src);
Packit Service 7770af
    // Match CSS "!important" keyword.
Packit Service 7770af
    const char* kwd_important(const char* src);
Packit Service 7770af
    // Match CSS "!optional" keyword.
Packit Service 7770af
    const char* kwd_optional(const char* src);
Packit Service 7770af
    // Match Sass "!default" keyword.
Packit Service 7770af
    const char* default_flag(const char* src);
Packit Service 7770af
    const char* global_flag(const char* src);
Packit Service 7770af
    // Match CSS pseudo-class/element prefixes
Packit Service 7770af
    const char* pseudo_prefix(const char* src);
Packit Service 7770af
    // Match CSS function call openers.
Packit Service 7770af
    const char* re_functional(const char* src);
Packit Service 7770af
    const char* re_pseudo_selector(const char* src);
Packit Service 7770af
    const char* functional_schema(const char* src);
Packit Service 7770af
    const char* pseudo_not(const char* src);
Packit Service 7770af
    // Match CSS 'odd' and 'even' keywords for functional pseudo-classes.
Packit Service 7770af
    const char* even(const char* src);
Packit Service 7770af
    const char* odd(const char* src);
Packit Service 7770af
    // Match CSS attribute-matching operators.
Packit Service 7770af
    const char* exact_match(const char* src);
Packit Service 7770af
    const char* class_match(const char* src);
Packit Service 7770af
    const char* dash_match(const char* src);
Packit Service 7770af
    const char* prefix_match(const char* src);
Packit Service 7770af
    const char* suffix_match(const char* src);
Packit Service 7770af
    const char* substring_match(const char* src);
Packit Service 7770af
    // Match CSS combinators.
Packit Service 7770af
    // const char* adjacent_to(const char* src);
Packit Service 7770af
    // const char* precedes(const char* src);
Packit Service 7770af
    // const char* parent_of(const char* src);
Packit Service 7770af
    // const char* ancestor_of(const char* src);
Packit Service 7770af
Packit Service 7770af
    // Match SCSS variable names.
Packit Service 7770af
    const char* variable(const char* src);
Packit Service 7770af
    const char* calc_fn_call(const char* src);
Packit Service 7770af
Packit Service 7770af
    // IE stuff
Packit Service 7770af
    const char* ie_progid(const char* src);
Packit Service 7770af
    const char* ie_expression(const char* src);
Packit Service 7770af
    const char* ie_property(const char* src);
Packit Service 7770af
    const char* ie_keyword_arg(const char* src);
Packit Service 7770af
    const char* ie_keyword_arg_value(const char* src);
Packit Service 7770af
    const char* ie_keyword_arg_property(const char* src);
Packit Service 7770af
Packit Service 7770af
    // match url()
Packit Service 7770af
    const char* H(const char* src);
Packit Service 7770af
    const char* W(const char* src);
Packit Service 7770af
    // `UNICODE` makes VS sad
Packit Service 7770af
    const char* UUNICODE(const char* src);
Packit Service 7770af
    const char* NONASCII(const char* src);
Packit Service 7770af
    const char* ESCAPE(const char* src);
Packit Service 7770af
    const char* real_uri_suffix(const char* src);
Packit Service 7770af
    // const char* real_uri_prefix(const char* src);
Packit Service 7770af
    const char* real_uri_value(const char* src);
Packit Service 7770af
Packit Service 7770af
    // Path matching functions.
Packit Service 7770af
    // const char* folder(const char* src);
Packit Service 7770af
    // const char* folders(const char* src);
Packit Service 7770af
Packit Service 7770af
Packit Service 7770af
    const char* static_string(const char* src);
Packit Service 7770af
    const char* static_component(const char* src);
Packit Service 7770af
    const char* static_property(const char* src);
Packit Service 7770af
    const char* static_value(const char* src);
Packit Service 7770af
Packit Service 7770af
    // Utility functions for finding and counting characters in a string.
Packit Service 7770af
    template<char c>
Packit Service 7770af
    const char* find_first(const char* src) {
Packit Service 7770af
      while (*src && *src != c) ++src;
Packit Service 7770af
      return *src ? src : 0;
Packit Service 7770af
    }
Packit Service 7770af
    template<prelexer mx>
Packit Service 7770af
    const char* find_first(const char* src) {
Packit Service 7770af
      while (*src && !mx(src)) ++src;
Packit Service 7770af
      return *src ? src : 0;
Packit Service 7770af
    }
Packit Service 7770af
    template<prelexer mx>
Packit Service 7770af
    const char* find_first_in_interval(const char* beg, const char* end) {
Packit Service 7770af
      bool esc = false;
Packit Service 7770af
      while ((beg < end) && *beg) {
Packit Service 7770af
        if (esc) esc = false;
Packit Service 7770af
        else if (*beg == '\\') esc = true;
Packit Service 7770af
        else if (mx(beg)) return beg;
Packit Service 7770af
        ++beg;
Packit Service 7770af
      }
Packit Service 7770af
      return 0;
Packit Service 7770af
    }
Packit Service 7770af
    template<prelexer mx, prelexer skip>
Packit Service 7770af
    const char* find_first_in_interval(const char* beg, const char* end) {
Packit Service 7770af
      bool esc = false;
Packit Service 7770af
      while ((beg < end) && *beg) {
Packit Service 7770af
        if (esc) esc = false;
Packit Service 7770af
        else if (*beg == '\\') esc = true;
Packit Service 7770af
        else if (const char* pos = skip(beg)) beg = pos;
Packit Service 7770af
        else if (mx(beg)) return beg;
Packit Service 7770af
        ++beg;
Packit Service 7770af
      }
Packit Service 7770af
      return 0;
Packit Service 7770af
    }
Packit Service 7770af
    template <prelexer mx>
Packit Service 7770af
    unsigned int count_interval(const char* beg, const char* end) {
Packit Service 7770af
      unsigned int counter = 0;
Packit Service 7770af
      bool esc = false;
Packit Service 7770af
      while (beg < end && *beg) {
Packit Service 7770af
        const char* p;
Packit Service 7770af
        if (esc) {
Packit Service 7770af
          esc = false;
Packit Service 7770af
          ++beg;
Packit Service 7770af
        } else if (*beg == '\\') {
Packit Service 7770af
          esc = true;
Packit Service 7770af
          ++beg;
Packit Service 7770af
        } else if ((p = mx(beg))) {
Packit Service 7770af
          ++counter;
Packit Service 7770af
          beg = p;
Packit Service 7770af
        }
Packit Service 7770af
        else {
Packit Service 7770af
          ++beg;
Packit Service 7770af
        }
Packit Service 7770af
      }
Packit Service 7770af
      return counter;
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    template <size_t size, prelexer mx, prelexer pad>
Packit Service 7770af
    const char* padded_token(const char* src)
Packit Service 7770af
    {
Packit Service 7770af
      size_t got = 0;
Packit Service 7770af
      const char* pos = src;
Packit Service 7770af
      while (got < size) {
Packit Service 7770af
        if (!mx(pos)) break;
Packit Service 7770af
        ++ pos; ++ got;
Packit Service 7770af
      }
Packit Service 7770af
      while (got < size) {
Packit Service 7770af
        if (!pad(pos)) break;
Packit Service 7770af
        ++ pos; ++ got;
Packit Service 7770af
      }
Packit Service 7770af
      return got ? pos : 0;
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    template <size_t min, size_t max, prelexer mx>
Packit Service 7770af
    const char* minmax_range(const char* src)
Packit Service 7770af
    {
Packit Service 7770af
      size_t got = 0;
Packit Service 7770af
      const char* pos = src;
Packit Service 7770af
      while (got < max) {
Packit Service 7770af
        if (!mx(pos)) break;
Packit Service 7770af
        ++ pos; ++ got;
Packit Service 7770af
      }
Packit Service 7770af
      if (got < min) return 0;
Packit Service 7770af
      if (got > max) return 0;
Packit Service 7770af
      return pos;
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    template <char min, char max>
Packit Service 7770af
    const char* char_range(const char* src)
Packit Service 7770af
    {
Packit Service 7770af
      if (*src < min) return 0;
Packit Service 7770af
      if (*src > max) return 0;
Packit Service 7770af
      return src + 1;
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
  }
Packit Service 7770af
}
Packit Service 7770af
Packit Service 7770af
#endif