Class: Sass::SCSS::StaticParser

Inherits:
Parser
  • Object
show all
Defined in:
lib/sass/scss/static_parser.rb

Overview

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. parsing selectors after resolving the interpolation.

Direct Known Subclasses

CssParser

Constant Summary

Constants included from RX

RX::CDC, RX::CDO, RX::COMMENT, RX::DASHMATCH, RX::DEFAULT, RX::ESCAPE, RX::FUNCTION, RX::GREATER, RX::H, RX::HASH, RX::HEXCOLOR, RX::IDENT, RX::IMPORTANT, RX::INCLUDES, RX::INTERP_START, RX::NAME, RX::NL, RX::NMCHAR, RX::NMSTART, RX::NONASCII, RX::NOT, RX::NUM, RX::NUMBER, RX::PLUS, RX::PREFIXMATCH, RX::RANGE, RX::S, RX::SINGLE_LINE_COMMENT, RX::STATIC_SELECTOR, RX::STATIC_VALUE, RX::STRING, RX::STRING1, RX::STRING1_NOINTERP, RX::STRING2, RX::STRING2_NOINTERP, RX::STRING_NOINTERP, RX::SUBSTRINGMATCH, RX::SUFFIXMATCH, RX::TILDE, RX::UNICODE, RX::UNICODERANGE, RX::URI, RX::URL, RX::URLCHAR, RX::W

Instance Method Summary collapse

Methods inherited from Parser

#initialize, #parse, #parse_interp_ident

Methods included from RX

escape_ident

Constructor Details

This class inherits a constructor from Sass::SCSS::Parser

Instance Method Details

#parse_selector(filename) ⇒ Selector::CommaSequence

Parses the text as a selector.

Parameters:

  • line (Fixnum)

    The line on which the selector appears. Used for error reporting

  • filename (String, nil)

    The file in which the selector appears, or nil if there is no such file. Used for error reporting

Returns:

Raises:



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sass/scss/static_parser.rb', line 18

def parse_selector(filename)
  init_scanner!
  selectors = [expr!(:_selector)]
  while tok(/,/)
    ws = str{ss}
    selectors << expr!(:_selector)
    selectors[-1] = Selector::Sequence.new(["\n"] + selectors.last.members) if ws.include?("\n")
  end
  expected("selector") unless @scanner.eos?
  seq = Selector::CommaSequence.new(selectors)
  seq.line = @line
  seq.filename = filename
  seq
end