Class | Sass::Script::Parser |
In: |
lib/sass/script/parser.rb
|
Parent: | Object |
The parser for SassScript. It parses a string of code into a tree of {Script::Node}s.
@param str [String, StringScanner] The source text to parse @param line [Fixnum] The line on which the SassScript appears.
Used for error reporting
@param offset [Fixnum] The number of characters in on which the SassScript appears.
Used for error reporting
@param filename [String] The name of the file in which the SassScript appears.
Used for error reporting
# File lib/sass/script/parser.rb, line 15 15: def initialize(str, line, offset, filename = nil) 16: @filename = filename 17: @lexer = Lexer.new(str, line, offset, filename) 18: end
Parses a SassScript expression.
@overload parse(str, line, offset, filename = nil) @return [Script::Node] The root node of the parse tree @see Parser#initialize @see Parser#parse
# File lib/sass/script/parser.rb, line 49 49: def self.parse(*args) 50: new(*args).parse 51: end
Parses a SassScript expression.
@return [Script::Node] The root node of the parse tree @raise [Sass::SyntaxError] if the expression isn‘t valid SassScript
# File lib/sass/script/parser.rb, line 37 37: def parse 38: expr = assert_expr :expr 39: raise Sass::SyntaxError.new("Unexpected #{@lexer.peek.type} token.") unless @lexer.done? 40: expr 41: end
Parses a SassScript expression within an interpolated segment (`#{}`). This means that it stops when it comes across an unmatched `}`, which signals the end of an interpolated segment, it returns rather than throwing an error.
@return [Script::Node] The root node of the parse tree @raise [Sass::SyntaxError] if the expression isn‘t valid SassScript
# File lib/sass/script/parser.rb, line 27 27: def parse_interpolated 28: expr = assert_expr :expr 29: assert_tok :end_interpolation 30: expr 31: end