PageRenderTime 17ms CodeModel.GetById 8ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/scalate-jruby/src/main/resources/haml-3.0.25/lib/sass/scss/css_parser.rb

http://github.com/scalate/scalate
Ruby | 46 lines | 32 code | 6 blank | 8 comment | 2 complexity | d92d2c53fb732caa80c3adf7e21f2c54 MD5 | raw file
 1require 'sass/script/css_parser'
 2
 3module Sass
 4  module SCSS
 5    # This is a subclass of {Parser} which only parses plain CSS.
 6    # It doesn't support any Sass extensions, such as interpolation,
 7    # parent references, nested selectors, and so forth.
 8    # It does support all the same CSS hacks as the SCSS parser, though.
 9    class CssParser < StaticParser
10      # Parse a selector, and return its value as a string.
11      #
12      # @return [String, nil] The parsed selector, or nil if no selector was parsed
13      # @raise [Sass::SyntaxError] if there's a syntax error in the selector
14      def parse_selector_string
15        init_scanner!
16        str {return unless selector}
17      end
18
19      private
20
21      def parent_selector; nil; end
22      def interpolation; nil; end
23      def interp_string; tok(STRING); end
24      def interp_ident(ident = IDENT); tok(ident); end
25      def use_css_import?; true; end
26
27      def block_child(context)
28        case context
29        when :ruleset
30          declaration
31        when :stylesheet
32          directive || ruleset
33        when :directive
34          directive || declaration_or_ruleset
35        end
36      end
37
38      def nested_properties!(node, space)
39        expected('expression (e.g. 1px, bold)');
40      end
41
42      @sass_script_parser = Class.new(Sass::Script::CssParser)
43      @sass_script_parser.send(:include, ScriptParser)
44    end
45  end
46end