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

http://github.com/scalate/scalate · Ruby · 40 lines · 25 code · 3 blank · 12 comment · 0 complexity · 6b5ebee7db164d08e0f2ac453db94bbb MD5 · raw file

  1. module Sass
  2. module SCSS
  3. # A parser for a static SCSS tree.
  4. # Parses with SCSS extensions, like nested rules and parent selectors,
  5. # but without dynamic SassScript.
  6. # This is useful for e.g. \{#parse\_selector parsing selectors}
  7. # after resolving the interpolation.
  8. class StaticParser < Parser
  9. # Parses the text as a selector.
  10. #
  11. # @param filename [String, nil] The file in which the selector appears,
  12. # or nil if there is no such file.
  13. # Used for error reporting.
  14. # @return [Selector::CommaSequence] The parsed selector
  15. # @raise [Sass::SyntaxError] if there's a syntax error in the selector
  16. def parse_selector(filename)
  17. init_scanner!
  18. seq = expr!(:selector_comma_sequence)
  19. expected("selector") unless @scanner.eos?
  20. seq.line = @line
  21. seq.filename = filename
  22. seq
  23. end
  24. private
  25. def variable; nil; end
  26. def script_value; nil; end
  27. def interpolation; nil; end
  28. def interp_string; s = tok(STRING) and [s]; end
  29. def interp_ident(ident = IDENT); s = tok(ident) and [s]; end
  30. def use_css_import?; true; end
  31. def special_directive(name)
  32. return unless %w[media import charset].include?(name)
  33. super
  34. end
  35. end
  36. end
  37. end