示例#1
0
文件: parser.cpp 项目: artju01/waffle
// Parse a postfix expr.
//
//    postfix-expr ::= applicaiton-expr
Tree*
parse_postfix_expr(Parser& p) {
  if (Tree* t1 = parse_primary_expr(p)) {
    while (t1) {
      if (Tree* t2 = parse_dot_expr(p, t1))
        t1 = t2;
      else if (Tree* t2 = parse_application_expr(p, t1)) 
        t1 = t2;
      else if (Tree* t2 = parse_and_expr(p, t1))
        t1 = t2;
      else if (Tree* t2 = parse_or_expr(p, t1))
        t1 = t2;
      else if (Tree* t2 = parse_eq_comp_expr(p, t1))
        t1 = t2;
      else if (Tree* t2 = parse_less_expr(p, t1))
        t1 = t2;
      else if (Tree* t2 = parse_union(p, t1))
        t1 = t2;
      else if (Tree* t2 = parse_intersect(p, t1))
        t1 = t2;
      else if (Tree* t2 = parse_except(p, t1))
        t1 = t2;
      else if (Tree* t2 = parse_join(p, t1))
        t1 = t2;
      else if (Tree* t2 = parse_as(p, t1))
        t1 = t2;
      else 
        break;
    }
    return t1;
  }
  return parse_primary_expr(p);
}
示例#2
0
static int parse_or_expr (pfstate_t *pf)
{
	int result;

	result = parse_and_expr (pf);
	if (result < 0) return (-1);
	
	while (pf->token_type == TOKEN_OR) {
	  int e;

	  next_token (pf);
	  e = parse_and_expr (pf);
	  if (e < 0) return (-1);
	  result |= e;
	}

	return (result);
}