Exemple #1
0
/*
   type checking positions
*/
static int typecheck_position (rule srule, int altnr, pos p, int dtype)
	{ expr ex = p -> ex;
	  int rtype = 0;
	  int ctype = balance_type (srule, altnr, dtype, p -> type);
	  switch (ex -> tag)
	     { case tag_single:
		  rtype = typecheck_affix (srule, altnr, ex -> u.single, ctype);
		  break;
	       case tag_compos:
		  rtype = typecheck_compos(srule, altnr, ex -> u.compos, ctype);
		  break;
	       case tag_concat:
		  rtype = typecheck_concat(srule, altnr, ex -> u.concat, ctype);
		  break;
	       case tag_union:
		  rtype = typecheck_union (srule, altnr, ex -> u.uni, ctype);
		  break;
	       default: bad_tag (ex -> tag, "typecheck_position");
	     };
	  if (p -> type != rtype)
	     { p -> type = rtype;
	       change = 1;
	     };
	  return (rtype);
	};
Exemple #2
0
struct value *lns_make_union(struct info *info,
                             struct lens *l1, struct lens *l2, int check) {
    struct lens *lens = NULL;

    if (check) {
        struct value *exn = typecheck_union(info, l1, l2);
        if (exn != NULL)
            return exn;
    }

    lens = make_lens_binop(L_UNION, info, l1, l2, regexp_union_n);
    lens->consumes_value = l1->consumes_value && l2->consumes_value;
    return make_lens_value(lens);
}