| Class | Sass::SCSS::Parser |
| In: |
lib/sass/scss/parser.rb
|
| Parent: | Object |
The parser for SCSS. It parses a string of code into a tree of {Sass::Tree::Node}s.
| DIRECTIVES | = | Set[:mixin, :include, :debug, :warn, :for, :while, :if, :extend, :import, :media] |
| EXPR_NAMES | = | { :media_query => "media query (e.g. print, screen, print and screen)", :media_expr => "media expression (e.g. (min-device-width: 800px)))", :pseudo_expr => "expression (e.g. fr, 2n+1)", :interp_ident => "identifier", :interp_name => "identifier", :expr => "expression (e.g. 1px, bold)", :_selector => "selector", :simple_selector_sequence => "selector", } |
| TOK_NAMES | = | Haml::Util.to_hash( Sass::SCSS::RX.constants.map {|c| [Sass::SCSS::RX.const_get(c), c.downcase]}). merge(IDENT => "identifier", /[;}]/ => '";"') |
@param str [String, StringScanner] The source document to parse @param line [Fixnum] The line on which the source string appeared,
if it's part of another document
# File lib/sass/scss/parser.rb, line 12
12: def initialize(str, line = 1)
13: @template = str
14: @line = line
15: @strs = []
16: end
Parses an SCSS document.
@return [Sass::Tree::RootNode] The root node of the document tree @raise [Sass::SyntaxError] if there‘s a syntax error in the document
# File lib/sass/scss/parser.rb, line 22
22: def parse
23: init_scanner!
24: root = stylesheet
25: expected("selector or at-rule") unless @scanner.eos?
26: root
27: end
Parses an identifier with interpolation. Note that this won‘t assert that the identifier takes up the entire input string; it‘s meant to be used with `StringScanner`s as part of other parsers.
@return [Array<String, Sass::Script::Node>, nil]
The interpolated identifier, or nil if none could be parsed
# File lib/sass/scss/parser.rb, line 35
35: def parse_interp_ident
36: init_scanner!
37: interp_ident
38: end