Exemplo n.º 1
0
local int
size_formals(Expr *formals)
{
	int	n;

	n = 0;
	while (formals != NULL && formals->e_class == E_APPLY) {
		n += size_pattern(formals->e_arg);
		formals = formals->e_func;
	}
	return n;
}
Exemplo n.º 2
0
local int
size_pattern(Expr *pattern)
{
	switch (pattern->e_class) {
	case E_APPLY:
		return size_pattern(pattern->e_arg) + 1;
	case E_PAIR:
		return size_pattern(pattern->e_left) +
			size_pattern(pattern->e_right);
	case E_PLUS:
		return size_pattern(pattern->e_rest) + pattern->e_incr;
	case E_NUM:
		return (int)(pattern->e_num) + 1;
	case E_CONS or E_CHAR:
		return 1;
	case E_VAR:
		return 0;
	otherwise:
		NOT_REACHED;
	}
}
Exemplo n.º 3
0
int rgrep_matches(char *line, char *pattern) {
    return matches(0, 0, size_pattern(line), size_pattern(pattern), line, pattern);
}