Commit 6ffd60ae by Aaron Leung

Added a matcher for SCSS variable names.

parent 6030f08c
...@@ -151,5 +151,10 @@ namespace Sass { ...@@ -151,5 +151,10 @@ namespace Sass {
return spaces(src); return spaces(src);
} }
// Match SCSS variable names.
char* variable(char* src) {
return sequence<exactly<'$'>, name>(src);
}
} }
} }
\ No newline at end of file
...@@ -246,6 +246,9 @@ namespace Sass { ...@@ -246,6 +246,9 @@ namespace Sass {
char* parent_of(char* src); char* parent_of(char* src);
char* ancestor_of(char* src); char* ancestor_of(char* src);
// Match SCSS variable names.
char* variable(char* src);
// Utility functions for finding and counting characters in a string. // Utility functions for finding and counting characters in a string.
template<char c> template<char c>
char* find_first(char* src) { char* find_first(char* src) {
......
...@@ -47,6 +47,8 @@ char hex1[] = "#1a2b3c#f1ab"; ...@@ -47,6 +47,8 @@ char hex1[] = "#1a2b3c#f1ab";
char hex2[] = "#abc-zippo"; char hex2[] = "#abc-zippo";
char nonhex1[] = "#ab blah"; char nonhex1[] = "#ab blah";
char nonhex2[] = "#abc123blah"; char nonhex2[] = "#abc123blah";
char var1[] = "$hello blah";
char nonvar1[] = "$ hello";
extern const char slash_star[] = "/*"; extern const char slash_star[] = "/*";
...@@ -88,6 +90,7 @@ int main() { ...@@ -88,6 +90,7 @@ int main() {
check_twice(spaces_and_comments, ws1, num1); check_twice(spaces_and_comments, ws1, num1);
check_twice(hex, hex1, nonhex1); check_twice(hex, hex1, nonhex1);
check_twice(hex, hex2, nonhex2); check_twice(hex, hex2, nonhex2);
check_twice(variable, var1, nonvar1);
cout << count_interval<'\n'>(ws1, spaces_and_comments(ws1)) << endl; cout << count_interval<'\n'>(ws1, spaces_and_comments(ws1)) << endl;
cout << count_interval<'*'>(ws1, spaces_and_comments(ws1)) << endl; cout << count_interval<'*'>(ws1, spaces_and_comments(ws1)) << endl;
cout << count_interval<exactly<slash_star> >(ws1, spaces_and_comments(ws1)) << endl; cout << count_interval<exactly<slash_star> >(ws1, spaces_and_comments(ws1)) << endl;
......
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