class Crass::Parser
def consume_qualified_rule(input = @tokens)
occurs.
Consumes a qualified rule and returns it, or `nil` if a parse error
def consume_qualified_rule(input = @tokens) rule = {:prelude => []} rule[:tokens] = input.collect do while true unless token = input.consume # Parse error. # # Note: The spec explicitly says to return nothing here, but Simon # Sapin's CSS parsing tests expect an error node. return create_node(:error, :value => 'invalid') end if token[:node] == :'{' # Note: The spec says the block should _be_ the consumed simple # block, but Simon Sapin's CSS parsing tests and tinycss2 expect # only the _value_ of the consumed simple block here. I assume I'm # interpreting the spec too literally, so I'm going with the # tinycss2 behavior. rule[:block] = consume_simple_block(input)[:value] break elsif token[:node] == :simple_block && token[:start] == '{' # Note: The spec says the block should _be_ the simple block, but # Simon Sapin's CSS parsing tests and tinycss2 expect only the # _value_ of the simple block here. I assume I'm interpreting the # spec too literally, so I'm going with the tinycss2 behavior. rule[:block] = token[:value] break else input.reconsume rule[:prelude] << consume_component_value(input) end end end create_node(:qualified_rule, rule) end