(uxnasm) Print active file in error
This commit is contained in:
parent
25e3e4e3ba
commit
80e2f9cc0c
19
src/uxnasm.c
19
src/uxnasm.c
|
@ -36,7 +36,7 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Uint8 data[LENGTH];
|
Uint8 data[LENGTH];
|
||||||
Uint8 lambda_stack[0x100], lambda_ptr, lambda_count;
|
Uint8 lambda_stack[0x100], lambda_ptr, lambda_count;
|
||||||
char scope[0x40], lambda[0x10];
|
char scope[0x40], lambda[0x10], *location;
|
||||||
unsigned int ptr, length;
|
unsigned int ptr, length;
|
||||||
Uint16 label_len, macro_len, refs_len;
|
Uint16 label_len, macro_len, refs_len;
|
||||||
Label labels[0x400];
|
Label labels[0x400];
|
||||||
|
@ -72,10 +72,17 @@ static int parse(char *w, FILE *f);
|
||||||
static int
|
static int
|
||||||
error(const char *name, const char *msg)
|
error(const char *name, const char *msg)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: %s\n", name, msg);
|
fprintf(stderr, "%s: %s in %s:\n", name, msg, p.location);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
setlocation(char *name)
|
||||||
|
{
|
||||||
|
p.location = name;
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
sublabel(char *src, char *scope, char *name)
|
sublabel(char *src, char *scope, char *name)
|
||||||
{
|
{
|
||||||
|
@ -261,11 +268,11 @@ writelitbyte(Uint8 b)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
doinclude(const char *filename)
|
doinclude(char *filename)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char w[0x40];
|
char w[0x40];
|
||||||
if(!(f = fopen(filename, "r")))
|
if(!(f = fopen(setlocation(filename), "r")))
|
||||||
return error("Include missing", filename);
|
return error("Include missing", filename);
|
||||||
while(fscanf(f, "%63s", w) == 1)
|
while(fscanf(f, "%63s", w) == 1)
|
||||||
if(!parse(w, f))
|
if(!parse(w, f))
|
||||||
|
@ -515,8 +522,8 @@ main(int argc, char *argv[])
|
||||||
if(argc == 1)
|
if(argc == 1)
|
||||||
return error("usage", "uxnasm [-v] input.tal output.rom");
|
return error("usage", "uxnasm [-v] input.tal output.rom");
|
||||||
if(argv[1][0] == '-' && argv[1][1] == 'v')
|
if(argv[1][0] == '-' && argv[1][1] == 'v')
|
||||||
return !fprintf(stdout, "Uxnasm - Uxntal Assembler, 25 Feb 2024.\n");
|
return !fprintf(stdout, "Uxnasm - Uxntal Assembler, 1 Mar 2024.\n");
|
||||||
if(!(src = fopen(argv[1], "r")))
|
if(!(src = fopen(setlocation(argv[1]), "r")))
|
||||||
return !error("Invalid input", argv[1]);
|
return !error("Invalid input", argv[1]);
|
||||||
if(!assemble(src))
|
if(!assemble(src))
|
||||||
return !error("Assembly", "Failed to assemble rom.");
|
return !error("Assembly", "Failed to assemble rom.");
|
||||||
|
|
Loading…
Reference in New Issue