Class: Sass::SCSS::Parser
- Inherits:
-
Object
- Object
- Sass::SCSS::Parser
- Includes:
- RX
- Defined in:
- lib/sass/scss/parser.rb
Overview
The parser for SCSS. It parses a string of code into a tree of Tree::Nodes.
Direct Known Subclasses
Constant Summary
Constants included from RX
RX::ANY, RX::CDC, RX::CDO, RX::COMMENT, RX::DASHMATCH, RX::DOMAIN, RX::ESCAPE, RX::FUNCTION, RX::GREATER, RX::H, RX::HASH, RX::HEXCOLOR, RX::IDENT, RX::IDENT_HYPHEN_INTERP, RX::IDENT_START, RX::IMPORTANT, RX::INCLUDES, RX::INTERP_START, RX::NAME, RX::NL, RX::NMCHAR, RX::NMSTART, RX::NONASCII, RX::NOT, RX::NUM, RX::NUMBER, RX::OPTIONAL, RX::PERCENTAGE, RX::PLUS, RX::PREFIXMATCH, RX::RANGE, RX::S, RX::SINGLE_LINE_COMMENT, RX::STATIC_COMPONENT, RX::STATIC_SELECTOR, RX::STATIC_VALUE, RX::STRING, RX::STRING1, RX::STRING1_NOINTERP, RX::STRING2, RX::STRING2_NOINTERP, RX::STRING_NOINTERP, RX::SUBSTRINGMATCH, RX::SUFFIXMATCH, RX::TILDE, RX::UNICODE, RX::UNICODERANGE, RX::UNIT, RX::UNITLESS_NUMBER, RX::URI, RX::URL, RX::URLCHAR, RX::URL_PREFIX, RX::VARIABLE, RX::W
Instance Attribute Summary collapse
-
#offset
Expose for the SASS parser.
Instance Method Summary collapse
-
#initialize(str, filename, importer, line = 1, offset = 1) ⇒ Parser
constructor
A new instance of Parser.
-
#parse ⇒ Sass::Tree::RootNode
Parses an SCSS document.
-
#parse_at_root_query ⇒ Array<String, Sass::Script;:Tree::Node>
Parses an at-root query.
-
#parse_interp_ident ⇒ Array<String, Sass::Script::Tree::Node>?
Parses an identifier with interpolation.
-
#parse_media_query_list ⇒ Sass::Media::QueryList
Parses a media query list.
-
#parse_supports_condition ⇒ Sass::Supports::Condition
Parses a supports query condition.
Methods included from RX
Constructor Details
#initialize(str, filename, importer, line = 1, offset = 1) ⇒ Parser
Returns a new instance of Parser.
26 27 28 29 30 31 32 33 34 |
# File 'lib/sass/scss/parser.rb', line 26
def initialize(str, filename, importer, line = 1, offset = 1)
# rubocop:enable ParameterLists
@template = str
@filename = filename
@importer = importer
@line = line
@offset = offset
@strs = []
end
|
Instance Attribute Details
#offset
Expose for the SASS parser.
10 11 12 |
# File 'lib/sass/scss/parser.rb', line 10
def offset
@offset
end
|
Instance Method Details
#parse ⇒ Sass::Tree::RootNode
Parses an SCSS document.
40 41 42 43 44 45 |
# File 'lib/sass/scss/parser.rb', line 40
def parse
init_scanner!
root = stylesheet
expected("selector or at-rule") unless root && @scanner.eos?
root
end
|
#parse_at_root_query ⇒ Array<String, Sass::Script;:Tree::Node>
Parses an at-root query.
75 76 77 78 79 80 |
# File 'lib/sass/scss/parser.rb', line 75
def parse_at_root_query
init_scanner!
query = at_root_query
expected("@at-root query list") unless query && @scanner.eos?
query
end
|
#parse_interp_ident ⇒ Array<String, Sass::Script::Tree::Node>?
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.
53 54 55 56 |
# File 'lib/sass/scss/parser.rb', line 53
def parse_interp_ident
init_scanner!
interp_ident
end
|
#parse_media_query_list ⇒ Sass::Media::QueryList
Parses a media query list.
63 64 65 66 67 68 |
# File 'lib/sass/scss/parser.rb', line 63
def parse_media_query_list
init_scanner!
ql = media_query_list
expected("media query list") unless ql && @scanner.eos?
ql
end
|
#parse_supports_condition ⇒ Sass::Supports::Condition
Parses a supports query condition.
87 88 89 90 91 92 |
# File 'lib/sass/scss/parser.rb', line 87
def parse_supports_condition
init_scanner!
condition = supports_condition
expected("supports condition") unless condition && @scanner.eos?
condition
end
|