Commit ef6d9046 by Aaron Leung

Adding another matcher and moving a few things around.

parent 07648e9d
......@@ -163,6 +163,8 @@ static SEQUENCE_MATCHER(identstart, sass_prefix_is_optional_hyphen, sass_prefix_
ONE_PLUS_MATCHER(name, sass_prefix_is_nmchar);
FIRST_REST_MATCHER(identifier, sass_prefix_is_identstart, sass_prefix_is_nmchar);
SEQUENCE_MATCHER(variable, sass_prefix_is_dollar, sass_prefix_is_identifier);
static OPTIONAL_MATCHER(optional_digits, sass_prefix_is_digits);
static SEQUENCE_MATCHER(realnum, sass_prefix_is_optional_digits, sass_prefix_is_dot, sass_prefix_is_digits);
ALTERNATIVES_MATCHER(number, sass_prefix_is_digits, sass_prefix_is_realnum);
......@@ -176,8 +178,4 @@ static OPTIONAL_MATCHER(optional_spaces, sass_prefix_is_spaces);
SEQUENCE_MATCHER(adjacent_to, sass_prefix_is_optional_spaces, sass_prefix_is_plus);
SEQUENCE_MATCHER(precedes, sass_prefix_is_optional_spaces, sass_prefix_is_tilde);
SEQUENCE_MATCHER(parent_of, sass_prefix_is_optional_spaces, sass_prefix_is_gt);
char *sass_prefix_is_ancestor_of(char *src) {
char *p = src;
while (isspace(*p)) p++;
return p == src ? NULL : p;
}
\ No newline at end of file
ALIAS_MATCHERS(sass_prefix_is_spaces, ancestor_of);
\ No newline at end of file
......@@ -3,8 +3,11 @@ typedef char *(*sass_prefix_matcher)(char *);
#define DECLARE(name) \
char *sass_prefix_is_ ## name(char *)
#define DECLARE_ALIAS(name) \
sass_prefix_matcher sass_prefix_is_ ## name
#define ALIAS_MATCHERS(orig, new) \
char *(*new)(char *) = orig
sass_prefix_matcher sass_prefix_is_ ## new = &orig
#define CHAR_MATCHER(name, prefix) \
char *sass_prefix_is_ ## name(char *src) { \
......@@ -174,6 +177,8 @@ DECLARE(substringmatch);
DECLARE(name);
DECLARE(identifier);
DECLARE(variable);
DECLARE(number);
DECLARE(string);
......@@ -184,4 +189,5 @@ DECLARE(functional);
DECLARE(adjacent_to);
DECLARE(parent_of);
DECLARE(precedes);
DECLARE(ancestor_of);
\ No newline at end of file
DECLARE_ALIAS(ancestor_of);
......@@ -42,6 +42,8 @@ int main() {
char *integer3 = "-294729+1";
char *class = ".blah-blah_bloo112-blah+blee4 hello";
char *id = "#foo_bar-baz123-hux blee";
char *var = "$blah123-blah";
char *non_var = "$ hux";
test1(sass_prefix_is_spaces, spaces);
test1(sass_prefix_is_spaces, words);
......@@ -95,6 +97,9 @@ int main() {
test1(sass_prefix_is_idname, id);
test1(sass_prefix_is_idname, class);
test1(sass_prefix_is_variable, var);
test1(sass_prefix_is_variable, non_var);
return 0;
......
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