static void yasm_ea_set_implicit_size_segment(yasm_parser_nasm *parser_nasm,
yasm_effaddr *ea, yasm_expr *e)
{
- if (tasm_compatible_mode) {
+ if (parser_nasm->tasm) {
const char *segment = yasm_expr_segment(e);
ea->data_len = yasm_expr_size(e);
if (segment) {
case LOCAL_ID:
{
char *name = ID_val;
- int local = tasm_compatible_mode
+ int local = parser_nasm->tasm
? (curtok == ID || curtok == LOCAL_ID ||
(curtok == SPECIAL_ID && name[0] == '@'))
: (curtok != ID);
if (curtok == ':')
get_next_token();
- if (curtok == EQU || (tasm_compatible_mode && curtok == '=')) {
+ if (curtok == EQU || (parser_nasm->tasm && curtok == '=')) {
/* label EQU expr */
yasm_expr *e;
get_next_token();
- if (tasm_compatible_mode && curtok == SIZE_OVERRIDE) {
+ if (parser_nasm->tasm && curtok == SIZE_OVERRIDE) {
size = SIZE_OVERRIDE_val;
get_next_token();
}
return NULL;
}
- if (tasm_compatible_mode && curtok == LABEL)
+ if (parser_nasm->tasm && curtok == LABEL)
get_next_token();
- if (tasm_compatible_mode && curtok == SIZE_OVERRIDE) {
+ if (parser_nasm->tasm && curtok == SIZE_OVERRIDE) {
size = SIZE_OVERRIDE_val;
get_next_token();
}
return parse_times(parser_nasm);
}
bc = parse_exp(parser_nasm);
- if (!tasm_compatible_mode && !bc)
+ if (!parser_nasm->tasm && !bc)
yasm_error_set(YASM_ERROR_SYNTAX,
N_("instruction expected after label"));
- if (tasm_compatible_mode && bc && !size)
+ if (parser_nasm->tasm && bc && !size)
size = yasm_bc_elem_size(bc);
define_label(parser_nasm, name, size, local);
return bc;
return NULL;
}
- if (tasm_compatible_mode && !is_eol() && curtok != ',') {
- yasm_expr *e, *f;
+ if (parser_nasm->tasm && !is_eol() && curtok != ',') {
+ yasm_expr *e = NULL, *f;
yasm_effaddr *ea;
switch (op->type) {
{
uintptr_t segreg = SEGREG_val;
get_next_token();
- if (tasm_compatible_mode && curtok == ':') {
+ if (parser_nasm->tasm && curtok == ':') {
get_next_token();
op = parse_operand(parser_nasm);
if (!op)
if (op->type == YASM_INSN__OPERAND_IMM) {
yasm_effaddr *ea = yasm_arch_ea_create(p_object->arch,
op->data.val);
- yasm_ea_set_implicit_size_segment(parser_nasm, ea, op->data.val);
- yasm_insn_operand *op2 = yasm_operand_create_mem(ea);
+ yasm_insn_operand *op2;
+ yasm_ea_set_implicit_size_segment(parser_nasm, ea,
+ op->data.val);
+ op2 = yasm_operand_create_mem(ea);
op2->size = op->size;
yasm_xfree(op);
op = op2;
case ID:
case LOCAL_ID:
case NONLOCAL_ID:
- if (tasm_compatible_mode) {
+ if (parser_nasm->tasm) {
get_peek_token(parser_nasm);
if (parser_nasm->peek_token == '[') {
yasm_symrec *sym = yasm_symtab_use(p_symtab, ID_val,
if (!e)
return NULL;
if (curtok != ':')
- if (tasm_compatible_mode && yasm_expr_size(e)) {
+ if (parser_nasm->tasm && yasm_expr_size(e)) {
yasm_effaddr *ea = yasm_arch_ea_create(p_object->arch, e);
yasm_ea_set_implicit_size_segment(parser_nasm, ea, e);
op = yasm_operand_create_mem(ea);
case STRING:
{
yasm_intnum *intn;
- if (tasm_compatible_mode)
+ if (parser_nasm->tasm)
intn = yasm_intnum_create_charconst_tasm(STRING_val.contents);
else
intn = yasm_intnum_create_charconst_nasm(STRING_val.contents);
{
yasm_symrec *symrec;
- if ((!tasm_compatible_mode || tasm_locals) && !local) {
+ if ((!parser_nasm->tasm || tasm_locals) && !local) {
if (parser_nasm->locallabel_base)
yasm_xfree(parser_nasm->locallabel_base);
parser_nasm->locallabel_base_len = strlen(name);
#include "nasm-parser.h"
-#include "modules/preprocs/nasm/nasm.h"
-
static void
-nasm_parser_do_parse(yasm_object *object, yasm_preproc *pp,
- int save_input, yasm_linemap *linemap,
- yasm_errwarns *errwarns)
+nasm_do_parse(yasm_object *object, yasm_preproc *pp, int save_input,
+ yasm_linemap *linemap, yasm_errwarns *errwarns, int tasm)
{
yasm_parser_nasm parser_nasm;
+ parser_nasm.tasm = tasm;
+
parser_nasm.object = object;
parser_nasm.linemap = linemap;
yasm_symtab_parser_finalize(object->symtab, 0, errwarns);
}
+static void
+nasm_parser_do_parse(yasm_object *object, yasm_preproc *pp,
+ int save_input, yasm_linemap *linemap,
+ yasm_errwarns *errwarns)
+{
+ nasm_do_parse(object, pp, save_input, linemap, errwarns, 0);
+}
+
#include "nasm-macros.c"
/* Define valid preprocessors to use with this parser */
int save_input, yasm_linemap *linemap,
yasm_errwarns *errwarns)
{
- tasm_compatible_mode = 1;
yasm_symtab_set_case_sensitive(object->symtab, 0);
yasm_warn_disable(YASM_WARN_IMPLICIT_SIZE_OVERRIDE);
- nasm_parser_do_parse(object, pp, save_input, linemap, errwarns);
+ nasm_do_parse(object, pp, save_input, linemap, errwarns, 1);
}
/* Define valid preprocessors to use with this parser */
{
/* check for special non-local labels like ..start */
if (tok[zeropos+1] == '.') {
- lvalp->str_val = yasm__xstrndup(tok+zeropos+(tasm_compatible_mode?2:0),
- toklen-zeropos-(tasm_compatible_mode?2:0));
+ lvalp->str_val = yasm__xstrndup(tok+zeropos+(parser_nasm->tasm?2:0),
+ toklen-zeropos-(parser_nasm->tasm?2:0));
/* check for special non-local ..@label */
if (lvalp->str_val[zeropos+2] == '@')
return NONLOCAL_ID;
return SPECIAL_ID;
}
- if (tasm_compatible_mode && (!tasm_locals ||
+ if (parser_nasm->tasm && (!tasm_locals ||
(tok[zeropos] == '.' &&
tok[zeropos+1] != '@' && tok[zeropos+2] != '@'))) {
/* no locals on Tasm without the 'locals' directive */
/* forced identifier */
"$" [a-zA-Z0-9_$#@~.?]+ {
if (TOK[1] == '.' ||
- (tasm_compatible_mode && TOK[1] == '@' && TOK[2] == '@')) {
+ (parser_nasm->tasm && TOK[1] == '@' && TOK[2] == '@')) {
/* handle like .label */
RETURN(handle_dot_label(lvalp, TOK, TOKLEN, 1, parser_nasm));
}
default:
break;
}
- if (tasm_compatible_mode) {
+ if (parser_nasm->tasm) {
if (!strcasecmp(TOK, "shl")) {
s->tok[TOKLEN] = savech;
RETURN(LEFT_OP);
strbuf_size + STRBUF_ALLOC_SIZE);
strbuf_size += STRBUF_ALLOC_SIZE;
}
- } else if (!tasm_compatible_mode) {
+ } else if (!parser_nasm->tasm) {
YYCURSOR--;
goto stringconst_end;
}