mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-02-23 17:29:23 +08:00
A few style fixups in parser.c
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
parent
7add67f949
commit
447e20cf96
39
parser.c
39
parser.c
@ -192,13 +192,13 @@ static void process_size_override(insn *result, int operand)
|
||||
|
||||
insn *parse_line(int pass, char *buffer, insn *result, ldfunc ldef)
|
||||
{
|
||||
bool insn_is_label = false;
|
||||
struct eval_hints hints;
|
||||
int operand;
|
||||
int critical;
|
||||
struct eval_hints hints;
|
||||
int j;
|
||||
bool first;
|
||||
bool insn_is_label = false;
|
||||
bool recover;
|
||||
int j;
|
||||
|
||||
restart_parse:
|
||||
first = true;
|
||||
@ -212,10 +212,12 @@ restart_parse:
|
||||
result->eops = NULL; /* must do this, whatever happens */
|
||||
result->operands = 0; /* must initialize this */
|
||||
|
||||
if (i == 0) { /* blank line - ignore */
|
||||
result->opcode = I_none; /* and no instruction either */
|
||||
/* Ignore blank lines */
|
||||
if (i == TOKEN_EOS) {
|
||||
result->opcode = I_none;
|
||||
return result;
|
||||
}
|
||||
|
||||
if (i != TOKEN_ID && i != TOKEN_INSN && i != TOKEN_PREFIX &&
|
||||
(i != TOKEN_REG || (REG_SREG & ~nasm_reg_flags[tokval.t_integer]))) {
|
||||
nasm_error(ERR_NONFATAL, "label or instruction expected"
|
||||
@ -248,8 +250,9 @@ restart_parse:
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
result->opcode = I_none; /* this line contains just a label */
|
||||
/* Just a label here */
|
||||
if (i == TOKEN_EOS) {
|
||||
result->opcode = I_none;
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -307,9 +310,10 @@ restart_parse:
|
||||
int j;
|
||||
enum prefixes pfx;
|
||||
|
||||
for (j = 0; j < MAXPREFIX; j++)
|
||||
for (j = 0; j < MAXPREFIX; j++) {
|
||||
if ((pfx = result->prefixes[j]) != P_none)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == 0 && pfx != P_none) {
|
||||
/*
|
||||
@ -361,7 +365,7 @@ restart_parse:
|
||||
*/
|
||||
while (1) {
|
||||
i = stdscan(NULL, &tokval);
|
||||
if (i == 0)
|
||||
if (i == TOKEN_EOS)
|
||||
break;
|
||||
else if (first && i == ':') {
|
||||
insn_is_label = true;
|
||||
@ -494,7 +498,7 @@ is_expression:
|
||||
* arguments. However, we'd better check first that it
|
||||
* _is_ a comma.
|
||||
*/
|
||||
if (i == 0) /* also could be EOL */
|
||||
if (i == TOKEN_EOS) /* also could be EOL */
|
||||
break;
|
||||
if (i != ',') {
|
||||
nasm_error(ERR_NONFATAL, "comma expected after operand %d",
|
||||
@ -541,8 +545,10 @@ is_expression:
|
||||
return result;
|
||||
}
|
||||
|
||||
/* right. Now we begin to parse the operands. There may be up to four
|
||||
* of these, separated by commas, and terminated by a zero token. */
|
||||
/*
|
||||
* Now we begin to parse the operands. There may be up to four
|
||||
* of these, separated by commas, and terminated by a zero token.
|
||||
*/
|
||||
|
||||
for (operand = 0; operand < MAX_OPERANDS; operand++) {
|
||||
expr *value; /* used most of the time */
|
||||
@ -555,7 +561,7 @@ is_expression:
|
||||
result->oprs[operand].opflags = 0;
|
||||
|
||||
i = stdscan(NULL, &tokval);
|
||||
if (i == 0)
|
||||
if (i == TOKEN_EOS)
|
||||
break; /* end of operands: get out of here */
|
||||
else if (first && i == ':') {
|
||||
insn_is_label = true;
|
||||
@ -840,8 +846,7 @@ is_expression:
|
||||
result->oprs[operand].segment = NO_SEG; /* don't care again */
|
||||
result->oprs[operand].wrt = NO_SEG; /* still don't care */
|
||||
|
||||
if(optimizing >= 0 && !(result->oprs[operand].type & STRICT))
|
||||
{
|
||||
if(optimizing >= 0 && !(result->oprs[operand].type & STRICT)) {
|
||||
/* Be optimistic */
|
||||
result->oprs[operand].type |=
|
||||
SBYTE16 | SBYTE32 | SBYTE64 | UDWORD64 | SDWORD64;
|
||||
@ -851,6 +856,7 @@ is_expression:
|
||||
result->oprs[operand].offset = reloc_value(value);
|
||||
result->oprs[operand].segment = reloc_seg(value);
|
||||
result->oprs[operand].wrt = reloc_wrt(value);
|
||||
|
||||
if (is_simple(value)) {
|
||||
if (reloc_value(value) == 1)
|
||||
result->oprs[operand].type |= UNITY;
|
||||
@ -957,13 +963,14 @@ is_expression:
|
||||
|
||||
static int is_comma_next(void)
|
||||
{
|
||||
struct tokenval tv;
|
||||
char *p;
|
||||
int i;
|
||||
struct tokenval tv;
|
||||
|
||||
p = stdscan_get();
|
||||
i = stdscan(NULL, &tv);
|
||||
stdscan_set(p);
|
||||
|
||||
return (i == ',' || i == ';' || !i);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user