Blame src/prelexer.cpp

Packit Service 7770af
#include "sass.hpp"
Packit Service 7770af
#include <cctype>
Packit Service 7770af
#include <iostream>
Packit Service 7770af
#include <iomanip>
Packit Service 7770af
#include "util.hpp"
Packit Service 7770af
#include "position.hpp"
Packit Service 7770af
#include "prelexer.hpp"
Packit Service 7770af
#include "constants.hpp"
Packit Service 7770af
Packit Service 7770af
Packit Service 7770af
namespace Sass {
Packit Service 7770af
  // using namespace Lexer;
Packit Service 7770af
  using namespace Constants;
Packit Service 7770af
Packit Service 7770af
  namespace Prelexer {
Packit Service 7770af
Packit Service 7770af
Packit Service 7770af
    /*
Packit Service 7770af
Packit Service 7770af
        def string_re(open, close)
Packit Service 7770af
          /#{open}((?:\\.|\#(?!\{)|[^#{close}\\#])*)(#{close}|#\{)/m
Packit Service 7770af
        end
Packit Service 7770af
      end
Packit Service 7770af
Packit Service 7770af
      # A hash of regular expressions that are used for tokenizing strings.
Packit Service 7770af
      #
Packit Service 7770af
      # The key is a `[Symbol, Boolean]` pair.
Packit Service 7770af
      # The symbol represents which style of quotation to use,
Packit Service 7770af
      # while the boolean represents whether or not the string
Packit Service 7770af
      # is following an interpolated segment.
Packit Service 7770af
      STRING_REGULAR_EXPRESSIONS = {
Packit Service 7770af
        :double => {
Packit Service 7770af
          /#{open}((?:\\.|\#(?!\{)|[^#{close}\\#])*)(#{close}|#\{)/m
Packit Service 7770af
          false => string_re('"', '"'),
Packit Service 7770af
          true => string_re('', '"')
Packit Service 7770af
        },
Packit Service 7770af
        :single => {
Packit Service 7770af
          false => string_re("'", "'"),
Packit Service 7770af
          true => string_re('', "'")
Packit Service 7770af
        },
Packit Service 7770af
        :uri => {
Packit Service 7770af
          false => /url\(#{W}(#{URLCHAR}*?)(#{W}\)|#\{)/,
Packit Service 7770af
          true => /(#{URLCHAR}*?)(#{W}\)|#\{)/
Packit Service 7770af
        },
Packit Service 7770af
        # Defined in https://developer.mozilla.org/en/CSS/@-moz-document as a
Packit Service 7770af
        # non-standard version of http://www.w3.org/TR/css3-conditional/
Packit Service 7770af
        :url_prefix => {
Packit Service 7770af
          false => /url-prefix\(#{W}(#{URLCHAR}*?)(#{W}\)|#\{)/,
Packit Service 7770af
          true => /(#{URLCHAR}*?)(#{W}\)|#\{)/
Packit Service 7770af
        },
Packit Service 7770af
        :domain => {
Packit Service 7770af
          false => /domain\(#{W}(#{URLCHAR}*?)(#{W}\)|#\{)/,
Packit Service 7770af
          true => /(#{URLCHAR}*?)(#{W}\)|#\{)/
Packit Service 7770af
        }
Packit Service 7770af
      }
Packit Service 7770af
    */
Packit Service 7770af
Packit Service 7770af
    /*
Packit Service 7770af
      /#{open}
Packit Service 7770af
        (
Packit Service 7770af
          \\.
Packit Service 7770af
          |
Packit Service 7770af
          \# (?!\{)
Packit Service 7770af
          |
Packit Service 7770af
          [^#{close}\\#]
Packit Service 7770af
        )*
Packit Service 7770af
        (#{close}|#\{)
Packit Service 7770af
      /m
Packit Service 7770af
      false => string_re('"', '"'),
Packit Service 7770af
      true => string_re('', '"')
Packit Service 7770af
    */
Packit Service 7770af
    extern const char string_double_negates[] = "\"\\#";
Packit Service 7770af
    const char* re_string_double_close(const char* src)
Packit Service 7770af
    {
Packit Service 7770af
      return sequence <
Packit Service 7770af
        // valid chars
Packit Service 7770af
        zero_plus <
Packit Service 7770af
          alternatives <
Packit Service 7770af
            // escaped char
Packit Service 7770af
            sequence <
Packit Service 7770af
              exactly <'\\'>,
Packit Service 7770af
              any_char
Packit Service 7770af
            >,
Packit Service 7770af
            // non interpolate hash
Packit Service 7770af
            sequence <
Packit Service 7770af
              exactly <'#'>,
Packit Service 7770af
              negate <
Packit Service 7770af
                exactly <'{'>
Packit Service 7770af
              >
Packit Service 7770af
            >,
Packit Service 7770af
            // other valid chars
Packit Service 7770af
            neg_class_char <
Packit Service 7770af
              string_double_negates
Packit Service 7770af
            >
Packit Service 7770af
          >
Packit Service 7770af
        >,
Packit Service 7770af
        // quoted string closer
Packit Service 7770af
        // or interpolate opening
Packit Service 7770af
        alternatives <
Packit Service 7770af
          exactly <'"'>,
Packit Service 7770af
          lookahead < exactly< hash_lbrace > >
Packit Service 7770af
        >
Packit Service 7770af
      >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* re_string_double_open(const char* src)
Packit Service 7770af
    {
Packit Service 7770af
      return sequence <
Packit Service 7770af
        // quoted string opener
Packit Service 7770af
        exactly <'"'>,
Packit Service 7770af
        // valid chars
Packit Service 7770af
        zero_plus <
Packit Service 7770af
          alternatives <
Packit Service 7770af
            // escaped char
Packit Service 7770af
            sequence <
Packit Service 7770af
              exactly <'\\'>,
Packit Service 7770af
              any_char
Packit Service 7770af
            >,
Packit Service 7770af
            // non interpolate hash
Packit Service 7770af
            sequence <
Packit Service 7770af
              exactly <'#'>,
Packit Service 7770af
              negate <
Packit Service 7770af
                exactly <'{'>
Packit Service 7770af
              >
Packit Service 7770af
            >,
Packit Service 7770af
            // other valid chars
Packit Service 7770af
            neg_class_char <
Packit Service 7770af
              string_double_negates
Packit Service 7770af
            >
Packit Service 7770af
          >
Packit Service 7770af
        >,
Packit Service 7770af
        // quoted string closer
Packit Service 7770af
        // or interpolate opening
Packit Service 7770af
        alternatives <
Packit Service 7770af
          exactly <'"'>,
Packit Service 7770af
          lookahead < exactly< hash_lbrace > >
Packit Service 7770af
        >
Packit Service 7770af
      >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    extern const char string_single_negates[] = "'\\#";
Packit Service 7770af
    const char* re_string_single_close(const char* src)
Packit Service 7770af
    {
Packit Service 7770af
      return sequence <
Packit Service 7770af
        // valid chars
Packit Service 7770af
        zero_plus <
Packit Service 7770af
          alternatives <
Packit Service 7770af
            // escaped char
Packit Service 7770af
            sequence <
Packit Service 7770af
              exactly <'\\'>,
Packit Service 7770af
              any_char
Packit Service 7770af
            >,
Packit Service 7770af
            // non interpolate hash
Packit Service 7770af
            sequence <
Packit Service 7770af
              exactly <'#'>,
Packit Service 7770af
              negate <
Packit Service 7770af
                exactly <'{'>
Packit Service 7770af
              >
Packit Service 7770af
            >,
Packit Service 7770af
            // other valid chars
Packit Service 7770af
            neg_class_char <
Packit Service 7770af
              string_single_negates
Packit Service 7770af
            >
Packit Service 7770af
          >
Packit Service 7770af
        >,
Packit Service 7770af
        // quoted string closer
Packit Service 7770af
        // or interpolate opening
Packit Service 7770af
        alternatives <
Packit Service 7770af
          exactly <'\''>,
Packit Service 7770af
          lookahead < exactly< hash_lbrace > >
Packit Service 7770af
        >
Packit Service 7770af
      >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* re_string_single_open(const char* src)
Packit Service 7770af
    {
Packit Service 7770af
      return sequence <
Packit Service 7770af
        // quoted string opener
Packit Service 7770af
        exactly <'\''>,
Packit Service 7770af
        // valid chars
Packit Service 7770af
        zero_plus <
Packit Service 7770af
          alternatives <
Packit Service 7770af
            // escaped char
Packit Service 7770af
            sequence <
Packit Service 7770af
              exactly <'\\'>,
Packit Service 7770af
              any_char
Packit Service 7770af
            >,
Packit Service 7770af
            // non interpolate hash
Packit Service 7770af
            sequence <
Packit Service 7770af
              exactly <'#'>,
Packit Service 7770af
              negate <
Packit Service 7770af
                exactly <'{'>
Packit Service 7770af
              >
Packit Service 7770af
            >,
Packit Service 7770af
            // other valid chars
Packit Service 7770af
            neg_class_char <
Packit Service 7770af
              string_single_negates
Packit Service 7770af
            >
Packit Service 7770af
          >
Packit Service 7770af
        >,
Packit Service 7770af
        // quoted string closer
Packit Service 7770af
        // or interpolate opening
Packit Service 7770af
        alternatives <
Packit Service 7770af
          exactly <'\''>,
Packit Service 7770af
          lookahead < exactly< hash_lbrace > >
Packit Service 7770af
        >
Packit Service 7770af
      >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    /*
Packit Service 7770af
      :uri => {
Packit Service 7770af
        false => /url\(#{W}(#{URLCHAR}*?)(#{W}\)|#\{)/,
Packit Service 7770af
        true => /(#{URLCHAR}*?)(#{W}\)|#\{)/
Packit Service 7770af
      },
Packit Service 7770af
    */
Packit Service 7770af
    const char* re_string_uri_close(const char* src)
Packit Service 7770af
    {
Packit Service 7770af
      return sequence <
Packit Service 7770af
        non_greedy<
Packit Service 7770af
          alternatives<
Packit Service 7770af
            class_char< real_uri_chars >,
Packit Service 7770af
            uri_character,
Packit Service 7770af
            NONASCII,
Packit Service 7770af
            ESCAPE
Packit Service 7770af
          >,
Packit Service 7770af
          alternatives<
Packit Service 7770af
            sequence < optional < W >, exactly <')'> >,
Packit Service 7770af
            lookahead < exactly< hash_lbrace > >
Packit Service 7770af
          >
Packit Service 7770af
        >,
Packit Service 7770af
        optional <
Packit Service 7770af
          sequence < optional < W >, exactly <')'> >
Packit Service 7770af
        >
Packit Service 7770af
      >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* re_string_uri_open(const char* src)
Packit Service 7770af
    {
Packit Service 7770af
      return sequence <
Packit Service 7770af
        exactly <'u'>,
Packit Service 7770af
        exactly <'r'>,
Packit Service 7770af
        exactly <'l'>,
Packit Service 7770af
        exactly <'('>,
Packit Service 7770af
        W,
Packit Service 7770af
        alternatives<
Packit Service 7770af
          quoted_string,
Packit Service 7770af
          non_greedy<
Packit Service 7770af
            alternatives<
Packit Service 7770af
              class_char< real_uri_chars >,
Packit Service 7770af
              uri_character,
Packit Service 7770af
              NONASCII,
Packit Service 7770af
              ESCAPE
Packit Service 7770af
            >,
Packit Service 7770af
            alternatives<
Packit Service 7770af
              sequence < W, exactly <')'> >,
Packit Service 7770af
              exactly< hash_lbrace >
Packit Service 7770af
            >
Packit Service 7770af
          >
Packit Service 7770af
        >
Packit Service 7770af
      >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // Match a line comment (/.*?(?=\n|\r\n?|\Z)/.
Packit Service 7770af
    const char* line_comment(const char* src)
Packit Service 7770af
    {
Packit Service 7770af
      return sequence<
Packit Service 7770af
               exactly <
Packit Service 7770af
                 slash_slash
Packit Service 7770af
               >,
Packit Service 7770af
               non_greedy<
Packit Service 7770af
                 any_char,
Packit Service 7770af
                 end_of_line
Packit Service 7770af
               >
Packit Service 7770af
             >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // Match a block comment.
Packit Service 7770af
    const char* block_comment(const char* src)
Packit Service 7770af
    {
Packit Service 7770af
      return sequence<
Packit Service 7770af
               delimited_by<
Packit Service 7770af
                 slash_star,
Packit Service 7770af
                 star_slash,
Packit Service 7770af
                 false
Packit Service 7770af
               >
Packit Service 7770af
             >(src);
Packit Service 7770af
    }
Packit Service 7770af
    /* not use anymore - remove?
Packit Service 7770af
    const char* block_comment_prefix(const char* src) {
Packit Service 7770af
      return exactly<slash_star>(src);
Packit Service 7770af
    }
Packit Service 7770af
    // Match either comment.
Packit Service 7770af
    const char* comment(const char* src) {
Packit Service 7770af
      return line_comment(src);
Packit Service 7770af
    }
Packit Service 7770af
    */
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
      return zero_plus< alternatives<spaces, line_comment> >(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* css_whitespace(const char* src) {
Packit Service 7770af
      return one_plus< alternatives<spaces, line_comment> >(src);
Packit Service 7770af
    }
Packit Service 7770af
    // Match optional_css_whitepace plus block_comments
Packit Service 7770af
    const char* optional_css_comments(const char* src) {
Packit Service 7770af
      return zero_plus< alternatives<spaces, line_comment, block_comment> >(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* css_comments(const char* src) {
Packit Service 7770af
      return one_plus< alternatives<spaces, line_comment, block_comment> >(src);
Packit Service 7770af
    }
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
      return sequence<
Packit Service 7770af
        exactly<'\\'>,
Packit Service 7770af
        alternatives <
Packit Service 7770af
          minmax_range<
Packit Service 7770af
            1, 3, xdigit
Packit Service 7770af
          >,
Packit Service 7770af
          any_char
Packit Service 7770af
        >,
Packit Service 7770af
        optional <
Packit Service 7770af
          exactly <' '>
Packit Service 7770af
        >
Packit Service 7770af
      >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // Match identifier start
Packit Service 7770af
    const char* identifier_alpha(const char* src)
Packit Service 7770af
    {
Packit Service 7770af
      return alternatives<
Packit Service 7770af
               unicode_seq,
Packit Service 7770af
               alpha,
Packit Service 7770af
               unicode,
Packit Service 7770af
               exactly<'-'>,
Packit Service 7770af
               exactly<'_'>,
Packit Service 7770af
               NONASCII,
Packit Service 7770af
               ESCAPE,
Packit Service 7770af
               escape_seq
Packit Service 7770af
             >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // Match identifier after start
Packit Service 7770af
    const char* identifier_alnum(const char* src)
Packit Service 7770af
    {
Packit Service 7770af
      return alternatives<
Packit Service 7770af
               unicode_seq,
Packit Service 7770af
               alnum,
Packit Service 7770af
               unicode,
Packit Service 7770af
               exactly<'-'>,
Packit Service 7770af
               exactly<'_'>,
Packit Service 7770af
               NONASCII,
Packit Service 7770af
               ESCAPE,
Packit Service 7770af
               escape_seq
Packit Service 7770af
             >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // Match CSS identifiers.
Packit Service 7770af
    const char* strict_identifier(const char* src)
Packit Service 7770af
    {
Packit Service 7770af
      return sequence<
Packit Service 7770af
               one_plus < strict_identifier_alpha >,
Packit Service 7770af
               zero_plus < strict_identifier_alnum >
Packit Service 7770af
               // word_boundary not needed
Packit Service 7770af
             >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // Match CSS identifiers.
Packit Service 7770af
    const char* identifier(const char* src)
Packit Service 7770af
    {
Packit Service 7770af
      return sequence<
Packit Service 7770af
               zero_plus< exactly<'-'> >,
Packit Service 7770af
               one_plus < identifier_alpha >,
Packit Service 7770af
               zero_plus < identifier_alnum >
Packit Service 7770af
               // word_boundary not needed
Packit Service 7770af
             >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* strict_identifier_alpha(const char* src)
Packit Service 7770af
    {
Packit Service 7770af
      return alternatives <
Packit Service 7770af
               alpha,
Packit Service 7770af
               unicode,
Packit Service 7770af
               escape_seq,
Packit Service 7770af
               exactly<'_'>
Packit Service 7770af
             >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* strict_identifier_alnum(const char* src)
Packit Service 7770af
    {
Packit Service 7770af
      return alternatives <
Packit Service 7770af
               alnum,
Packit Service 7770af
               unicode,
Packit Service 7770af
               escape_seq,
Packit Service 7770af
               exactly<'_'>
Packit Service 7770af
             >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // Match a single CSS unit
Packit Service 7770af
    const char* one_unit(const char* src)
Packit Service 7770af
    {
Packit Service 7770af
      return sequence <
Packit Service 7770af
               optional < exactly <'-'> >,
Packit Service 7770af
               strict_identifier_alpha,
Packit Service 7770af
               zero_plus < alternatives<
Packit Service 7770af
                 strict_identifier_alnum,
Packit Service 7770af
                 sequence <
Packit Service 7770af
                   one_plus < exactly<'-'> >,
Packit Service 7770af
                   strict_identifier_alpha
Packit Service 7770af
                 >
Packit Service 7770af
               > >
Packit Service 7770af
             >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // Match numerator/denominator CSS units
Packit Service 7770af
    const char* multiple_units(const char* src)
Packit Service 7770af
    {
Packit Service 7770af
      return
Packit Service 7770af
        sequence <
Packit Service 7770af
          one_unit,
Packit Service 7770af
          zero_plus <
Packit Service 7770af
            sequence <
Packit Service 7770af
              exactly <'*'>,
Packit Service 7770af
              one_unit
Packit Service 7770af
            >
Packit Service 7770af
          >
Packit Service 7770af
        >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // Match complex CSS unit identifiers
Packit Service 7770af
    const char* unit_identifier(const char* src)
Packit Service 7770af
    {
Packit Service 7770af
      return sequence <
Packit Service 7770af
        multiple_units,
Packit Service 7770af
        optional <
Packit Service 7770af
          sequence <
Packit Service 7770af
          exactly <'/'>,
Packit Service 7770af
          negate < sequence <
Packit Service 7770af
            exactly < calc_fn_kwd >,
Packit Service 7770af
            exactly < '(' >
Packit Service 7770af
          > >,
Packit Service 7770af
          multiple_units
Packit Service 7770af
        > >
Packit Service 7770af
      >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* identifier_alnums(const char* src)
Packit Service 7770af
    {
Packit Service 7770af
      return one_plus< identifier_alnum >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // Match number prefix ([\+\-]+)
Packit Service 7770af
    const char* number_prefix(const char* src) {
Packit Service 7770af
      return alternatives <
Packit Service 7770af
        exactly < '+' >,
Packit Service 7770af
        sequence <
Packit Service 7770af
          exactly < '-' >,
Packit Service 7770af
          optional_css_whitespace,
Packit Service 7770af
          exactly< '-' >
Packit Service 7770af
        >
Packit Service 7770af
      >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // Match interpolant schemas
Packit Service 7770af
    const char* identifier_schema(const char* src) {
Packit Service 7770af
Packit Service 7770af
      return sequence <
Packit Service 7770af
               one_plus <
Packit Service 7770af
                 sequence <
Packit Service 7770af
                   zero_plus <
Packit Service 7770af
                     alternatives <
Packit Service 7770af
                       sequence <
Packit Service 7770af
                         optional <
Packit Service 7770af
                           exactly <'$'>
Packit Service 7770af
                         >,
Packit Service 7770af
                         identifier
Packit Service 7770af
                       >,
Packit Service 7770af
                       exactly <'-'>
Packit Service 7770af
                     >
Packit Service 7770af
                   >,
Packit Service 7770af
                   interpolant,
Packit Service 7770af
                   zero_plus <
Packit Service 7770af
                     alternatives <
Packit Service 7770af
                       digits,
Packit Service 7770af
                       sequence <
Packit Service 7770af
                         optional <
Packit Service 7770af
                           exactly <'$'>
Packit Service 7770af
                         >,
Packit Service 7770af
                         identifier
Packit Service 7770af
                       >,
Packit Service 7770af
                       quoted_string,
Packit Service 7770af
                       exactly<'-'>
Packit Service 7770af
                     >
Packit Service 7770af
                   >
Packit Service 7770af
                 >
Packit Service 7770af
               >,
Packit Service 7770af
               negate <
Packit Service 7770af
                 exactly<'%'>
Packit Service 7770af
               >
Packit Service 7770af
             > (src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // interpolants can be recursive/nested
Packit Service 7770af
    const char* interpolant(const char* src) {
Packit Service 7770af
      return recursive_scopes< exactly<hash_lbrace>, exactly<rbrace> >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // $re_squote = /'(?:$re_itplnt|\\.|[^'])*'/
Packit Service 7770af
    const char* single_quoted_string(const char* src) {
Packit Service 7770af
      // match a single quoted string, while skipping interpolants
Packit Service 7770af
      return sequence <
Packit Service 7770af
        exactly <'\''>,
Packit Service 7770af
        zero_plus <
Packit Service 7770af
          alternatives <
Packit Service 7770af
            // skip escapes
Packit Service 7770af
            sequence <
Packit Service 7770af
              exactly < '\\' >,
Packit Service 7770af
              re_linebreak
Packit Service 7770af
            >,
Packit Service 7770af
            escape_seq,
Packit Service 7770af
            unicode_seq,
Packit Service 7770af
            // skip interpolants
Packit Service 7770af
            interpolant,
Packit Service 7770af
            // skip non delimiters
Packit Service 7770af
            any_char_but < '\'' >
Packit Service 7770af
          >
Packit Service 7770af
        >,
Packit Service 7770af
        exactly <'\''>
Packit Service 7770af
      >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // $re_dquote = /"(?:$re_itp|\\.|[^"])*"/
Packit Service 7770af
    const char* double_quoted_string(const char* src) {
Packit Service 7770af
      // match a single quoted string, while skipping interpolants
Packit Service 7770af
      return sequence <
Packit Service 7770af
        exactly <'"'>,
Packit Service 7770af
        zero_plus <
Packit Service 7770af
          alternatives <
Packit Service 7770af
            // skip escapes
Packit Service 7770af
            sequence <
Packit Service 7770af
              exactly < '\\' >,
Packit Service 7770af
              re_linebreak
Packit Service 7770af
            >,
Packit Service 7770af
            escape_seq,
Packit Service 7770af
            unicode_seq,
Packit Service 7770af
            // skip interpolants
Packit Service 7770af
            interpolant,
Packit Service 7770af
            // skip non delimiters
Packit Service 7770af
            any_char_but < '"' >
Packit Service 7770af
          >
Packit Service 7770af
        >,
Packit Service 7770af
        exactly <'"'>
Packit Service 7770af
      >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // $re_quoted = /(?:$re_squote|$re_dquote)/
Packit Service 7770af
    const char* quoted_string(const char* src) {
Packit Service 7770af
      // match a quoted string, while skipping interpolants
Packit Service 7770af
      return alternatives<
Packit Service 7770af
        single_quoted_string,
Packit Service 7770af
        double_quoted_string
Packit Service 7770af
      >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* sass_value(const char* src) {
Packit Service 7770af
      return alternatives <
Packit Service 7770af
        quoted_string,
Packit Service 7770af
        identifier,
Packit Service 7770af
        percentage,
Packit Service 7770af
        hex,
Packit Service 7770af
        dimension,
Packit Service 7770af
        number
Packit Service 7770af
      >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // this is basically `one_plus < sass_value >`
Packit Service 7770af
    // takes care to not parse invalid combinations
Packit Service 7770af
    const char* value_combinations(const char* src) {
Packit Service 7770af
      // `2px-2px` is invalid combo
Packit Service 7770af
      bool was_number = false;
Packit Service 7770af
      const char* pos;
Packit Service 7770af
      while (src) {
Packit Service 7770af
        if ((pos = alternatives < quoted_string, identifier, percentage, hex >(src))) {
Packit Service 7770af
          was_number = false;
Packit Service 7770af
          src = pos;
Packit Service 7770af
        } else if (!was_number && !exactly<'+'>(src) && (pos = alternatives < dimension, number >(src))) {
Packit Service 7770af
          was_number = true;
Packit Service 7770af
          src = pos;
Packit Service 7770af
        } else {
Packit Service 7770af
          break;
Packit Service 7770af
        }
Packit Service 7770af
      }
Packit Service 7770af
      return src;
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // must be at least one interpolant
Packit Service 7770af
    // can be surrounded by sass values
Packit Service 7770af
    // make sure to never parse (dim)(dim)
Packit Service 7770af
    // since this wrongly consumes `2px-1px`
Packit Service 7770af
    // `2px1px` is valid number (unit `px1px`)
Packit Service 7770af
    const char* value_schema(const char* src)
Packit Service 7770af
    {
Packit Service 7770af
      return sequence <
Packit Service 7770af
        one_plus <
Packit Service 7770af
          sequence <
Packit Service 7770af
            optional < value_combinations >,
Packit Service 7770af
            interpolant,
Packit Service 7770af
            optional < value_combinations >
Packit Service 7770af
          >
Packit Service 7770af
        >
Packit Service 7770af
      >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // Match CSS '@' keywords.
Packit Service 7770af
    const char* at_keyword(const char* src) {
Packit Service 7770af
      return sequence<exactly<'@'>, identifier>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    /*
Packit Service 7770af
        tok(%r{
Packit Service 7770af
          (
Packit Service 7770af
            \\.
Packit Service 7770af
          |
Packit Service 7770af
            (?!url\()
Packit Service 7770af
            [^"'/\#!;\{\}] # "
Packit Service 7770af
          |
Packit Service 7770af
            /(?![\*\/])
Packit Service 7770af
          |
Packit Service 7770af
            \#(?!\{)
Packit Service 7770af
          |
Packit Service 7770af
            !(?![a-z]) # TODO: never consume "!" when issue 1126 is fixed.
Packit Service 7770af
          )+
Packit Service 7770af
        }xi) || tok(COMMENT) || tok(SINGLE_LINE_COMMENT) || interp_string || interp_uri ||
Packit Service 7770af
                interpolation(:warn_for_color)
Packit Service 7770af
    */
Packit Service 7770af
    const char* re_almost_any_value_token(const char* src) {
Packit Service 7770af
Packit Service 7770af
      return alternatives <
Packit Service 7770af
        one_plus <
Packit Service 7770af
          alternatives <
Packit Service 7770af
            sequence <
Packit Service 7770af
              exactly <'\\'>,
Packit Service 7770af
              any_char
Packit Service 7770af
            >,
Packit Service 7770af
            sequence <
Packit Service 7770af
              negate <
Packit Service 7770af
                sequence <
Packit Service 7770af
                  exactly < url_kwd >,
Packit Service 7770af
                  exactly <'('>
Packit Service 7770af
                >
Packit Service 7770af
              >,
Packit Service 7770af
              neg_class_char <
Packit Service 7770af
                almost_any_value_class
Packit Service 7770af
              >
Packit Service 7770af
            >,
Packit Service 7770af
            sequence <
Packit Service 7770af
              exactly <'/'>,
Packit Service 7770af
              negate <
Packit Service 7770af
                alternatives <
Packit Service 7770af
                  exactly <'/'>,
Packit Service 7770af
                  exactly <'*'>
Packit Service 7770af
                >
Packit Service 7770af
              >
Packit Service 7770af
            >,
Packit Service 7770af
            sequence <
Packit Service 7770af
              exactly <'\\'>,
Packit Service 7770af
              exactly <'#'>,
Packit Service 7770af
              negate <
Packit Service 7770af
                exactly <'{'>
Packit Service 7770af
              >
Packit Service 7770af
            >,
Packit Service 7770af
            sequence <
Packit Service 7770af
              exactly <'!'>,
Packit Service 7770af
              negate <
Packit Service 7770af
                alpha
Packit Service 7770af
              >
Packit Service 7770af
            >
Packit Service 7770af
          >
Packit Service 7770af
        >,
Packit Service 7770af
        block_comment,
Packit Service 7770af
        line_comment,
Packit Service 7770af
        interpolant,
Packit Service 7770af
        space,
Packit Service 7770af
        sequence <
Packit Service 7770af
          exactly<'u'>,
Packit Service 7770af
          exactly<'r'>,
Packit Service 7770af
          exactly<'l'>,
Packit Service 7770af
          exactly<'('>,
Packit Service 7770af
          zero_plus <
Packit Service 7770af
            alternatives <
Packit Service 7770af
              class_char< real_uri_chars >,
Packit Service 7770af
              uri_character,
Packit Service 7770af
              NONASCII,
Packit Service 7770af
              ESCAPE
Packit Service 7770af
            >
Packit Service 7770af
          >,
Packit Service 7770af
          // false => /url\(#{W}(#{URLCHAR}*?)(#{W}\)|#\{)/,
Packit Service 7770af
          // true => /(#{URLCHAR}*?)(#{W}\)|#\{)/
Packit Service 7770af
          exactly<')'>
Packit Service 7770af
        >
Packit Service 7770af
      >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    /*
Packit Service 7770af
      DIRECTIVES = Set[:mixin, :include, :function, :return, :debug, :warn, :for,
Packit Service 7770af
        :each, :while, :if, :else, :extend, :import, :media, :charset, :content,
Packit Service 7770af
        :_moz_document, :at_root, :error]
Packit Service 7770af
    */
Packit Service 7770af
    const char* re_special_directive(const char* src) {
Packit Service 7770af
      return alternatives <
Packit Service 7770af
        word < mixin_kwd >,
Packit Service 7770af
        word < include_kwd >,
Packit Service 7770af
        word < function_kwd >,
Packit Service 7770af
        word < return_kwd >,
Packit Service 7770af
        word < debug_kwd >,
Packit Service 7770af
        word < warn_kwd >,
Packit Service 7770af
        word < for_kwd >,
Packit Service 7770af
        word < each_kwd >,
Packit Service 7770af
        word < while_kwd >,
Packit Service 7770af
        word < if_kwd >,
Packit Service 7770af
        word < else_kwd >,
Packit Service 7770af
        word < extend_kwd >,
Packit Service 7770af
        word < import_kwd >,
Packit Service 7770af
        word < media_kwd >,
Packit Service 7770af
        word < charset_kwd >,
Packit Service 7770af
        word < content_kwd >,
Packit Service 7770af
        // exactly < moz_document_kwd >,
Packit Service 7770af
        word < at_root_kwd >,
Packit Service 7770af
        word < error_kwd >
Packit Service 7770af
      >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* re_prefixed_directive(const char* src) {
Packit Service 7770af
      return sequence <
Packit Service 7770af
        optional <
Packit Service 7770af
          sequence <
Packit Service 7770af
            exactly <'-'>,
Packit Service 7770af
            one_plus < alnum >,
Packit Service 7770af
            exactly <'-'>
Packit Service 7770af
          >
Packit Service 7770af
        >,
Packit Service 7770af
        exactly < supports_kwd >
Packit Service 7770af
      >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* re_reference_combinator(const char* src) {
Packit Service 7770af
      return sequence <
Packit Service 7770af
        optional <
Packit Service 7770af
          sequence <
Packit Service 7770af
            zero_plus <
Packit Service 7770af
              exactly <'-'>
Packit Service 7770af
            >,
Packit Service 7770af
            identifier,
Packit Service 7770af
            exactly <'|'>
Packit Service 7770af
          >
Packit Service 7770af
        >,
Packit Service 7770af
        zero_plus <
Packit Service 7770af
          exactly <'-'>
Packit Service 7770af
        >,
Packit Service 7770af
        identifier
Packit Service 7770af
      >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* static_reference_combinator(const char* src) {
Packit Service 7770af
      return sequence <
Packit Service 7770af
        exactly <'/'>,
Packit Service 7770af
        re_reference_combinator,
Packit Service 7770af
        exactly <'/'>
Packit Service 7770af
      >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* schema_reference_combinator(const char* src) {
Packit Service 7770af
      return sequence <
Packit Service 7770af
        exactly <'/'>,
Packit Service 7770af
        optional <
Packit Service 7770af
          sequence <
Packit Service 7770af
            css_ip_identifier,
Packit Service 7770af
            exactly <'|'>
Packit Service 7770af
          >
Packit Service 7770af
        >,
Packit Service 7770af
        css_ip_identifier,
Packit Service 7770af
        exactly <'/'>
Packit Service 7770af
      > (src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* kwd_import(const char* src) {
Packit Service 7770af
      return word<import_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* kwd_at_root(const char* src) {
Packit Service 7770af
      return word<at_root_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* kwd_with_directive(const char* src) {
Packit Service 7770af
      return word<with_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* kwd_without_directive(const char* src) {
Packit Service 7770af
      return word<without_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* kwd_media(const char* src) {
Packit Service 7770af
      return word<media_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* kwd_supports_directive(const char* src) {
Packit Service 7770af
      return word<supports_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* kwd_mixin(const char* src) {
Packit Service 7770af
      return word<mixin_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* kwd_function(const char* src) {
Packit Service 7770af
      return word<function_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* kwd_return_directive(const char* src) {
Packit Service 7770af
      return word<return_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* kwd_include_directive(const char* src) {
Packit Service 7770af
      return word<include_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* kwd_content_directive(const char* src) {
Packit Service 7770af
      return word<content_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* kwd_charset_directive(const char* src) {
Packit Service 7770af
      return word<charset_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* kwd_extend(const char* src) {
Packit Service 7770af
      return word<extend_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
Packit Service 7770af
    const char* kwd_if_directive(const char* src) {
Packit Service 7770af
      return word<if_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* kwd_else_directive(const char* src) {
Packit Service 7770af
      return word<else_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* elseif_directive(const char* src) {
Packit Service 7770af
      return sequence< exactly< else_kwd >,
Packit Service 7770af
                                optional_css_comments,
Packit Service 7770af
                                word< if_after_else_kwd > >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* kwd_for_directive(const char* src) {
Packit Service 7770af
      return word<for_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* kwd_from(const char* src) {
Packit Service 7770af
      return word<from_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* kwd_to(const char* src) {
Packit Service 7770af
      return word<to_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* kwd_through(const char* src) {
Packit Service 7770af
      return word<through_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* kwd_each_directive(const char* src) {
Packit Service 7770af
      return word<each_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* kwd_in(const char* src) {
Packit Service 7770af
      return word<in_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* kwd_while_directive(const char* src) {
Packit Service 7770af
      return word<while_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* name(const char* src) {
Packit Service 7770af
      return one_plus< alternatives< alnum,
Packit Service 7770af
                                     exactly<'-'>,
Packit Service 7770af
                                     exactly<'_'>,
Packit Service 7770af
                                     escape_seq > >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* kwd_warn(const char* src) {
Packit Service 7770af
      return word<warn_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* kwd_err(const char* src) {
Packit Service 7770af
      return word<error_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* kwd_dbg(const char* src) {
Packit Service 7770af
      return word<debug_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    /* not used anymore - remove?
Packit Service 7770af
    const char* directive(const char* src) {
Packit Service 7770af
      return sequence< exactly<'@'>, identifier >(src);
Packit Service 7770af
    } */
Packit Service 7770af
Packit Service 7770af
    const char* kwd_null(const char* src) {
Packit Service 7770af
      return word<null_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* css_identifier(const char* src) {
Packit Service 7770af
      return sequence <
Packit Service 7770af
               zero_plus <
Packit Service 7770af
                 exactly <'-'>
Packit Service 7770af
               >,
Packit Service 7770af
               identifier
Packit Service 7770af
             >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* css_ip_identifier(const char* src) {
Packit Service 7770af
      return sequence <
Packit Service 7770af
               zero_plus <
Packit Service 7770af
                 exactly <'-'>
Packit Service 7770af
               >,
Packit Service 7770af
               alternatives <
Packit Service 7770af
                 identifier,
Packit Service 7770af
                 interpolant
Packit Service 7770af
               >
Packit Service 7770af
             >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // Match CSS type selectors
Packit Service 7770af
    const char* namespace_prefix(const char* src) {
Packit Service 7770af
      return sequence <
Packit Service 7770af
               optional <
Packit Service 7770af
                 alternatives <
Packit Service 7770af
                   exactly <'*'>,
Packit Service 7770af
                   css_identifier
Packit Service 7770af
                 >
Packit Service 7770af
               >,
Packit Service 7770af
               exactly <'|'>,
Packit Service 7770af
               negate <
Packit Service 7770af
                 exactly <'='>
Packit Service 7770af
               >
Packit Service 7770af
             >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // Match CSS type selectors
Packit Service 7770af
    const char* namespace_schema(const char* src) {
Packit Service 7770af
      return sequence <
Packit Service 7770af
               optional <
Packit Service 7770af
                 alternatives <
Packit Service 7770af
                   exactly <'*'>,
Packit Service 7770af
                   css_ip_identifier
Packit Service 7770af
                 >
Packit Service 7770af
               >,
Packit Service 7770af
               exactly<'|'>,
Packit Service 7770af
               negate <
Packit Service 7770af
                 exactly <'='>
Packit Service 7770af
               >
Packit Service 7770af
             >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* hyphens_and_identifier(const char* src) {
Packit Service 7770af
      return sequence< zero_plus< exactly< '-' > >, identifier_alnums >(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* hyphens_and_name(const char* src) {
Packit Service 7770af
      return sequence< zero_plus< exactly< '-' > >, name >(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* universal(const char* src) {
Packit Service 7770af
      return sequence< optional<namespace_schema>, exactly<'*'> >(src);
Packit Service 7770af
    }
Packit Service 7770af
    // Match CSS id names.
Packit Service 7770af
    const char* id_name(const char* src) {
Packit Service 7770af
      return sequence<exactly<'#'>, identifier_alnums >(src);
Packit Service 7770af
    }
Packit Service 7770af
    // Match CSS class names.
Packit Service 7770af
    const char* class_name(const char* src) {
Packit Service 7770af
      return sequence<exactly<'.'>, identifier >(src);
Packit Service 7770af
    }
Packit Service 7770af
    // Attribute name in an attribute selector.
Packit Service 7770af
    const char* attribute_name(const char* src) {
Packit Service 7770af
      return alternatives< sequence< optional<namespace_schema>, identifier>,
Packit Service 7770af
                           identifier >(src);
Packit Service 7770af
    }
Packit Service 7770af
    // match placeholder selectors
Packit Service 7770af
    const char* placeholder(const char* src) {
Packit Service 7770af
      return sequence<exactly<'%'>, identifier_alnums >(src);
Packit Service 7770af
    }
Packit Service 7770af
    // Match CSS numeric constants.
Packit Service 7770af
Packit Service 7770af
    const char* op(const char* src) {
Packit Service 7770af
      return class_char<op_chars>(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* sign(const char* src) {
Packit Service 7770af
      return class_char<sign_chars>(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* unsigned_number(const char* src) {
Packit Service 7770af
      return alternatives<sequence< zero_plus<digits>,
Packit Service 7770af
                                    exactly<'.'>,
Packit Service 7770af
                                    one_plus<digits> >,
Packit Service 7770af
                          digits>(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* number(const char* src) {
Packit Service 7770af
      return sequence< optional<sign>, unsigned_number>(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* coefficient(const char* src) {
Packit Service 7770af
      return alternatives< sequence< optional<sign>, digits >,
Packit Service 7770af
                           sign >(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* binomial(const char* src) {
Packit Service 7770af
      return sequence <
Packit Service 7770af
               optional < sign >,
Packit Service 7770af
               optional < digits >,
Packit Service 7770af
               exactly <'n'>,
Packit Service 7770af
               zero_plus < sequence <
Packit Service 7770af
                 optional_css_whitespace, sign,
Packit Service 7770af
                 optional_css_whitespace, digits
Packit Service 7770af
               > >
Packit Service 7770af
             >(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* percentage(const char* src) {
Packit Service 7770af
      return sequence< number, exactly<'%'> >(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* ampersand(const char* src) {
Packit Service 7770af
      return exactly<'&'>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    /* not used anymore - remove?
Packit Service 7770af
    const char* em(const char* src) {
Packit Service 7770af
      return sequence< number, exactly<em_kwd> >(src);
Packit Service 7770af
    } */
Packit Service 7770af
    const char* dimension(const char* src) {
Packit Service 7770af
      return sequence<number, unit_identifier >(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* hex(const char* src) {
Packit Service 7770af
      const char* p = sequence< exactly<'#'>, one_plus<xdigit> >(src);
Packit Service 7770af
      ptrdiff_t len = p - src;
Packit Service 7770af
      return (len != 4 && len != 7) ? 0 : p;
Packit Service 7770af
    }
Packit Service 7770af
    const char* hexa(const char* src) {
Packit Service 7770af
      const char* p = sequence< exactly<'#'>, one_plus<xdigit> >(src);
Packit Service 7770af
      ptrdiff_t len = p - src;
Packit Service 7770af
      return (len != 4 && len != 7 && len != 9) ? 0 : p;
Packit Service 7770af
    }
Packit Service 7770af
    const char* hex0(const char* src) {
Packit Service 7770af
      const char* p = sequence< exactly<'0'>, exactly<'x'>, one_plus<xdigit> >(src);
Packit Service 7770af
      ptrdiff_t len = p - src;
Packit Service 7770af
      return (len != 5 && len != 8) ? 0 : p;
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    /* no longer used - remove?
Packit Service 7770af
    const char* rgb_prefix(const char* src) {
Packit Service 7770af
      return word<rgb_kwd>(src);
Packit Service 7770af
    }*/
Packit Service 7770af
    // Match CSS uri specifiers.
Packit Service 7770af
Packit Service 7770af
    const char* uri_prefix(const char* src) {
Packit Service 7770af
      return sequence <
Packit Service 7770af
        exactly <
Packit Service 7770af
          url_kwd
Packit Service 7770af
        >,
Packit Service 7770af
        zero_plus <
Packit Service 7770af
          sequence <
Packit Service 7770af
            exactly <'-'>,
Packit Service 7770af
            one_plus <
Packit Service 7770af
              alpha
Packit Service 7770af
            >
Packit Service 7770af
          >
Packit Service 7770af
        >,
Packit Service 7770af
        exactly <'('>
Packit Service 7770af
      >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // TODO: rename the following two functions
Packit Service 7770af
    /* no longer used - remove?
Packit Service 7770af
    const char* uri(const char* src) {
Packit Service 7770af
      return sequence< exactly<url_kwd>,
Packit Service 7770af
                       optional<spaces>,
Packit Service 7770af
                       quoted_string,
Packit Service 7770af
                       optional<spaces>,
Packit Service 7770af
                       exactly<')'> >(src);
Packit Service 7770af
    }*/
Packit Service 7770af
    /* no longer used - remove?
Packit Service 7770af
    const char* url_value(const char* src) {
Packit Service 7770af
      return sequence< optional< sequence< identifier, exactly<':'> > >, // optional protocol
Packit Service 7770af
                       one_plus< sequence< zero_plus< exactly<'/'> >, filename > >, // one or more folders and/or trailing filename
Packit Service 7770af
                       optional< exactly<'/'> > >(src);
Packit Service 7770af
    }*/
Packit Service 7770af
    /* no longer used - remove?
Packit Service 7770af
    const char* url_schema(const char* src) {
Packit Service 7770af
      return sequence< optional< sequence< identifier, exactly<':'> > >, // optional protocol
Packit Service 7770af
                       filename_schema >(src); // optional trailing slash
Packit Service 7770af
    }*/
Packit Service 7770af
    // Match CSS "!important" keyword.
Packit Service 7770af
    const char* kwd_important(const char* src) {
Packit Service 7770af
      return sequence< exactly<'!'>,
Packit Service 7770af
                       optional_css_whitespace,
Packit Service 7770af
                       word<important_kwd> >(src);
Packit Service 7770af
    }
Packit Service 7770af
    // Match CSS "!optional" keyword.
Packit Service 7770af
    const char* kwd_optional(const char* src) {
Packit Service 7770af
      return sequence< exactly<'!'>,
Packit Service 7770af
      optional_css_whitespace,
Packit Service 7770af
      word<optional_kwd> >(src);
Packit Service 7770af
    }
Packit Service 7770af
    // Match Sass "!default" keyword.
Packit Service 7770af
    const char* default_flag(const char* src) {
Packit Service 7770af
      return sequence< exactly<'!'>,
Packit Service 7770af
                       optional_css_whitespace,
Packit Service 7770af
                       word<default_kwd> >(src);
Packit Service 7770af
    }
Packit Service 7770af
    // Match Sass "!global" keyword.
Packit Service 7770af
    const char* global_flag(const char* src) {
Packit Service 7770af
      return sequence< exactly<'!'>,
Packit Service 7770af
                       optional_css_whitespace,
Packit Service 7770af
                       word<global_kwd> >(src);
Packit Service 7770af
    }
Packit Service 7770af
    // Match CSS pseudo-class/element prefixes.
Packit Service 7770af
    const char* pseudo_prefix(const char* src) {
Packit Service 7770af
      return sequence< exactly<':'>, optional< exactly<':'> > >(src);
Packit Service 7770af
    }
Packit Service 7770af
    // Match CSS function call openers.
Packit Service 7770af
    const char* functional_schema(const char* src) {
Packit Service 7770af
      return sequence <
Packit Service 7770af
               one_plus <
Packit Service 7770af
                 sequence <
Packit Service 7770af
                   zero_plus <
Packit Service 7770af
                     alternatives <
Packit Service 7770af
                       identifier,
Packit Service 7770af
                       exactly <'-'>
Packit Service 7770af
                     >
Packit Service 7770af
                   >,
Packit Service 7770af
                   one_plus <
Packit Service 7770af
                     sequence <
Packit Service 7770af
                       interpolant,
Packit Service 7770af
                       alternatives <
Packit Service 7770af
                         digits,
Packit Service 7770af
                         identifier,
Packit Service 7770af
                         exactly<'+'>,
Packit Service 7770af
                         exactly<'-'>
Packit Service 7770af
                       >
Packit Service 7770af
                     >
Packit Service 7770af
                   >
Packit Service 7770af
                 >
Packit Service 7770af
               >,
Packit Service 7770af
               negate <
Packit Service 7770af
                 exactly <'%'>
Packit Service 7770af
               >,
Packit Service 7770af
               lookahead <
Packit Service 7770af
                 exactly <'('>
Packit Service 7770af
               >
Packit Service 7770af
             > (src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* re_nothing(const char* src) {
Packit Service 7770af
      return src;
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* re_functional(const char* src) {
Packit Service 7770af
      return sequence< identifier, optional < block_comment >, exactly<'('> >(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* re_pseudo_selector(const char* src) {
Packit Service 7770af
      return sequence< identifier, optional < block_comment >, exactly<'('> >(src);
Packit Service 7770af
    }
Packit Service 7770af
    // Match the CSS negation pseudo-class.
Packit Service 7770af
    const char* pseudo_not(const char* src) {
Packit Service 7770af
      return word< pseudo_not_kwd >(src);
Packit Service 7770af
    }
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
      return word<even_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* odd(const char* src) {
Packit Service 7770af
      return word<odd_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
    // Match CSS attribute-matching operators.
Packit Service 7770af
    const char* exact_match(const char* src) { return exactly<'='>(src); }
Packit Service 7770af
    const char* class_match(const char* src) { return exactly<tilde_equal>(src); }
Packit Service 7770af
    const char* dash_match(const char* src) { return exactly<pipe_equal>(src); }
Packit Service 7770af
    const char* prefix_match(const char* src) { return exactly<caret_equal>(src); }
Packit Service 7770af
    const char* suffix_match(const char* src) { return exactly<dollar_equal>(src); }
Packit Service 7770af
    const char* substring_match(const char* src) { return exactly<star_equal>(src); }
Packit Service 7770af
    // Match CSS combinators.
Packit Service 7770af
    /* not used anymore - remove?
Packit Service 7770af
    const char* adjacent_to(const char* src) {
Packit Service 7770af
      return sequence< optional_spaces, exactly<'+'> >(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* precedes(const char* src) {
Packit Service 7770af
      return sequence< optional_spaces, exactly<'~'> >(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* parent_of(const char* src) {
Packit Service 7770af
      return sequence< optional_spaces, exactly<'>'> >(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* ancestor_of(const char* src) {
Packit Service 7770af
      return sequence< spaces, negate< exactly<'{'> > >(src);
Packit Service 7770af
    }*/
Packit Service 7770af
Packit Service 7770af
    // Match SCSS variable names.
Packit Service 7770af
    const char* variable(const char* src) {
Packit Service 7770af
      return sequence<exactly<'$'>, identifier>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // parse `calc`, `-a-calc` and `--b-c-calc`
Packit Service 7770af
    // but do not parse `foocalc` or `foo-calc`
Packit Service 7770af
    const char* calc_fn_call(const char* src) {
Packit Service 7770af
      return sequence <
Packit Service 7770af
        optional < sequence <
Packit Service 7770af
          hyphens,
Packit Service 7770af
          one_plus < sequence <
Packit Service 7770af
            strict_identifier,
Packit Service 7770af
            hyphens
Packit Service 7770af
          > >
Packit Service 7770af
        > >,
Packit Service 7770af
        exactly < calc_fn_kwd >,
Packit Service 7770af
        word_boundary
Packit Service 7770af
      >(src);
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
      return word<true_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* kwd_false(const char* src) {
Packit Service 7770af
      return word<false_kwd>(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* kwd_only(const char* src) {
Packit Service 7770af
      return keyword < only_kwd >(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* kwd_and(const char* src) {
Packit Service 7770af
      return keyword < and_kwd >(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* kwd_or(const char* src) {
Packit Service 7770af
      return keyword < or_kwd >(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* kwd_not(const char* src) {
Packit Service 7770af
      return keyword < not_kwd >(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* kwd_eq(const char* src) {
Packit Service 7770af
      return exactly<eq>(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* kwd_neq(const char* src) {
Packit Service 7770af
      return exactly<neq>(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* kwd_gt(const char* src) {
Packit Service 7770af
      return exactly<gt>(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* kwd_gte(const char* src) {
Packit Service 7770af
      return exactly<gte>(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* kwd_lt(const char* src) {
Packit Service 7770af
      return exactly<lt>(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* kwd_lte(const char* src) {
Packit Service 7770af
      return exactly<lte>(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // match specific IE syntax
Packit Service 7770af
    const char* ie_progid(const char* src) {
Packit Service 7770af
      return sequence <
Packit Service 7770af
        word<progid_kwd>,
Packit Service 7770af
        exactly<':'>,
Packit Service 7770af
        alternatives< identifier_schema, identifier >,
Packit Service 7770af
        zero_plus< sequence<
Packit Service 7770af
          exactly<'.'>,
Packit Service 7770af
          alternatives< identifier_schema, identifier >
Packit Service 7770af
        > >,
Packit Service 7770af
        zero_plus < sequence<
Packit Service 7770af
          exactly<'('>,
Packit Service 7770af
          optional_css_whitespace,
Packit Service 7770af
          optional < sequence<
Packit Service 7770af
            alternatives< variable, identifier_schema, identifier >,
Packit Service 7770af
            optional_css_whitespace,
Packit Service 7770af
            exactly<'='>,
Packit Service 7770af
            optional_css_whitespace,
Packit Service 7770af
            alternatives< variable, identifier_schema, identifier, quoted_string, number, hexa >,
Packit Service 7770af
            zero_plus< sequence<
Packit Service 7770af
              optional_css_whitespace,
Packit Service 7770af
              exactly<','>,
Packit Service 7770af
              optional_css_whitespace,
Packit Service 7770af
              sequence<
Packit Service 7770af
                alternatives< variable, identifier_schema, identifier >,
Packit Service 7770af
                optional_css_whitespace,
Packit Service 7770af
                exactly<'='>,
Packit Service 7770af
                optional_css_whitespace,
Packit Service 7770af
                alternatives< variable, identifier_schema, identifier, quoted_string, number, hexa >
Packit Service 7770af
              >
Packit Service 7770af
            > >
Packit Service 7770af
          > >,
Packit Service 7770af
          optional_css_whitespace,
Packit Service 7770af
          exactly<')'>
Packit Service 7770af
        > >
Packit Service 7770af
      >(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* ie_expression(const char* src) {
Packit Service 7770af
      return sequence < word<expression_kwd>, exactly<'('>, skip_over_scopes< exactly<'('>, exactly<')'> > >(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* ie_property(const char* src) {
Packit Service 7770af
      return alternatives < ie_expression, ie_progid >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // const char* ie_args(const char* src) {
Packit Service 7770af
    //   return sequence< alternatives< ie_keyword_arg, value_schema, quoted_string, interpolant, number, identifier, delimited_by< '(', ')', true> >,
Packit Service 7770af
    //                    zero_plus< sequence< optional_css_whitespace, exactly<','>, optional_css_whitespace, alternatives< ie_keyword_arg, value_schema, quoted_string, interpolant, number, identifier, delimited_by<'(', ')', true> > > > >(src);
Packit Service 7770af
    // }
Packit Service 7770af
Packit Service 7770af
    const char* ie_keyword_arg_property(const char* src) {
Packit Service 7770af
      return alternatives <
Packit Service 7770af
          variable,
Packit Service 7770af
          identifier_schema,
Packit Service 7770af
          identifier
Packit Service 7770af
        >(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* ie_keyword_arg_value(const char* src) {
Packit Service 7770af
      return alternatives <
Packit Service 7770af
          variable,
Packit Service 7770af
          identifier_schema,
Packit Service 7770af
          identifier,
Packit Service 7770af
          quoted_string,
Packit Service 7770af
          number,
Packit Service 7770af
          hexa,
Packit Service 7770af
          sequence <
Packit Service 7770af
            exactly < '(' >,
Packit Service 7770af
            skip_over_scopes <
Packit Service 7770af
              exactly < '(' >,
Packit Service 7770af
              exactly < ')' >
Packit Service 7770af
            >
Packit Service 7770af
          >
Packit Service 7770af
        >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* ie_keyword_arg(const char* src) {
Packit Service 7770af
      return sequence <
Packit Service 7770af
        ie_keyword_arg_property,
Packit Service 7770af
        optional_css_whitespace,
Packit Service 7770af
        exactly<'='>,
Packit Service 7770af
        optional_css_whitespace,
Packit Service 7770af
        ie_keyword_arg_value
Packit Service 7770af
      >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // Path matching functions.
Packit Service 7770af
    /* not used anymore - remove?
Packit Service 7770af
    const char* folder(const char* src) {
Packit Service 7770af
      return sequence< zero_plus< any_char_except<'/'> >,
Packit Service 7770af
                       exactly<'/'> >(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* folders(const char* src) {
Packit Service 7770af
      return zero_plus< folder >(src);
Packit Service 7770af
    }*/
Packit Service 7770af
    /* not used anymore - remove?
Packit Service 7770af
    const char* chunk(const char* src) {
Packit Service 7770af
      char inside_str = 0;
Packit Service 7770af
      const char* p = src;
Packit Service 7770af
      size_t depth = 0;
Packit Service 7770af
      while (true) {
Packit Service 7770af
        if (!*p) {
Packit Service 7770af
          return 0;
Packit Service 7770af
        }
Packit Service 7770af
        else if (!inside_str && (*p == '"' || *p == '\'')) {
Packit Service 7770af
          inside_str = *p;
Packit Service 7770af
        }
Packit Service 7770af
        else if (*p == inside_str && *(p-1) != '\\') {
Packit Service 7770af
          inside_str = 0;
Packit Service 7770af
        }
Packit Service 7770af
        else if (*p == '(' && !inside_str) {
Packit Service 7770af
          ++depth;
Packit Service 7770af
        }
Packit Service 7770af
        else if (*p == ')' && !inside_str) {
Packit Service 7770af
          if (depth == 0) return p;
Packit Service 7770af
          else            --depth;
Packit Service 7770af
        }
Packit Service 7770af
        ++p;
Packit Service 7770af
      }
Packit Service 7770af
      // unreachable
Packit Service 7770af
      return 0;
Packit Service 7770af
    }
Packit Service 7770af
    */
Packit Service 7770af
Packit Service 7770af
    // follow the CSS spec more closely and see if this helps us scan URLs correctly
Packit Service 7770af
    /* not used anymore - remove?
Packit Service 7770af
    const char* NL(const char* src) {
Packit Service 7770af
      return alternatives< exactly<'\n'>,
Packit Service 7770af
                           sequence< exactly<'\r'>, exactly<'\n'> >,
Packit Service 7770af
                           exactly<'\r'>,
Packit Service 7770af
                           exactly<'\f'> >(src);
Packit Service 7770af
    }*/
Packit Service 7770af
Packit Service 7770af
    const char* H(const char* src) {
Packit Service 7770af
      return std::isxdigit(*src) ? src+1 : 0;
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* W(const char* src) {
Packit Service 7770af
      return zero_plus< alternatives<
Packit Service 7770af
        space,
Packit Service 7770af
        exactly< '\t' >,
Packit Service 7770af
        exactly< '\r' >,
Packit Service 7770af
        exactly< '\n' >,
Packit Service 7770af
        exactly< '\f' >
Packit Service 7770af
      > >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* UUNICODE(const char* src) {
Packit Service 7770af
      return sequence< exactly<'\\'>,
Packit Service 7770af
                       between<H, 1, 6>,
Packit Service 7770af
                       optional< W >
Packit Service 7770af
                       >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* NONASCII(const char* src) {
Packit Service 7770af
      return nonascii(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* ESCAPE(const char* src) {
Packit Service 7770af
      return alternatives<
Packit Service 7770af
        UUNICODE,
Packit Service 7770af
        sequence<
Packit Service 7770af
          exactly<'\\'>,
Packit Service 7770af
          alternatives<
Packit Service 7770af
            NONASCII,
Packit Service 7770af
            escapable_character
Packit Service 7770af
          >
Packit Service 7770af
        >
Packit Service 7770af
      >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
Packit Service 7770af
    // const char* real_uri_prefix(const char* src) {
Packit Service 7770af
    //   return alternatives<
Packit Service 7770af
    //     exactly< url_kwd >,
Packit Service 7770af
    //     exactly< url_prefix_kwd >
Packit Service 7770af
    //   >(src);
Packit Service 7770af
    // }
Packit Service 7770af
Packit Service 7770af
    const char* real_uri_suffix(const char* src) {
Packit Service 7770af
      return sequence< W, exactly< ')' > >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* real_uri_value(const char* src) {
Packit Service 7770af
      return
Packit Service 7770af
      sequence<
Packit Service 7770af
        non_greedy<
Packit Service 7770af
          alternatives<
Packit Service 7770af
            class_char< real_uri_chars >,
Packit Service 7770af
            uri_character,
Packit Service 7770af
            NONASCII,
Packit Service 7770af
            ESCAPE
Packit Service 7770af
          >,
Packit Service 7770af
          alternatives<
Packit Service 7770af
            real_uri_suffix,
Packit Service 7770af
            exactly< hash_lbrace >
Packit Service 7770af
          >
Packit Service 7770af
        >
Packit Service 7770af
      >
Packit Service 7770af
      (src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* static_string(const char* src) {
Packit Service 7770af
      const char* pos = src;
Packit Service 7770af
      const char * s = quoted_string(pos);
Packit Service 7770af
      Token t(pos, s);
Packit Service 7770af
      const unsigned int p = count_interval< interpolant >(t.begin, t.end);
Packit Service 7770af
      return (p == 0) ? t.end : 0;
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* unicode_seq(const char* src) {
Packit Service 7770af
      return sequence <
Packit Service 7770af
        alternatives <
Packit Service 7770af
          exactly< 'U' >,
Packit Service 7770af
          exactly< 'u' >
Packit Service 7770af
        >,
Packit Service 7770af
        exactly< '+' >,
Packit Service 7770af
        padded_token <
Packit Service 7770af
          6, xdigit,
Packit Service 7770af
          exactly < '?' >
Packit Service 7770af
        >
Packit Service 7770af
      >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* static_component(const char* src) {
Packit Service 7770af
      return alternatives< identifier,
Packit Service 7770af
                           static_string,
Packit Service 7770af
                           percentage,
Packit Service 7770af
                           hex,
Packit Service 7770af
                           exactly<'|'>,
Packit Service 7770af
                           // exactly<'+'>,
Packit Service 7770af
                           sequence < number, unit_identifier >,
Packit Service 7770af
                           number,
Packit Service 7770af
                           sequence< exactly<'!'>, word<important_kwd> >
Packit Service 7770af
                          >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* static_property(const char* src) {
Packit Service 7770af
      return
Packit Service 7770af
        sequence <
Packit Service 7770af
          zero_plus<
Packit Service 7770af
            sequence <
Packit Service 7770af
              optional_css_comments,
Packit Service 7770af
              alternatives <
Packit Service 7770af
                exactly<','>,
Packit Service 7770af
                exactly<'('>,
Packit Service 7770af
                exactly<')'>,
Packit Service 7770af
                kwd_optional,
Packit Service 7770af
                quoted_string,
Packit Service 7770af
                interpolant,
Packit Service 7770af
                identifier,
Packit Service 7770af
                percentage,
Packit Service 7770af
                dimension,
Packit Service 7770af
                variable,
Packit Service 7770af
                alnum,
Packit Service 7770af
                sequence <
Packit Service 7770af
                  exactly <'\\'>,
Packit Service 7770af
                  any_char
Packit Service 7770af
                >
Packit Service 7770af
              >
Packit Service 7770af
            >
Packit Service 7770af
          >,
Packit Service 7770af
          lookahead <
Packit Service 7770af
            sequence <
Packit Service 7770af
              optional_css_comments,
Packit Service 7770af
              alternatives <
Packit Service 7770af
                exactly <';'>,
Packit Service 7770af
                exactly <'}'>,
Packit Service 7770af
                end_of_file
Packit Service 7770af
              >
Packit Service 7770af
            >
Packit Service 7770af
          >
Packit Service 7770af
        >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* static_value(const char* src) {
Packit Service 7770af
      return sequence< sequence<
Packit Service 7770af
                         static_component,
Packit Service 7770af
                         zero_plus< identifier >
Packit Service 7770af
                       >,
Packit Service 7770af
                       zero_plus < sequence<
Packit Service 7770af
                                     alternatives<
Packit Service 7770af
                                       sequence< optional_spaces, alternatives<
Packit Service 7770af
                                         exactly < '/' >,
Packit Service 7770af
                                         exactly < ',' >,
Packit Service 7770af
                                         exactly < ' ' >
Packit Service 7770af
                                       >, optional_spaces >,
Packit Service 7770af
                                       spaces
Packit Service 7770af
                                     >,
Packit Service 7770af
                                     static_component
Packit Service 7770af
                       > >,
Packit Service 7770af
                       zero_plus < spaces >,
Packit Service 7770af
                       alternatives< exactly<';'>, exactly<'}'> >
Packit Service 7770af
                      >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* parenthese_scope(const char* src) {
Packit Service 7770af
      return sequence <
Packit Service 7770af
        exactly < '(' >,
Packit Service 7770af
        skip_over_scopes <
Packit Service 7770af
          exactly < '(' >,
Packit Service 7770af
          exactly < ')' >
Packit Service 7770af
        >
Packit Service 7770af
      >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* re_selector_list(const char* src) {
Packit Service 7770af
      return alternatives <
Packit Service 7770af
        // partial bem selector
Packit Service 7770af
        sequence <
Packit Service 7770af
          ampersand,
Packit Service 7770af
          one_plus <
Packit Service 7770af
            exactly < '-' >
Packit Service 7770af
          >,
Packit Service 7770af
          word_boundary,
Packit Service 7770af
          optional_spaces
Packit Service 7770af
        >,
Packit Service 7770af
        // main selector matching
Packit Service 7770af
        one_plus <
Packit Service 7770af
          alternatives <
Packit Service 7770af
            // consume whitespace and comments
Packit Service 7770af
            spaces, block_comment, line_comment,
Packit Service 7770af
            // match `/deep/` selector (pass-trough)
Packit Service 7770af
            // there is no functionality for it yet
Packit Service 7770af
            schema_reference_combinator,
Packit Service 7770af
            // match selector ops /[*&%,\[\]]/
Packit Service 7770af
            class_char < selector_lookahead_ops >,
Packit Service 7770af
            // match selector combinators /[>+~]/
Packit Service 7770af
            class_char < selector_combinator_ops >,
Packit Service 7770af
            // match pseudo selectors
Packit Service 7770af
            sequence <
Packit Service 7770af
              exactly <'('>,
Packit Service 7770af
              optional_spaces,
Packit Service 7770af
              optional <re_selector_list>,
Packit Service 7770af
              optional_spaces,
Packit Service 7770af
              exactly <')'>
Packit Service 7770af
            >,
Packit Service 7770af
            // match attribute compare operators
Packit Service 7770af
            alternatives <
Packit Service 7770af
              exact_match, class_match, dash_match,
Packit Service 7770af
              prefix_match, suffix_match, substring_match
Packit Service 7770af
            >,
Packit Service 7770af
            // main selector match
Packit Service 7770af
            sequence <
Packit Service 7770af
              // allow namespace prefix
Packit Service 7770af
              optional < namespace_schema >,
Packit Service 7770af
              // modifiers prefixes
Packit Service 7770af
              alternatives <
Packit Service 7770af
                sequence <
Packit Service 7770af
                  exactly <'#'>,
Packit Service 7770af
                  // not for interpolation
Packit Service 7770af
                  negate < exactly <'{'> >
Packit Service 7770af
                >,
Packit Service 7770af
                // class match
Packit Service 7770af
                exactly <'.'>,
Packit Service 7770af
                // single or double colon
Packit Service 7770af
                sequence <
Packit Service 7770af
                  optional < pseudo_prefix >,
Packit Service 7770af
                  // fix libsass issue 2376
Packit Service 7770af
                  negate < exactly < url_kwd > >
Packit Service 7770af
                >
Packit Service 7770af
              >,
Packit Service 7770af
              // accept hypens in token
Packit Service 7770af
              one_plus < sequence <
Packit Service 7770af
                // can start with hyphens
Packit Service 7770af
                zero_plus <
Packit Service 7770af
                  sequence <
Packit Service 7770af
                    exactly <'-'>,
Packit Service 7770af
                    optional_spaces
Packit Service 7770af
                  >
Packit Service 7770af
                >,
Packit Service 7770af
                // now the main token
Packit Service 7770af
                alternatives <
Packit Service 7770af
                  kwd_optional,
Packit Service 7770af
                  exactly <'*'>,
Packit Service 7770af
                  quoted_string,
Packit Service 7770af
                  interpolant,
Packit Service 7770af
                  identifier,
Packit Service 7770af
                  variable,
Packit Service 7770af
                  percentage,
Packit Service 7770af
                  binomial,
Packit Service 7770af
                  dimension,
Packit Service 7770af
                  alnum
Packit Service 7770af
                >
Packit Service 7770af
              > >,
Packit Service 7770af
              // can also end with hyphens
Packit Service 7770af
              zero_plus < exactly<'-'> >
Packit Service 7770af
            >
Packit Service 7770af
          >
Packit Service 7770af
        >
Packit Service 7770af
      >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    const char* type_selector(const char* src) {
Packit Service 7770af
      return sequence< optional<namespace_schema>, identifier>(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* re_type_selector(const char* src) {
Packit Service 7770af
      return alternatives< type_selector, universal, quoted_string, dimension, percentage, number, identifier_alnums >(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* re_type_selector2(const char* src) {
Packit Service 7770af
      return alternatives< type_selector, universal, quoted_string, dimension, percentage, number, identifier_alnums >(src);
Packit Service 7770af
    }
Packit Service 7770af
    const char* re_static_expression(const char* src) {
Packit Service 7770af
      return sequence< number, optional_spaces, exactly<'/'>, optional_spaces, number >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
    // lexer special_fn: these functions cannot be overloaded
Packit Service 7770af
    // (/((-[\w-]+-)?(calc|element)|expression|progid:[a-z\.]*)\(/i)
Packit Service 7770af
    const char* re_special_fun(const char* src) {
Packit Service 7770af
Packit Service 7770af
      // match this first as we test prefix hyphens
Packit Service 7770af
      if (const char* calc = calc_fn_call(src)) {
Packit Service 7770af
        return calc;
Packit Service 7770af
      }
Packit Service 7770af
Packit Service 7770af
      return sequence <
Packit Service 7770af
        optional <
Packit Service 7770af
          sequence <
Packit Service 7770af
            exactly <'-'>,
Packit Service 7770af
            one_plus <
Packit Service 7770af
              alternatives <
Packit Service 7770af
                alpha,
Packit Service 7770af
                exactly <'+'>,
Packit Service 7770af
                exactly <'-'>
Packit Service 7770af
              >
Packit Service 7770af
            >
Packit Service 7770af
          >
Packit Service 7770af
        >,
Packit Service 7770af
        alternatives <
Packit Service 7770af
          word < expression_kwd >,
Packit Service 7770af
          sequence <
Packit Service 7770af
            sequence <
Packit Service 7770af
              exactly < progid_kwd >,
Packit Service 7770af
              exactly <':'>
Packit Service 7770af
            >,
Packit Service 7770af
            zero_plus <
Packit Service 7770af
              alternatives <
Packit Service 7770af
                char_range <'a', 'z'>,
Packit Service 7770af
                exactly <'.'>
Packit Service 7770af
              >
Packit Service 7770af
            >
Packit Service 7770af
          >
Packit Service 7770af
        >
Packit Service 7770af
      >(src);
Packit Service 7770af
    }
Packit Service 7770af
Packit Service 7770af
  }
Packit Service 7770af
}