summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-07-18 18:49:55 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-07-18 18:49:55 -0700
commit00444ae04e91cfd14b505e54934aecf4462eadea (patch)
tree7ee1b495a3bb1afe77ab8cb9fec43034f0b0ada9
parent605f5155eeedea126c4fe4f2387e7a3da0fc3063 (diff)
downloadnasm-00444ae04e91cfd14b505e54934aecf4462eadea.tar.gz
nasm-00444ae04e91cfd14b505e54934aecf4462eadea.tar.bz2
nasm-00444ae04e91cfd14b505e54934aecf4462eadea.zip
Drop efunc and evaluate argument to parse_line()
We never invoked the parser with anything but the default definitions for evaluate and efunc. Unlike the backend, though, we sometimes invoke parse_line() with redefine_label() instead of define_label(). Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--nasm.c4
-rw-r--r--parser.c96
-rw-r--r--parser.h7
3 files changed, 51 insertions, 56 deletions
diff --git a/nasm.c b/nasm.c
index d6db557..5e2e205 100644
--- a/nasm.c
+++ b/nasm.c
@@ -1497,9 +1497,7 @@ static void assemble_file(char *fname, StrList **depend_ptr)
directive);
}
} else { /* it isn't a directive */
-
- parse_line(pass1, line, &output_ins,
- nasm_error, evaluate, def_label);
+ parse_line(pass1, line, &output_ins, def_label);
if (optimizing > 0) {
if (forwref != NULL && globallineno == forwref->lineno) {
diff --git a/parser.c b/parser.c
index 9b9e89a..2ff6e36 100644
--- a/parser.c
+++ b/parser.c
@@ -48,6 +48,7 @@
#include "insns.h"
#include "nasmlib.h"
#include "stdscan.h"
+#include "eval.h"
#include "parser.h"
#include "float.h"
#include "tables.h"
@@ -60,7 +61,6 @@ static int is_comma_next(void);
static int i;
static struct tokenval tokval;
-static efunc error;
static struct location *location; /* Pointer to current line's segment,offset */
void parser_global_info(struct location * locp)
@@ -98,7 +98,7 @@ static int prefix_slot(enum prefixes prefix)
case P_ASP:
return PPS_ASIZE;
default:
- error(ERR_PANIC, "Invalid value %d passed to prefix_slot()", prefix);
+ nasm_error(ERR_PANIC, "Invalid value %d passed to prefix_slot()", prefix);
return -1;
}
}
@@ -139,7 +139,7 @@ static void process_size_override(insn * result, int operand)
result->oprs[operand].type |= BITS128;
break;
default:
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"invalid operand size specification");
break;
}
@@ -164,7 +164,7 @@ static void process_size_override(insn * result, int operand)
case P_A64:
if (result->prefixes[PPS_ASIZE] &&
result->prefixes[PPS_ASIZE] != tokval.t_integer)
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"conflicting address size specifications");
else
result->prefixes[PPS_ASIZE] = tokval.t_integer;
@@ -183,15 +183,14 @@ static void process_size_override(insn * result, int operand)
result->oprs[operand].eaflags |= EAF_WORDOFFS;
break;
default:
- error(ERR_NONFATAL, "invalid size specification in"
+ nasm_error(ERR_NONFATAL, "invalid size specification in"
" effective address");
break;
}
}
}
-insn *parse_line(int pass, char *buffer, insn * result,
- efunc errfunc, evalfunc evaluate, ldfunc ldef)
+insn *parse_line(int pass, char *buffer, insn *result, ldfunc ldef)
{
int operand;
int critical;
@@ -204,7 +203,6 @@ insn *parse_line(int pass, char *buffer, insn * result,
restart_parse:
first = true;
result->forw_ref = false;
- error = errfunc;
stdscan_reset();
stdscan_bufptr = buffer;
@@ -220,7 +218,7 @@ restart_parse:
}
if (i != TOKEN_ID && i != TOKEN_INSN && i != TOKEN_PREFIX &&
(i != TOKEN_REG || (REG_SREG & ~nasm_reg_flags[tokval.t_integer]))) {
- error(ERR_NONFATAL, "label or instruction expected"
+ nasm_error(ERR_NONFATAL, "label or instruction expected"
" at start of line");
result->opcode = -1;
return result;
@@ -234,7 +232,7 @@ restart_parse:
if (i == ':') { /* skip over the optional colon */
i = stdscan(NULL, &tokval);
} else if (i == 0) {
- error(ERR_WARNING | ERR_WARN_OL | ERR_PASS1,
+ nasm_error(ERR_WARNING | ERR_WARN_OL | ERR_PASS1,
"label alone on a line without a colon might be in error");
}
if (i != TOKEN_INSN || tokval.t_integer != I_EQU) {
@@ -272,20 +270,20 @@ restart_parse:
i = stdscan(NULL, &tokval);
value =
- evaluate(stdscan, NULL, &tokval, NULL, pass0, error, NULL);
+ evaluate(stdscan, NULL, &tokval, NULL, pass0, nasm_error, NULL);
i = tokval.t_type;
if (!value) { /* but, error in evaluator */
result->opcode = -1; /* unrecoverable parse error: */
return result; /* ignore this instruction */
}
if (!is_simple(value)) {
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"non-constant argument supplied to TIMES");
result->times = 1L;
} else {
result->times = value->value;
if (value->value < 0 && pass0 == 2) {
- error(ERR_NONFATAL, "TIMES value %d is negative",
+ nasm_error(ERR_NONFATAL, "TIMES value %d is negative",
value->value);
result->times = 0;
}
@@ -294,10 +292,10 @@ restart_parse:
int slot = prefix_slot(tokval.t_integer);
if (result->prefixes[slot]) {
if (result->prefixes[slot] == tokval.t_integer)
- error(ERR_WARNING,
+ nasm_error(ERR_WARNING,
"instruction has redundant prefixes");
else
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"instruction has conflicting prefixes");
}
result->prefixes[slot] = tokval.t_integer;
@@ -326,7 +324,7 @@ restart_parse:
result->oprs[0].segment = result->oprs[0].wrt = NO_SEG;
return result;
} else {
- error(ERR_NONFATAL, "parser: instruction expected");
+ nasm_error(ERR_NONFATAL, "parser: instruction expected");
result->opcode = -1;
return result;
}
@@ -395,7 +393,7 @@ restart_parse:
i = stdscan(NULL, &tokval);
}
if (i != TOKEN_STR) {
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"%s must be followed by a string constant",
funcname);
eop->type = EOT_NOTHING;
@@ -405,14 +403,14 @@ restart_parse:
string_transform(tokval.t_charptr, tokval.t_inttwo,
&eop->stringval, func);
if (eop->stringlen == (size_t)-1) {
- error(ERR_NONFATAL, "invalid string for transform");
+ nasm_error(ERR_NONFATAL, "invalid string for transform");
eop->type = EOT_NOTHING;
}
}
if (parens && i && i != ')') {
i = stdscan(NULL, &tokval);
if (i != ')') {
- error(ERR_NONFATAL, "unterminated %s function",
+ nasm_error(ERR_NONFATAL, "unterminated %s function",
funcname);
}
}
@@ -454,12 +452,12 @@ restart_parse:
eop->stringlen = 16;
break;
case I_DY:
- error(ERR_NONFATAL, "floating-point constant"
+ nasm_error(ERR_NONFATAL, "floating-point constant"
" encountered in DY instruction");
eop->stringlen = 0;
break;
default:
- error(ERR_NONFATAL, "floating-point constant"
+ nasm_error(ERR_NONFATAL, "floating-point constant"
" encountered in unknown instruction");
/*
* fix suggested by Pedro Gimeno... original line
@@ -476,7 +474,7 @@ restart_parse:
if (!eop->stringlen ||
!float_const(tokval.t_charptr, sign,
(uint8_t *)eop->stringval,
- eop->stringlen, error))
+ eop->stringlen, nasm_error))
eop->type = EOT_NOTHING;
i = stdscan(NULL, &tokval); /* eat the comma */
} else {
@@ -485,7 +483,7 @@ restart_parse:
is_expression:
value = evaluate(stdscan, NULL, &tokval, NULL,
- critical, error, NULL);
+ critical, nasm_error, NULL);
i = tokval.t_type;
if (!value) { /* error in evaluator */
result->opcode = -1; /* unrecoverable parse error: */
@@ -501,7 +499,7 @@ restart_parse:
eop->segment = reloc_seg(value);
eop->wrt = reloc_wrt(value);
} else {
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"operand %d: expression is not simple"
" or relocatable", oper_num);
}
@@ -516,7 +514,7 @@ restart_parse:
if (i == 0) /* also could be EOL */
break;
if (i != ',') {
- error(ERR_NONFATAL, "comma expected after operand %d",
+ nasm_error(ERR_NONFATAL, "comma expected after operand %d",
oper_num);
result->opcode = -1; /* unrecoverable parse error: */
return result; /* ignore this instruction */
@@ -530,18 +528,18 @@ restart_parse:
* operands.
*/
if (!result->eops || result->eops->type != EOT_DB_STRING)
- error(ERR_NONFATAL, "`incbin' expects a file name");
+ nasm_error(ERR_NONFATAL, "`incbin' expects a file name");
else if (result->eops->next &&
result->eops->next->type != EOT_DB_NUMBER)
- error(ERR_NONFATAL, "`incbin': second parameter is",
+ nasm_error(ERR_NONFATAL, "`incbin': second parameter is",
" non-numeric");
else if (result->eops->next && result->eops->next->next &&
result->eops->next->next->type != EOT_DB_NUMBER)
- error(ERR_NONFATAL, "`incbin': third parameter is",
+ nasm_error(ERR_NONFATAL, "`incbin': third parameter is",
" non-numeric");
else if (result->eops->next && result->eops->next->next &&
result->eops->next->next->next)
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"`incbin': more than three parameters");
else
return result;
@@ -552,7 +550,7 @@ restart_parse:
result->opcode = -1;
return result;
} else /* DB ... */ if (oper_num == 0)
- error(ERR_WARNING | ERR_PASS1,
+ nasm_error(ERR_WARNING | ERR_PASS1,
"no operand for data declaration");
else
result->operands = oper_num;
@@ -636,7 +634,7 @@ restart_parse:
result->oprs[operand].type |= SHORT;
break;
default:
- error(ERR_NONFATAL, "invalid operand size specification");
+ nasm_error(ERR_NONFATAL, "invalid operand size specification");
}
i = stdscan(NULL, &tokval);
}
@@ -656,17 +654,17 @@ restart_parse:
if ((result->oprs[operand].type & FAR) && !mref &&
result->opcode != I_JMP && result->opcode != I_CALL) {
- error(ERR_NONFATAL, "invalid use of FAR operand specifier");
+ nasm_error(ERR_NONFATAL, "invalid use of FAR operand specifier");
}
value = evaluate(stdscan, NULL, &tokval,
&result->oprs[operand].opflags,
- critical, error, &hints);
+ critical, nasm_error, &hints);
i = tokval.t_type;
if (result->oprs[operand].opflags & OPFLAG_FORWARD) {
result->forw_ref = true;
}
- if (!value) { /* error in evaluator */
+ if (!value) { /* nasm_error in evaluator */
result->opcode = -1; /* unrecoverable parse error: */
return result; /* ignore this instruction */
}
@@ -676,9 +674,9 @@ restart_parse:
*/
if (value[1].type != 0 || value->value != 1 ||
REG_SREG & ~nasm_reg_flags[value->type])
- error(ERR_NONFATAL, "invalid segment override");
+ nasm_error(ERR_NONFATAL, "invalid segment override");
else if (result->prefixes[PPS_SEG])
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"instruction has conflicting segment overrides");
else {
result->prefixes[PPS_SEG] = value->type;
@@ -693,7 +691,7 @@ restart_parse:
}
value = evaluate(stdscan, NULL, &tokval,
&result->oprs[operand].opflags,
- critical, error, &hints);
+ critical, nasm_error, &hints);
i = tokval.t_type;
if (result->oprs[operand].opflags & OPFLAG_FORWARD) {
result->forw_ref = true;
@@ -708,18 +706,18 @@ restart_parse:
recover = false;
if (mref && bracket) { /* find ] at the end */
if (i != ']') {
- error(ERR_NONFATAL, "parser: expecting ]");
+ nasm_error(ERR_NONFATAL, "parser: expecting ]");
recover = true;
} else { /* we got the required ] */
i = stdscan(NULL, &tokval);
if (i != 0 && i != ',') {
- error(ERR_NONFATAL, "comma or end of line expected");
+ nasm_error(ERR_NONFATAL, "comma or end of line expected");
recover = true;
}
}
} else { /* immediate operand */
if (i != 0 && i != ',' && i != ':') {
- error(ERR_NONFATAL, "comma, colon or end of line expected");
+ nasm_error(ERR_NONFATAL, "comma, colon or end of line expected");
recover = true;
} else if (i == ':') {
result->oprs[operand].type |= COLON;
@@ -755,7 +753,7 @@ restart_parse:
i = e->type, s = e->value; /* second has to be indexreg */
else if (e->value != 1) { /* If both want to be index */
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"beroset-p-592-invalid effective address");
result->opcode = -1;
return result;
@@ -765,7 +763,7 @@ restart_parse:
}
if (e->type != 0) { /* is there an offset? */
if (e->type <= EXPR_REG_END) { /* in fact, is there an error? */
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"beroset-p-603-invalid effective address");
result->opcode = -1;
return result;
@@ -791,7 +789,7 @@ restart_parse:
* Look for a segment base type.
*/
if (e->type && e->type < EXPR_SEGBASE) {
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"beroset-p-630-invalid effective address");
result->opcode = -1;
return result;
@@ -799,7 +797,7 @@ restart_parse:
while (e->type && e->value == 0)
e++;
if (e->type && e->value != 1) {
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"beroset-p-637-invalid effective address");
result->opcode = -1;
return result;
@@ -813,7 +811,7 @@ restart_parse:
while (e->type && e->value == 0)
e++;
if (e->type) {
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"beroset-p-650-invalid effective address");
result->opcode = -1;
return result;
@@ -827,7 +825,7 @@ restart_parse:
}
if (e->type != 0) { /* there'd better be nothing left! */
- error(ERR_NONFATAL,
+ nasm_error(ERR_NONFATAL,
"beroset-p-663-invalid effective address");
result->opcode = -1;
return result;
@@ -888,7 +886,7 @@ restart_parse:
unsigned int rs;
if (value->type >= EXPR_SIMPLE || value->value != 1) {
- error(ERR_NONFATAL, "invalid operand type");
+ nasm_error(ERR_NONFATAL, "invalid operand type");
result->opcode = -1;
return result;
}
@@ -898,7 +896,7 @@ restart_parse:
*/
for (i = 1; value[i].type; i++)
if (value[i].value) {
- error(ERR_NONFATAL, "invalid operand type");
+ nasm_error(ERR_NONFATAL, "invalid operand type");
result->opcode = -1;
return result;
}
@@ -919,7 +917,7 @@ restart_parse:
result->oprs[operand].basereg = value->type;
if (rs && (result->oprs[operand].type & SIZE_MASK) != rs)
- error(ERR_WARNING | ERR_PASS1,
+ nasm_error(ERR_WARNING | ERR_PASS1,
"register size specification ignored");
}
}
diff --git a/parser.h b/parser.h
index eb882ed..9b2b6d6 100644
--- a/parser.h
+++ b/parser.h
@@ -39,9 +39,8 @@
#ifndef NASM_PARSER_H
#define NASM_PARSER_H
-void parser_global_info(struct location * locp);
-insn *parse_line(int pass, char *buffer, insn * result,
- efunc error, evalfunc evaluate, ldfunc ldef);
-void cleanup_insn(insn * instruction);
+void parser_global_info(struct location *locp);
+insn *parse_line(int pass, char *buffer, insn *result, ldfunc ldef);
+void cleanup_insn(insn *instruction);
#endif