mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Smoothing out a few more constant parsing bugs.
git-svn-id: svn://hamptoncatlin.com/haml/trunk@260 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
parent
67397758bd
commit
12255afcd0
3 changed files with 22 additions and 11 deletions
|
@ -84,37 +84,46 @@ module Sass
|
|||
beginning = i
|
||||
token = value[i]
|
||||
|
||||
while i < value_len && token != :close
|
||||
i += 1
|
||||
token = value[i]
|
||||
|
||||
while i < value_len && token != :close
|
||||
if token == :open
|
||||
to_return.push(*value[beginning...i])
|
||||
sub, i = parenthesize_helper(i + 1, value, value_len)
|
||||
beginning = i
|
||||
token = value[i]
|
||||
to_return << sub
|
||||
else
|
||||
i += 1
|
||||
end
|
||||
|
||||
token = value[i]
|
||||
end
|
||||
to_return.push(*value[beginning...i])
|
||||
return to_return, i + 1
|
||||
end
|
||||
|
||||
#--
|
||||
# TODO: Don't pass around original value;
|
||||
# have Constant.parse automatically add it to exception.
|
||||
#++
|
||||
def operationalize(value, original, constants)
|
||||
value = [value] unless value.is_a?(Array)
|
||||
length = value.length
|
||||
if length == 1
|
||||
Literal.parse(insert_constant(value[0], constants))
|
||||
value = value[0]
|
||||
if value.is_a? Operation
|
||||
value
|
||||
else
|
||||
Literal.parse(insert_constant(value, constants))
|
||||
end
|
||||
elsif length == 2
|
||||
raise "Improperly formatted script:\n#{original}"
|
||||
raise "Syntax error:\n#{original}"
|
||||
elsif length == 3
|
||||
Operation.new(operationalize(value[0], original, constants), operationalize(value[2], original, constants), value[1])
|
||||
else
|
||||
raise "Improperly formatted script:\n#{original}" unless length >= 5 && length % 2 == 1
|
||||
raise "Syntax error:\n#{original}" unless length >= 5 && length % 2 == 1
|
||||
if SECOND_ORDER.include?(value[1]) && FIRST_ORDER.include?(value[3])
|
||||
operationalize([value[1], value[2], operationalize(value[3..5]), *value[6..-1]], original, constants)
|
||||
operationalize([value[1], value[2], operationalize(value[3..5], original, constants), *value[6..-1]], original, constants)
|
||||
else
|
||||
operationalize([operationalize(value[0..2]), *value[4..-1]], original, constants)
|
||||
operationalize([operationalize(value[0..2], original, constants), *value[3..-1]], original, constants)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#main { width: 30; background-color: #000; color: #ffffaf; }
|
||||
#main #sidebar { background-color: #00ff98; num-normal: 10; num-dec: 10.2; num-dec0: 99; num-neg: -10; esc: 10+12; }
|
||||
#main #sidebar { background-color: #00ff98; num-normal: 10; num-dec: 10.2; num-dec0: 99; num-neg: -10; esc: 10+12; many: 6; complex: 18#3a8b9fhi4; }
|
||||
|
||||
#plus { num-num: 7; num-str: 100px; num-col: 13#ffffff; str-str: hi there; str-num: times: 13; col-num: #ff8aaa; col-col: #5f80ff; }
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
:dec0= !dec_0
|
||||
:neg= !neg
|
||||
:esc= !esc
|
||||
:many= 1 + 2 + 3
|
||||
:complex= ((1 + 2) + 15)+#3a8b9f + (hi+(1 +1+ 2))
|
||||
|
||||
#plus
|
||||
:num
|
||||
|
|
Loading…
Add table
Reference in a new issue