Permalink
Browse files

Merge branch 'stable'

Conflicts:
	doc-src/SASS_CHANGELOG.md
	lib/sass/script/lexer.rb
	lib/sass/script/parser.rb
  • Loading branch information...
2 parents 291977c + 439db92 commit 19a5ebb6b5f89bf72c2a3dde94cd90406414e89c @nex3 nex3 committed Jan 24, 2014
Showing with 23 additions and 23 deletions.
  1. +2 −0 doc-src/SASS_CHANGELOG.md
  2. +4 −20 lib/sass/script/lexer.rb
  3. +10 −3 lib/sass/script/parser.rb
  4. +7 −0 test/sass/script_test.rb
View
2 doc-src/SASS_CHANGELOG.md
@@ -425,6 +425,8 @@ of all directives, but will preserve any CSS rules.
* Clean up file paths when importing to avoid errors for overlong path
names.
+* Parse calls to functions named `true`, `false`, and `null` as function calls.
+
## 3.2.13
* Numbers returned by user-defined functions now trigger division, just like
View
24 lib/sass/script/lexer.rb
@@ -72,8 +72,7 @@ def offset
TOKEN_NAMES = Sass::Util.map_hash(OPERATORS_REVERSE) {|k, v| [k, v.inspect]}.merge(
:const => "variable (e.g. $foo)",
- :ident => "identifier (e.g. middle)",
- :bool => "boolean (e.g. true, false)")
+ :ident => "identifier (e.g. middle)")
# A list of operator strings ordered with longer names first
# so that `>` and `<` don't clobber `>=` and `<=`.
@@ -92,8 +91,6 @@ def offset
:ident => /(#{IDENT})(\()?/,
:number => /(?:(\d*\.\d+)|(\d+))([a-zA-Z%]+)?/,
:color => HEXCOLOR,
- :bool => /(true|false)\b/,
- :null => /null\b/,
:ident_op => /(#{Regexp.union(*IDENT_OP_NAMES.map do |s|
Regexp.new(Regexp.escape(s) + "(?!#{NMCHAR}|\Z)")
end)})/,
@@ -253,9 +250,9 @@ def token
return string(interp_type, true)
end
- variable || string(:double, false) || string(:single, false) || number ||
- color || bool || null || string(:uri, false) ||
- raw(UNICODERANGE) || special_fun || special_val || ident_op || ident || op
+ variable || string(:double, false) || string(:single, false) || number || color ||
+ string(:uri, false) || raw(UNICODERANGE) || special_fun || special_val || ident_op ||
+ ident || op
end
def variable
@@ -307,19 +304,6 @@ def color
[:color, script_color]
end
- def bool
- s = scan(REGULAR_EXPRESSIONS[:bool])
- return unless s
- script_bool = Script::Value::Bool.new(s == 'true')
- [:bool, script_bool]
- end
-
- def null
- return unless scan(REGULAR_EXPRESSIONS[:null])
- script_null = Script::Value::Null.new
- [:null, script_null]
- end
-
def special_fun
str1 = scan(/((-[\w-]+-)?(calc|element)|expression|progid:[a-z\.]*)\(/i)
return unless str1
View
13 lib/sass/script/parser.rb
@@ -382,9 +382,16 @@ def ident
name = @lexer.next
if (color = Sass::Script::Value::Color::COLOR_NAMES[name.value.downcase])
- return literal_node(Sass::Script::Value::Color.new(color), name.source_range)
+ literal_node(Sass::Script::Value::Color.new(color), name.source_range)
+ elsif name.value == "true"
+ literal_node(Sass::Script::Value::Bool.new(true), name.source_range)
+ elsif name.value == "false"
+ literal_node(Sass::Script::Value::Bool.new(false), name.source_range)
+ elsif name.value == "null"
+ literal_node(Sass::Script::Value::Null.new, name.source_range)
+ else
+ literal_node(Sass::Script::Value::String.new(name.value, :identifier), name.source_range)
end
- literal_node(Script::Value::String.new(name.value, :identifier), name.source_range)
end
def funcall
@@ -543,7 +550,7 @@ def selector
end
def literal
- t = try_toks(:color, :bool, :null)
+ t = try_tok(:color)
return literal_node(t.value, t.source_range) if t
end
View
7 test/sass/script_test.rb
@@ -706,6 +706,13 @@ def test_funcall_has_higher_precedence_than_color_name
assert_equal "teal\\+bang(12)", resolve("teal\\+bang(12)")
end
+ def test_funcall_has_higher_precedence_than_true_false_null
+ assert_equal "teal(12)", resolve("teal(12)")
+ assert_equal "tealbang(12)", resolve("tealbang(12)")
+ assert_equal "teal-bang(12)", resolve("teal-bang(12)")
+ assert_equal "teal\\+bang(12)", resolve("teal\\+bang(12)")
+ end
+
def test_interpolation_after_hash
assert_equal "#2", resolve('"##{1 + 1}"')
end

0 comments on commit 19a5ebb

Please sign in to comment.