vendor/bundle/ruby/2.3.0/gems/sass-3.4.22/lib/sass/scss/parser.rb
# When parsing the contents of a ruleset, it can be difficult to tell
# declarations apart from nested rulesets. Since we don't thoroughly parse
# selectors until after resolving interpolation, we can share a bunch of
# the parsing of the two, but we need to disambiguate them first. We use
# the following criteria:
#
# * If the entity doesn't start with an identifier followed by a colon,
#   it's a selector. There are some additional mostly-unimportant cases
#   here to support various declaration hacks.
#
# * If the colon is followed by another colon, it's a selector.
#
# * Otherwise, if the colon is followed by anything other than
#   interpolation or a character that's valid as the beginning of an
#   identifier, it's a declaration.
#
# * If the colon is followed by interpolation or a valid identifier, try
#   parsing it as a declaration value. If this fails, backtrack and parse
#   it as a selector.
#
# * If the declaration value value valid but is followed by "{", backtrack
#   and parse it as a selector anyway. This ensures that ".foo:bar {" is
#   always parsed as a selector and never as a property with nested
#   properties beneath it.
When parsing the contents of a ruleset, it can be difficult to tell
declarations apart from nested rulesets. Since we don't thoroughly parse
selectors until after resolving interpolation, we can share a bunch of
the parsing of the two, but we need to disambiguate them first. We use
the following criteria.

If the entity doesn't start with an identifier followed by a colon,
it's a selector. There are some additional mostly-unimportant cases
here to support various declaration hacks.

If the colon is followed by another colon, it's a selector.

Otherwise, if the colon is followed by anything other than
interpolation or a character that's valid as the beginning of an
identifier, it's a declaration.

If the colon is followed by interpolation or a valid identifier, try
parsing it as a declaration value. If this fails, backtrack and parse
it as a selector.

If the declaration value value valid but is followed by "{", backtrack
and parse it as a selector anyway. This ensures that ".foo:bar {" is
always parsed as a selector and never as a property with nested
properties beneath it.
When parsing the contents of a ruleset it can be difficult to tell declarations apart from nested rulesets . Since we don ' t thoroughly parse selectors until after resolving interpolation we can share a bunch of the parsing of the two but we need to disambiguate them first . We use the following criteria . If the entity doesn ' t start with an identifier followed by a colon it ' s a selector . There are some additional mostly - unimportant cases here to support various declaration hacks . If the colon is followed by another colon it ' s a selector . Otherwise if the colon is followed by anything other than interpolation or a character that ' s valid as the beginning of an identifier it ' s a declaration . If the colon is followed by interpolation or a valid identifier try parsing it as a declaration value . If this fails backtrack and parse it as a selector . If the declaration value value valid but is followed by " { " backtrack and parse it as a selector anyway . This ensures that " . foo : bar { " is always parsed as a selector and never as a property with nested properties beneath it .
def declaration_or_ruleset
        start_pos = source_position
        declaration = try_declaration
        if declaration.nil?
          return unless (selector = almost_any_value)
        elsif declaration.is_a?(Array)
          selector = declaration
        else
          return declaration
        end
        if (additional_selector = almost_any_value)
          selector << additional_selector
        end
        block(
          node(
            Sass::Tree::RuleNode.new(merge(selector), range(start_pos)), start_pos), :ruleset)
      end
def declaration_or_ruleset start_pos = source_position declaration = try_declaration if declaration . nil? return unless ( selector = almost_any_value ) elsif declaration . is_a? ( Array ) selector = declaration else return declaration end if ( additional_selector = almost_any_value ) selector << additional_selector end block ( node ( Sass :: Tree :: RuleNode . new ( merge ( selector ) , range ( start_pos ) ) , start_pos ) , :ruleset ) end
When parsing the contents of a ruleset, it can be difficult to tell
declarations apart from nested rulesets.
When parsing the contents of a ruleset it can be difficult to tell declarations apart from nested rulesets .
# Declaration should be a PropNode.