class Crass::Parser

def consume_function(input = @tokens)

5.4.8. https://www.w3.org/TR/2013/WD-css-syntax-3-20130919/#consume-a-function

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