class Crass::Parser
def consume_function(input = @tokens)
Consumes a function and returns it.
def consume_function(input = @tokens) @depth += 1 begin # Discard functions nested more deeply than the maximum allowed depth to # avoid exhausting the Ruby stack on maliciously nested input. return discard_block(input) if @depth > @maximum_depth function = { :name => input.current[:value], :value => [], :tokens => [input.current] # Non-standard, used for serialization. } function[:tokens].concat(input.collect { while token = input.consume case token[:node] when :')' break # Non-standard. when :comment next else input.reconsume function[:value] << consume_component_value(input) end end }) create_node(:function, function) ensure @depth -= 1 end end