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.

Methods

Included Modules

Sass::SCSS::RX

Constants

DIRECTIVES = Set[:mixin, :include, :function, :return, :debug, :warn, :for, :each, :while, :if, :else, :extend, :import, :media, :charset, :content, :_moz_document]
PREFIXED_DIRECTIVES = Set[:supports]
EXPR_NAMES = { :media_query => "media query (e.g. print, screen, print and screen)", :media_expr => "media expression (e.g. (min-device-width: 800px))", :pseudo_arg => "expression (e.g. fr, 2n+1)", :interp_ident => "identifier", :interp_name => "identifier", :qualified_name => "identifier", :expr => "expression (e.g. 1px, bold)", :_selector => "selector", :simple_selector_sequence => "selector", :import_arg => "file to import (string or url())", :moz_document_function => "matching function (e.g. url-prefix(), domain())", :supports_condition => "@supports condition (e.g. (display: flexbox))", :supports_condition_in_parens => "@supports condition (e.g. (display: flexbox))", }
TOK_NAMES = Sass::Util.to_hash( Sass::SCSS::RX.constants.map {|c| [Sass::SCSS::RX.const_get(c), c.downcase]}). merge(IDENT => "identifier", /[;}]/ => '";"')
NEWLINE = "\n"   Avoid allocating lots of new strings for `tok`. This is important because `tok` is called all the time.

Public Class methods

@param str [String, StringScanner] The source document to parse.

  Note that `Parser` *won't* raise a nice error message if this isn't properly parsed;
  for that, you should use the higher-level {Sass::Engine} or {Sass::CSS}.

@param filename [String] The name of the file being parsed. Used for warnings. @param line [Fixnum] The line on which the source string appeared,

  if it's part of another document.

Public Instance methods

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

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

Parses a media query list.

@return [Sass::Media::QueryList] The parsed query list @raise [Sass::SyntaxError] if there‘s a syntax error in the query list,

  or if it doesn't take up the entire input string.

[Validate]