Sha256: d2dbdf294d1d37eb1e367fd6f7eec397f607a466ed00d362e59e03120e9ab4da

Contents?: true

Size: 1.69 KB

Versions: 15

Compression:

Stored size: 1.69 KB

Contents

require 'sass/script/css_parser'

module Sass
  module SCSS
    # A parser for a static SCSS tree.
    # Parses with SCSS extensions, like nested rules and parent selectors,
    # but without dynamic SassScript.
    # This is useful for e.g. \{#parse\_selector parsing selectors}
    # after resolving the interpolation.
    class StaticParser < Parser
      # Parses the text as a selector.
      #
      # @param filename [String, nil] The file in which the selector appears,
      #   or nil if there is no such file.
      #   Used for error reporting.
      # @return [Selector::CommaSequence] The parsed selector
      # @raise [Sass::SyntaxError] if there's a syntax error in the selector
      def parse_selector
        init_scanner!
        seq = expr!(:selector_comma_sequence)
        expected("selector") unless @scanner.eos?
        seq.line = @line
        seq.filename = @filename
        seq
      end

      private

      def moz_document_function
        val = tok(URI) || tok(URL_PREFIX) || tok(DOMAIN) || function(!:allow_var)
        return unless val
        ss
        [val]
      end

      def variable; nil; end
      def script_value; nil; end
      def interpolation; nil; end
      def var_expr; nil; end
      def interp_string; (s = tok(STRING)) && [s]; end
      def interp_uri; (s = tok(URI)) && [s]; end
      def interp_ident(ident = IDENT); (s = tok(ident)) && [s]; end
      def use_css_import?; true; end

      def special_directive(name, start_pos)
        return unless %w[media import charset -moz-document].include?(name)
        super
      end

      @sass_script_parser = Class.new(Sass::Script::CssParser)
      @sass_script_parser.send(:include, ScriptParser)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
sass-3.3.0.alpha.382 lib/sass/scss/static_parser.rb
sass-3.3.0.alpha.380 lib/sass/scss/static_parser.rb
sass-3.3.0.alpha.378 lib/sass/scss/static_parser.rb
sass-3.3.0.alpha.377 lib/sass/scss/static_parser.rb
sass-3.3.0.alpha.376 lib/sass/scss/static_parser.rb
sass-3.3.0.alpha.375 lib/sass/scss/static_parser.rb
sass-3.3.0.alpha.372 lib/sass/scss/static_parser.rb
sass-3.3.0.alpha.370 lib/sass/scss/static_parser.rb
sass-3.3.0.alpha.369 lib/sass/scss/static_parser.rb
sass-3.3.0.alpha.368 lib/sass/scss/static_parser.rb
sass-3.3.0.alpha.367 lib/sass/scss/static_parser.rb
sass-3.3.0.alpha.366 lib/sass/scss/static_parser.rb
sass-3.3.0.alpha.364 lib/sass/scss/static_parser.rb
sass-3.3.0.alpha.354 lib/sass/scss/static_parser.rb
sass-3.3.0.alpha.353 lib/sass/scss/static_parser.rb