PageRenderTime 53ms CodeModel.GetById 42ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

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