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.
PRECEDENCE | = | [ :comma, :single_eq, :space, :or, :and, [:eq, :neq], [:gt, :gte, :lt, :lte], [:plus, :minus], [:times, :div, :mod], ] | ||
ASSOCIATIVE | = | [:plus, :times] | ||
EXPR_NAMES | = | { :string => "string", :default => "expression (e.g. 1px, bold)", :mixin_arglist => "mixin argument", :fn_arglist => "function argument", } | It would be possible to have unified assert and try methods, but detecting the method/token difference turns out to be quite expensive. |
@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 options [{Symbol => Object}] An options hash;
see {file:SASS_REFERENCE.md#sass_options the Sass options documentation}
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
Returns an integer representing the precedence of the given operator. A lower integer indicates a looser binding.
@private
Parses a SassScript expression.
@return [Script::Node] The root node of the parse tree @raise [Sass::SyntaxError] if the expression isn‘t valid SassScript
Parses the argument list for a function definition.
@return [(Array<Script::Node>, Script::Node)]
The root nodes of the arguments, and the splat argument.
@raise [Sass::SyntaxError] if the argument list isn‘t valid SassScript
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
Parses the argument list for a mixin definition.
@return [(Array<Script::Node>, Script::Node)]
The root nodes of the arguments, and the splat argument.
@raise [Sass::SyntaxError] if the argument list isn‘t valid SassScript
Parses the argument list for a mixin include.
@return [(Array<Script::Node>, {String => Script::Node}, Script::Node)]
The root nodes of the positional arguments, keyword arguments, and splat argument. Keyword arguments are in a hash from names to values.
@raise [Sass::SyntaxError] if the argument list isn‘t valid SassScript
Parse a single string value, possibly containing interpolation. Doesn‘t assert that the scanner is finished after parsing.
@return [Script::Node] The root node of the parse tree. @raise [Sass::SyntaxError] if the string isn‘t valid SassScript
Parses a SassScript expression, ending it when it encounters one of the given identifier tokens.
@param [include?(String)] A set of strings that delimit the expression. @return [Script::Node] The root node of the parse tree @raise [Sass::SyntaxError] if the expression isn‘t valid SassScript