Add ^pl and ^ph expressions from 2.11BSD's m11.

I hope I understood what this is doing!
This commit is contained in:
Olaf Seibert
2017-04-28 22:39:51 +02:00
parent 27abf32bf4
commit 4916b699fa
5 changed files with 122 additions and 0 deletions

36
parse.c
View File

@@ -755,6 +755,42 @@ EX_TREE *parse_unary(
tp = new_ex_lit(flt[0]);
tp->cp = endcp;
}
return tp;
}
case 'p':
/* psect limits, low or high */ {
char bound = tolower((unsigned char)cp[2]);
char *cp2 = skipwhite(cp + 3);
int islocal = 0;
char *endcp;
char *psectname = get_symbol(cp2, &endcp, &islocal);
SYMBOL *sectsym = lookup_sym(psectname, &section_st);
if (sectsym && !islocal) {
SECTION *psect = sectsym->section;
tp = new_ex_tree();
tp->type = EX_SYM;
tp->data.symbol = sectsym;
tp->cp = cp;
if (bound == 'l') {
; /* that's it */
} else if (bound == 'h') {
EX_TREE *rightp = new_ex_lit(psect->size);
tp = new_ex_bin(EX_ADD, tp, rightp);
} else {
tp = ex_err(tp, endcp);
/* report(stack->top, "^p: %c not recognized", bound); */
}
} else {
/* report(stack->top, "psect name %s not found"); */
tp = ex_err(new_ex_lit(0), endcp);
}
free(psectname);
tp->cp = endcp;
cp = endcp;
return tp;
}
}