Example #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);
	};
Example #2
0
struct value *lns_make_concat(struct info *info,
                              struct lens *l1, struct lens *l2, int check) {
    struct lens *lens = NULL;

    if (check) {
        struct value *exn = typecheck_concat(info, l1, l2);
        if (exn != NULL) {
            return exn;
        }
    }
    if (l1->value && l2->value) {
        return make_exn_value(info, "Multiple stores in concat");
    }
    if (l1->key && l2->key) {
        return make_exn_value(info, "Multiple keys/labels in concat");
    }

    lens = make_lens_binop(L_CONCAT, info, l1, l2, regexp_concat_n);
    lens->consumes_value = l1->consumes_value || l2->consumes_value;
    return make_lens_value(lens);
}