Commit 7d2dd600 by Aaron Leung

Working on parsing attribute selectors.

parent a5080f4e
[hey = 'ho'] {
blah: blah;
[hoo *= "ha" ] {
bloo: bloo;
}
}
\ No newline at end of file
......@@ -105,6 +105,7 @@ namespace Sass {
Node parse_selector();
Node parse_simple_selector_sequence();
Node parse_simple_selector();
Node parse_attribute_selector();
Node parse_block();
Node parse_rule();
Node parse_values();
......
......@@ -86,9 +86,27 @@ namespace Sass {
Node Document::parse_simple_selector()
{
lex< id_name >() || lex< class_name >() /*|| lex< attribute >() ||
lex< pseudo >() || lex< negation >()*/ ;
return Node(line_number, Node::simple_selector, lexed);
if (lex< id_name >() || lex< class_name >()) {
return Node(line_number, Node::simple_selector, lexed);
}
else if (peek< exactly<'['> >(position)) {
return parse_attribute_selector();
}
}
Node Document::parse_attribute_selector()
{
Node attr_sel(line_number, Node::attribute_selector, 3);
lex< exactly<'['> >();
lex< type_selector >();
attr_sel << Node(line_number, Node::value, lexed);
lex< alternatives< exact_match, class_match, dash_match,
prefix_match, suffix_match, substring_match > >();
attr_sel << Node(line_number, Node::value, lexed);
lex< string_constant >();
attr_sel << Node(line_number, Node::value, lexed);
lex< exactly<']'> >();
return attr_sel;
}
Node Document::parse_block()
......
......@@ -121,6 +121,26 @@ namespace Sass {
return rslt;
}
// Same as above, but with 5 arguments.
template <prelexer mx1, prelexer mx2, prelexer mx3,
prelexer mx4, prelexer mx5>
char* alternatives(char* src) {
char* rslt;
(rslt = mx1(src)) || (rslt = mx2(src)) || (rslt = mx3(src)) ||
(rslt = mx4(src)) || (rslt = mx5(src));
return rslt;
}
// Same as above, but with 6 arguments.
template <prelexer mx1, prelexer mx2, prelexer mx3,
prelexer mx4, prelexer mx5, prelexer mx6>
char* alternatives(char* src) {
char* rslt;
(rslt = mx1(src)) || (rslt = mx2(src)) || (rslt = mx3(src)) ||
(rslt = mx4(src)) || (rslt = mx5(src)) || (rslt = mx6(src));
return rslt;
}
// Tries the matchers in sequence and succeeds if they all succeed.
template <prelexer mx1, prelexer mx2>
char* sequence(char* src) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment