Class Sass::SCSS::StaticParser
In: lib/sass/scss/static_parser.rb
Parent: Parser

A parser for a static SCSS tree. Parses with SCSS extensions, like nested rules and parent selectors, but without dynamic SassScript. This is useful for e.g. \{parse_selector parsing selectors} after resolving the interpolation.

Methods

Public Instance methods

Parses the text as a selector.

@param line [Fixnum] The line on which the selector appears.

  Used for error reporting

@param filename [String, nil] The file in which the selector appears,

  or nil if there is no such file.
  Used for error reporting

@return [Selector::CommaSequence] The parsed selector @raise [Sass::SyntaxError] if there‘s a syntax error in the selector

[Source]

    # File lib/sass/scss/static_parser.rb, line 18
18:       def parse_selector(filename)
19:         init_scanner!
20:         selectors = [expr!(:_selector)]
21:         while tok(/,/)
22:           ws = str{ss}
23:           selectors << expr!(:_selector)
24:           selectors[-1] = Selector::Sequence.new(["\n"] + selectors.last.members) if ws.include?("\n")
25:         end
26:         expected("selector") unless @scanner.eos?
27:         seq = Selector::CommaSequence.new(selectors)
28:         seq.line = @line
29:         seq.filename = filename
30:         seq
31:       end

[Validate]