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, :at_root, :error]
PREFIXED_DIRECTIVES = Set[:supports]
EXPR_NAMES = { :media_query => "media query (e.g. print, screen, print and screen)", :media_query_list => "media query (e.g. print, screen, print and screen)", :media_expr => "media expression (e.g. (min-device-width: 800px))", :at_root_query => "@at-root query (e.g. (without: media))", :at_root_directive_list => '* or identifier', :pseudo_args => "expression (e.g. fr, 2n+1)", :interp_ident => "identifier", :qualified_name => "identifier", :expr => "expression (e.g. 1px, bold)", :selector_comma_sequence => "selector", :string => "string", :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))", :a_n_plus_b => "An+B expression", :keyframes_selector_component => "from, to, or a percentage", :keyframes_selector => "keyframes selector (e.g. 10%)"
TOK_NAMES = Sass::Util.to_hash(Sass::SCSS::RX.constants.map do |c| [Sass::SCSS::RX.const_get(c), c.downcase]

Attributes

offset  [RW]  Expose for the SASS parser.
sass_script_parser  [RW]  @private

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 and source maps.

@param importer [Sass::Importers::Base] The importer used to import the

  file being parsed. Used for source maps.

@param line [Integer] The 1-based line on which the source string appeared,

  if it's part of another document.

@param offset [Integer] The 1-based character (not byte) offset in the line on

  which the source string starts. Used for error reporting and sourcemap
  building.

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 at-root query.

@return [Array<String, Sass::Script;:Tree::Node>] The interpolated query. @raise [Sass::SyntaxError] if there‘s a syntax error in the query,

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

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::Tree::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.

Parses a supports clause for an @import directive

Parses a supports query condition.

@return [Sass::Supports::Condition] The parsed condition @raise [Sass::SyntaxError] if there‘s a syntax error in the condition,

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

[Validate]