Sha256: 854021310df9e86d6468c2bc99bfff0c28014aec66adb321dad499e2ef05a396

Contents?: true

Size: 1.4 KB

Versions: 6

Compression:

Stored size: 1.4 KB

Contents

require 'sass/script/css_parser'

module Sass
  module SCSS
    # This is a subclass of {Parser} which only parses plain CSS.
    # It doesn't support any Sass extensions, such as interpolation,
    # parent references, nested selectors, and so forth.
    # It does support all the same CSS hacks as the SCSS parser, though.
    class CssParser < StaticParser
      # Parse a selector, and return its value as a string.
      #
      # @return [String, nil] The parsed selector, or nil if no selector was parsed
      # @raise [Sass::SyntaxError] if there's a syntax error in the selector
      def parse_selector_string
        init_scanner!
        str {return unless selector}
      end

      private

      def placeholder_selector; nil; end
      def parent_selector; nil; end
      def interpolation; nil; end
      def interp_string; tok(STRING); end
      def interp_ident(ident = IDENT); tok(ident); end
      def use_css_import?; true; end

      def block_child(context)
        case context
        when :ruleset
          declaration
        when :stylesheet
          directive || ruleset
        when :directive
          directive || declaration_or_ruleset
        end
      end

      def nested_properties!(node, space)
        expected('expression (e.g. 1px, bold)');
      end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sass-3.2.0.alpha.57 lib/sass/scss/css_parser.rb
sass-3.2.0.alpha.56 lib/sass/scss/css_parser.rb
sass-3.2.0.alpha.55 lib/sass/scss/css_parser.rb
sass-3.2.0.alpha.54 lib/sass/scss/css_parser.rb
sass-3.2.0.alpha.53 lib/sass/scss/css_parser.rb
sass-3.2.0.alpha.49 lib/sass/scss/css_parser.rb