Change ~ to !.

This commit is contained in:
Nathan Weizenbaum 2008-08-10 14:34:22 -04:00
parent b4b6ce2c29
commit c14afa0618
2 changed files with 13 additions and 16 deletions

View File

@ -30,11 +30,10 @@ module Sass
?* => :times,
?/ => :div,
?% => :mod,
?~ => :not,
?& => :single_and,
?| => :single_or,
?= => :single_equals,
CONSTANT_CHAR => :const,
CONSTANT_CHAR => :const_or_not,
STRING_CHAR => :str,
ESCAPE_CHAR => :esc
}
@ -126,7 +125,7 @@ module Sass
symbol = SYMBOLS[byte]
# Adjacent values without an operator should be concatenated
if (symbol.nil? || symbol == :open || symbol == :const) &&
if (symbol.nil? || symbol == :open || symbol == :const_or_not) &&
last && (!last.is_a?(Symbol) || last == :close)
to_return << :concat
end
@ -138,7 +137,7 @@ module Sass
end
# Time for a unary op!
if ![nil, :open, :close, :const, :single_and, :single_or, :single_equals].include?(symbol) && beginning_of_token
if ![nil, :open, :close, :const_or_not, :single_and, :single_or, :single_equals].include?(symbol) && beginning_of_token
beginning_of_token = true
to_return << :unary << symbol
next
@ -149,8 +148,9 @@ module Sass
next
end
if symbol == :single_equals && last == :not
if symbol == :single_equals && last == :const_or_not
to_return[-1] = :not_equals
to_return.slice!(-2) if to_return[-2] == :concat
next
end
@ -185,12 +185,10 @@ module Sass
to_return << parenthesize(value)
when :unary
to_return << [value.shift, parenthesize(value, true)]
when :const
when :const_or_not
raise Sass::SyntaxError.new("Unterminated constant.") if value.first.nil?
raise Sass::SyntaxError.new("Invalid constant.") unless value.first.is_a?(::String)
to_return << [:const, value.first]
value.shift
to_return << (value.first.is_a?(::String) ? [:const, value.shift] : [:not, parenthesize(value, true)])
else
to_return << token
end

View File

@ -46,7 +46,6 @@ class SassEngineTest < Test::Unit::TestCase
"@import templates/basic\n foo" => "Illegal nesting: Nothing may be nested beneath import directives.",
"foo\n @import templates/basic" => "Import directives may only be used at the root of a document.",
"!foo = bar baz !" => "Unterminated constant.",
"!foo = !(foo)" => "Invalid constant.",
"=foo\n :color red\n.bar\n +bang" => "Undefined mixin 'bang'.",
".bar\n =foo\n :color red\n" => ["Mixins may only be defined at the root of a document.", 2],
"=foo\n :color red\n.bar\n +foo\n :color red" => "Illegal nesting: Nothing may be nested beneath mixin directives.",
@ -404,8 +403,8 @@ a {
CSS
!var = true
a
b = ~~!var
c = ~!var
b = !!!var
c = !!var
SASS
end
@ -429,7 +428,7 @@ SASS
a
@if !var
b: 1
@if ~!var
@if !!var
b: 2
SASS
end
@ -447,10 +446,10 @@ CSS
a
t1 = "foo" == foo
t2 = 1 == 1.0
t3 = false ~= true
t3 = false != true
f1 = foo == bar
f2 = 1em == 1px
f3 = 12 ~= 12
f3 = 12 != 12
SASS
end
@ -509,7 +508,7 @@ a-1 {
blooble: gloop; }
CSS
!a = 5
@while !a ~= 0
@while !a != 0
a-\#{!a}
blooble: gloop
!a = !a - 1