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

http://github.com/scalate/scalate · Ruby · 63 lines · 40 code · 6 blank · 17 comment · 0 complexity · fca175b98ba79c0b88ce31d06bdc043f MD5 · raw file

  1. require 'strscan'
  2. require 'sass/script/node'
  3. require 'sass/script/variable'
  4. require 'sass/script/funcall'
  5. require 'sass/script/operation'
  6. require 'sass/script/literal'
  7. require 'sass/script/parser'
  8. module Sass
  9. # SassScript is code that's embedded in Sass documents
  10. # to allow for property values to be computed from variables.
  11. #
  12. # This module contains code that handles the parsing and evaluation of SassScript.
  13. module Script
  14. # The regular expression used to parse variables.
  15. MATCH = /^[!\$](#{Sass::SCSS::RX::IDENT})\s*((?:\|\|)?=|:)\s*(.+?)(!(?i:default))?$/
  16. # The regular expression used to validate variables without matching.
  17. VALIDATE = /^[!\$]#{Sass::SCSS::RX::IDENT}$/
  18. # Parses a string of SassScript
  19. #
  20. # @param value [String] The SassScript
  21. # @param line [Fixnum] The number of the line on which the SassScript appeared.
  22. # Used for error reporting
  23. # @param offset [Fixnum] The number of characters in on `line` that the SassScript started.
  24. # Used for error reporting
  25. # @param options [{Symbol => Object}] An options hash;
  26. # see {file:SASS_REFERENCE.md#sass_options the Sass options documentation}
  27. # @return [Script::Node] The root node of the parse tree
  28. def self.parse(value, line, offset, options = {})
  29. Parser.parse(value, line, offset, options)
  30. rescue Sass::SyntaxError => e
  31. e.message << ": #{value.inspect}." if e.message == "SassScript error"
  32. e.modify_backtrace(:line => line, :filename => options[:filename])
  33. raise e
  34. end
  35. # @private
  36. def self.var_warning(varname, line, offset, filename)
  37. Haml::Util.haml_warn <<MESSAGE
  38. DEPRECATION WARNING:
  39. On line #{line}, character #{offset}#{" of '#{filename}'" if filename}
  40. Variables with ! have been deprecated and will be removed in version 3.2.
  41. Use \"$#{varname}\" instead.
  42. You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
  43. MESSAGE
  44. end
  45. # @private
  46. def self.equals_warning(types, name, val, guarded, line, offset, filename)
  47. Haml::Util.haml_warn <<MESSAGE
  48. DEPRECATION WARNING:
  49. On line #{line}#{", character #{offset}" if offset}#{" of '#{filename}'" if filename}
  50. Setting #{types} with #{"||" if guarded}= has been deprecated and will be removed in version 3.2.
  51. Use "#{name}: #{val}#{" !default" if guarded}" instead.
  52. You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
  53. MESSAGE
  54. end
  55. end
  56. end