vendor/bundle/ruby/2.3.0/gems/sass-3.4.22/lib/sass/scss/parser.rb
# Tries to parse a declaration, and returns the value parsed so far if it
# fails.
#
# This has three possible return types. It can return `nil`, indicating
# that parsing failed completely and the scanner hasn't moved forward at
# all. It can return an Array, indicating that parsing failed after
# consuming some text (possibly containing interpolation), which is
# returned. Or it can return a PropNode, indicating that parsing
# succeeded.
Tries to parse a declaration, and returns the value parsed so far if it
fails.

This has three possible return types. It can return `nil`, indicating
that parsing failed completely and the scanner hasn't moved forward at
all. It can return an Array, indicating that parsing failed after
consuming some text (possibly containing interpolation), which is
returned. Or it can return a PropNode, indicating that parsing
succeeded.
Tries to parse a declaration and returns the value parsed so far if it fails . This has three possible return types . It can return ` nil ` indicating that parsing failed completely and the scanner hasn ' t moved forward at all . It can return an Array indicating that parsing failed after consuming some text ( possibly containing interpolation ) which is returned . Or it can return a PropNode indicating that parsing succeeded .
def try_declaration
        name_start_pos = source_position
        if (s = tok(/[:\*\.]|\#(?!\{)/))
          name = [s, str {ss}]
          return name unless (ident = interp_ident)
          name << ident
        else
          return unless (name = interp_ident)
          name = Array(name)
        end
        if (comment = tok(COMMENT))
          name << comment
        end
        name_end_pos = source_position
        mid = [str {ss}]
        return name + mid unless tok(/:/)
        mid << ':'
        return name + mid + [':'] if tok(/:/)
        mid << str {ss}
        post_colon_whitespace = !mid.last.empty?
        could_be_selector = !post_colon_whitespace && (tok?(IDENT_START) || tok?(INTERP_START))
        value_start_pos = source_position
        value = nil
        error = catch_error do
          value = value!(name.first.is_a?(String) && name.first.start_with?("--"))
          if tok?(/\{/)
            tok!(/;/) if could_be_selector
          elsif !tok?(/[;{}]/)
            tok!(/[;{}]/)
          end
        end
        if error
          rethrow error unless could_be_selector
          additional_selector = almost_any_value
          rethrow error if tok?(/;/)
          return name + mid + (additional_selector || [])
        end
        value_end_pos = source_position
        ss
        require_block = tok?(/\{/)
        node = node(Sass::Tree::PropNode.new(name.flatten.compact, value, :new),
                    name_start_pos, value_end_pos)
        node.name_source_range = range(name_start_pos, name_end_pos)
        node.value_source_range = range(value_start_pos, value_end_pos)
        return node unless require_block
        nested_properties! node
      end
def try_declaration name_start_pos = source_position if ( s = tok ( / [: \* \. ]| \# (?! \{ ) / ) ) name = [ s , str { ss } ] return name unless ( ident = interp_ident ) name << ident else return unless ( name = interp_ident ) name = Array ( name ) end if ( comment = tok ( COMMENT ) ) name << comment end name_end_pos = source_position mid = [ str { ss } ] return name + mid unless tok ( / : / ) mid << ':' return name + mid + [ ':' ] if tok ( / : / ) mid << str { ss } post_colon_whitespace = ! mid . last . empty? could_be_selector = ! post_colon_whitespace && ( tok? ( IDENT_START ) || tok? ( INTERP_START ) ) value_start_pos = source_position value = nil error = catch_error do value = value! ( name . first . is_a? ( String ) && name . first . start_with? ( "--" ) ) if tok? ( / \{ / ) tok! ( / ; / ) if could_be_selector elsif ! tok? ( / [;{}] / ) tok! ( / [;{}] / ) end end if error rethrow error unless could_be_selector additional_selector = almost_any_value rethrow error if tok? ( / ; / ) return name + mid + ( additional_selector || [ ] ) end value_end_pos = source_position ss require_block = tok? ( / \{ / ) node = node ( Sass :: Tree :: PropNode . new ( name . flatten . compact , value , :new ) , name_start_pos , value_end_pos ) node . name_source_range = range ( name_start_pos , name_end_pos ) node . value_source_range = range ( value_start_pos , value_end_pos ) return node unless require_block nested_properties! node end
Tries to parse a declaration, and returns the value parsed so far if it
fails.
Tries to parse a declaration and returns the value parsed so far if it fails .
# This allows the "*prop: val", ":prop: val", "#prop: val", and ".prop: # val" hacks. # Properties that are ambiguous with selectors can't have additional # properties nested beneath them. # We want an exception if there's no valid end-of-property character # exists, but we don't want to consume it if it does. # If the value would be followed by a semicolon, it's definitely # supposed to be a property, not a selector.