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

new parse parse_interp_ident

### Included Modules

Sass::SCSS::RX

### Constants

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", /[;}]/ => '";"')

### Public Class methods

new(str, line = 1)

@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 line [Fixnum] The line on which the source string appeared,

      if it's part of another document

[Source]

        # File lib/sass/scss/parser.rb, line 14
    14:       def initialize(str, line = 1)
    15:         @template = str
    16:         @line = line
    17:         @strs = []
    18:       end

### Public Instance methods

parse()

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

[Source]

        # File lib/sass/scss/parser.rb, line 24
    24:       def parse
    25:         init_scanner!
    26:         root = stylesheet
    27:         expected("selector or at-rule") unless @scanner.eos?
    28:         root
    29:       end

parse_interp_ident()

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

[Source]

        # File lib/sass/scss/parser.rb, line 37
    37:       def parse_interp_ident
    38:         init_scanner!
    39:         interp_ident
    40:       end

[Validate]