| 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.
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
# 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
# File lib/sass/scss/static_parser.rb, line 39
39: def interp_ident(ident = IDENT); s = tok(ident) and [s]; end
# File lib/sass/scss/static_parser.rb, line 42
42: def special_directive(name)
43: return unless name == 'media' || name == 'import'
44: super
45: end