Replace error/warning numbers by strings.

More work on address sizes and scoping.


git-svn-id: svn://svn.cc65.org/cc65/trunk@2620 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2003-11-08 17:20:21 +00:00
parent 7e74078801
commit 44976a0461
25 changed files with 294 additions and 493 deletions

View File

@@ -7,9 +7,9 @@
/* */ /* */
/* */ /* */
/* (C) 2000-2003 Ullrich von Bassewitz */ /* (C) 2000-2003 Ullrich von Bassewitz */
/* Wacholderweg 14 */ /* R<EFBFBD>merstra<EFBFBD>e 52 */
/* D-70597 Stuttgart */ /* D-70794 Filderstadt */
/* EMail: uz@musoftware.de */ /* EMail: uz@cc65.org */
/* */ /* */
/* */ /* */
/* This software is provided 'as-is', without any expressed or implied */ /* This software is provided 'as-is', without any expressed or implied */
@@ -90,7 +90,7 @@ static IfDesc* AllocIf (const char* Directive, int NeedTerm)
/* Check for stack overflow */ /* Check for stack overflow */
if (IfCount >= MAX_IFS) { if (IfCount >= MAX_IFS) {
Fatal (FAT_IF_NESTING); Fatal ("Too many nested .IFs");
} }
/* Alloc one element */ /* Alloc one element */
@@ -126,7 +126,7 @@ static void FreeIf (void)
do { do {
IfDesc* D = GetCurrentIf(); IfDesc* D = GetCurrentIf();
if (D == 0) { if (D == 0) {
Error (ERR_UNEXPECTED, ".ENDIF"); Error (" Unexpected .ENDIF");
Done = 1; Done = 1;
} else { } else {
Done = (D->Flags & ifNeedTerm) != 0; Done = (D->Flags & ifNeedTerm) != 0;
@@ -210,10 +210,10 @@ void DoConditionals (void)
case TOK_ELSE: case TOK_ELSE:
D = GetCurrentIf (); D = GetCurrentIf ();
if (D == 0) { if (D == 0) {
Error (ERR_UNEXPECTED, ".ELSE"); Error ("Unexpected .ELSE");
} else if (GetElse(D)) { } else if (GetElse(D)) {
/* We already had a .ELSE ! */ /* We already had a .ELSE ! */
Error (ERR_DUPLICATE_ELSE); Error ("Duplicate .ELSE");
} else { } else {
/* Allow an .ELSE */ /* Allow an .ELSE */
InvertIfCond (D); InvertIfCond (D);
@@ -228,10 +228,10 @@ void DoConditionals (void)
case TOK_ELSEIF: case TOK_ELSEIF:
D = GetCurrentIf (); D = GetCurrentIf ();
if (D == 0) { if (D == 0) {
Error (ERR_UNEXPECTED, ".ELSEIF"); Error ("Unexpected .ELSEIF");
} else if (GetElse(D)) { } else if (GetElse(D)) {
/* We already had a .ELSE */ /* We already had a .ELSE */
Error (ERR_DUPLICATE_ELSE); Error ("Duplicate .ELSE");
} else { } else {
/* Handle as if there was an .ELSE first */ /* Handle as if there was an .ELSE first */
InvertIfCond (D); InvertIfCond (D);
@@ -434,7 +434,7 @@ void CheckOpenIfs (void)
} }
/* Start of .if is in the file we're about to leave */ /* Start of .if is in the file we're about to leave */
PError (&D->Pos, ERR_OPEN_IF); PError (&D->Pos, "Conditional assembly branch was never closed");
FreeIf (); FreeIf ();
} }
} }

View File

@@ -6,9 +6,9 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 2000-2001 Ullrich von Bassewitz */ /* (C) 2000-2003 Ullrich von Bassewitz */
/* Wacholderweg 14 */ /* R<EFBFBD>merstra<EFBFBD>e 52 */
/* D-70597 Stuttgart */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
/* */ /* */
/* */ /* */
@@ -63,7 +63,7 @@ void DbgInfoFile (void)
/* Name */ /* Name */
if (Tok != TOK_STRCON) { if (Tok != TOK_STRCON) {
ErrorSkip (ERR_STRCON_EXPECTED); ErrorSkip ("String constant expected");
return; return;
} }
strcpy (Name, SVal); strcpy (Name, SVal);
@@ -106,7 +106,7 @@ void DbgInfoLine (void)
/* The name of the file follows */ /* The name of the file follows */
if (Tok != TOK_STRCON) { if (Tok != TOK_STRCON) {
ErrorSkip (ERR_STRCON_EXPECTED); ErrorSkip ("String constant expected");
return; return;
} }
@@ -122,7 +122,7 @@ void DbgInfoLine (void)
/* Line number */ /* Line number */
LineNum = ConstExpression (); LineNum = ConstExpression ();
if (LineNum < 0) { if (LineNum < 0) {
ErrorSkip (ERR_RANGE); ErrorSkip ("Line number is out of valid range");
return; return;
} }
@@ -135,7 +135,7 @@ void DbgInfoLine (void)
void DbgInfoSym (void) void DbgInfoSym (void)
/* Parse and handle SYM subcommand of the .dbg pseudo instruction */ /* Parse and handle SYM subcommand of the .dbg pseudo instruction */
{ {
ErrorSkip (ERR_NOT_IMPLEMENTED); ErrorSkip ("Not implemented");
} }

View File

@@ -7,7 +7,7 @@
/* */ /* */
/* */ /* */
/* (C) 1998-2003 Ullrich von Bassewitz */ /* (C) 1998-2003 Ullrich von Bassewitz */
/* R<>merstrasse 52 */ /* R<>merstra<EFBFBD>e 52 */
/* D-70794 Filderstadt */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
/* */ /* */
@@ -102,11 +102,11 @@ void GetEA (EffAddr* A)
/* [dir] or [dir],y */ /* [dir] or [dir],y */
NextTok (); NextTok ();
A->Expr = Expression (); A->Expr = Expression ();
Consume (TOK_RBRACK, ERR_RBRACK_EXPECTED); Consume (TOK_RBRACK, "']' expected");
if (Tok == TOK_COMMA) { if (Tok == TOK_COMMA) {
/* [dir],y */ /* [dir],y */
NextTok (); NextTok ();
Consume (TOK_Y, ERR_Y_EXPECTED); Consume (TOK_Y, "`Y' expected");
A->AddrModeSet = AM_DIR_IND_LONG_Y; A->AddrModeSet = AM_DIR_IND_LONG_Y;
} else { } else {
/* [dir] */ /* [dir] */
@@ -134,9 +134,9 @@ void GetEA (EffAddr* A)
A->AddrModeSet = AM_STACK_REL_IND_Y; A->AddrModeSet = AM_STACK_REL_IND_Y;
ConsumeRParen (); ConsumeRParen ();
ConsumeComma (); ConsumeComma ();
Consume (TOK_Y, ERR_Y_EXPECTED); Consume (TOK_Y, "`Y' expected");
} else { } else {
Error (ERR_SYNTAX); Error ("Syntax error");
} }
} else { } else {
@@ -146,7 +146,7 @@ void GetEA (EffAddr* A)
if (Tok == TOK_COMMA) { if (Tok == TOK_COMMA) {
/* (adr),y */ /* (adr),y */
NextTok (); NextTok ();
Consume (TOK_Y, ERR_Y_EXPECTED); Consume (TOK_Y, "`Y' expected");
A->AddrModeSet = AM_DIR_IND_Y; A->AddrModeSet = AM_DIR_IND_Y;
} else { } else {
/* (adr) */ /* (adr) */
@@ -176,7 +176,7 @@ void GetEA (EffAddr* A)
if (Tok == TOK_COMMA) { if (Tok == TOK_COMMA) {
/* bank.adr,x */ /* bank.adr,x */
NextTok (); NextTok ();
Consume (TOK_X, ERR_X_EXPECTED); Consume (TOK_X, "`X' expected");
A->AddrModeSet = AM_ABS_LONG_X; A->AddrModeSet = AM_ABS_LONG_X;
} else { } else {
/* bank.adr */ /* bank.adr */
@@ -206,7 +206,7 @@ void GetEA (EffAddr* A)
break; break;
default: default:
Error (ERR_SYNTAX); Error ("Syntax error");
} }

View File

@@ -7,7 +7,7 @@
/* */ /* */
/* */ /* */
/* (C) 1998-2003 Ullrich von Bassewitz */ /* (C) 1998-2003 Ullrich von Bassewitz */
/* R<>merstrasse 52 */ /* R<>merstra<EFBFBD>e 52 */
/* D-70794 Filderstadt */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
/* */ /* */
@@ -65,26 +65,13 @@ unsigned WarningCount = 0;
void WarningMsg (const FilePos* Pos, unsigned WarnNum, va_list ap) void WarningMsg (const FilePos* Pos, unsigned Level, const char* Format, va_list ap)
/* Print warning message. */ /* Print warning message. */
{ {
static const struct { if (Level <= WarnLevel) {
unsigned char Level; fprintf (stderr, "%s(%lu): Warning: ",
const char* Msg; GetFileName (Pos->Name), Pos->Line);
} Warnings [WARN_COUNT-1] = { vfprintf (stderr, Format, ap);
{ 2, "Symbol `%s' is defined but never used" },
{ 2, "Symbol `%s' is imported but never used" },
{ 1, "Cannot track processor status byte" },
{ 1, "Suspicious address expression" },
{ 0, "Unnamed .PROCs are deprecated, please use .SCOPE" },
{ 1, "Address size mismatch for symbol `%s'" },
{ 0, "User warning: %s" },
};
if (Warnings [WarnNum-1].Level <= WarnLevel) {
fprintf (stderr, "%s(%lu): Warning #%u: ",
GetFileName (Pos->Name), Pos->Line, WarnNum);
vfprintf (stderr, Warnings [WarnNum-1].Msg, ap);
fprintf (stderr, "\n"); fprintf (stderr, "\n");
++WarningCount; ++WarningCount;
} }
@@ -92,23 +79,23 @@ void WarningMsg (const FilePos* Pos, unsigned WarnNum, va_list ap)
void Warning (unsigned WarnNum, ...) void Warning (unsigned Level, const char* Format, ...)
/* Print warning message. */ /* Print warning message. */
{ {
va_list ap; va_list ap;
va_start (ap, WarnNum); va_start (ap, Format);
WarningMsg (&CurPos, WarnNum, ap); WarningMsg (&CurPos, Level, Format, ap);
va_end (ap); va_end (ap);
} }
void PWarning (const FilePos* Pos, unsigned WarnNum, ...) void PWarning (const FilePos* Pos, unsigned Level, const char* Format, ...)
/* Print warning message giving an explicit file and position. */ /* Print warning message giving an explicit file and position. */
{ {
va_list ap; va_list ap;
va_start (ap, WarnNum); va_start (ap, Format);
WarningMsg (Pos, WarnNum, ap); WarningMsg (Pos, Level, Format, ap);
va_end (ap); va_end (ap);
} }
@@ -120,122 +107,46 @@ void PWarning (const FilePos* Pos, unsigned WarnNum, ...)
void ErrorMsg (const FilePos* Pos, unsigned ErrNum, va_list ap) void ErrorMsg (const FilePos* Pos, const char* Format, va_list ap)
/* Print an error message */ /* Print an error message */
{ {
static const char* Msgs [ERR_COUNT-1] = { fprintf (stderr, "%s(%lu): Error: ",
"Command/operation not implemented", GetFileName (Pos->Name), Pos->Line);
"Cannot open include file `%s': %s", vfprintf (stderr, Format, ap);
"Cannot read from include file `%s': %s",
"Include nesting too deep",
"Invalid input character: %02X",
"Hex digit expected",
"Digit expected",
"`0' or `1' expected",
"Numerical overflow",
"Control statement expected",
"Too many characters",
"`:' expected",
"`(' expected",
"`)' expected",
"`]' expected",
"`,' expected",
"Boolean switch value expected (on/off/+/-)",
"`Y' expected",
"`X' expected",
"Integer constant expected",
"String constant expected",
"Character constant expected",
"Constant expression expected",
"Identifier expected",
"`.ENDMACRO' expected",
"Option key expected",
"`=' expected",
"Address size specifier expected",
"Command is only valid in 65816 mode",
"User error: %s",
"String constant too long",
"Newline in string constant",
"Illegal character constant",
"Illegal addressing mode",
"Illegal character to start local symbols",
"Illegal use of local symbol",
"Illegal segment name: `%s'",
"Illegal macro package name",
"Illegal emulation feature",
"Illegal scope specifier",
"Illegal assert action",
"Syntax error",
"Symbol `%s' is already defined",
"Undefined symbol `%s'",
"Symbol `%s' is already marked as import",
"Symbol `%s' is already marked as export",
"Exported symbol `%s' is undefined",
"Exported values must be constant",
"Unexpected end of file",
"Unexpected end of line",
"Unexpected `%s'",
"Division by zero",
"Modulo operation with zero",
"Range error",
"Too many macro parameters",
"Macro parameter expected",
"Circular reference in symbol definition",
"Symbol `%s' redeclaration mismatch",
"Address size mismatch for symbol `%s'",
"Alignment value must be a power of 2",
"Duplicate `.ELSE'",
"Conditional assembly branch was never closed",
"Lexical level was not terminated correctly",
"No open lexical level",
"Segment attribute mismatch",
"Segment stack overflow",
"Segment stack is empty",
"Segment stack is not empty at end of assembly",
"CPU not supported",
"Counter underflow",
"Undefined label",
"Open `%s'",
"File name `%s' not found in file table",
};
fprintf (stderr, "%s(%lu): Error #%u: ",
GetFileName (Pos->Name), Pos->Line, ErrNum);
vfprintf (stderr, Msgs [ErrNum-1], ap);
fprintf (stderr, "\n"); fprintf (stderr, "\n");
++ErrorCount; ++ErrorCount;
} }
void Error (unsigned ErrNum, ...) void Error (const char* Format, ...)
/* Print an error message */ /* Print an error message */
{ {
va_list ap; va_list ap;
va_start (ap, ErrNum); va_start (ap, Format);
ErrorMsg (&CurPos, ErrNum, ap); ErrorMsg (&CurPos, Format, ap);
va_end (ap); va_end (ap);
} }
void PError (const FilePos* Pos, unsigned ErrNum, ...) void PError (const FilePos* Pos, const char* Format, ...)
/* Print an error message giving an explicit file and position. */ /* Print an error message giving an explicit file and position. */
{ {
va_list ap; va_list ap;
va_start (ap, ErrNum); va_start (ap, Format);
ErrorMsg (Pos, ErrNum, ap); ErrorMsg (Pos, Format, ap);
va_end (ap); va_end (ap);
} }
void ErrorSkip (unsigned ErrNum, ...) void ErrorSkip (const char* Format, ...)
/* Print an error message and skip the rest of the line */ /* Print an error message and skip the rest of the line */
{ {
va_list ap; va_list ap;
va_start (ap, ErrNum); va_start (ap, Format);
ErrorMsg (&CurPos, ErrNum, ap); ErrorMsg (&CurPos, Format, ap);
va_end (ap); va_end (ap);
SkipUntilSep (); SkipUntilSep ();
@@ -249,30 +160,14 @@ void ErrorSkip (unsigned ErrNum, ...)
void Fatal (unsigned FatNum, ...) void Fatal (const char* Format, ...)
/* Print a message about a fatal error and die */ /* Print a message about a fatal error and die */
{ {
static const char* Msgs [FAT_COUNT-1] = {
"Maximum number of input files reached",
"Out of memory",
"Too many segments",
"String too long",
"Cannot open input file `%s': %s",
"Cannot stat input file `%s': %s",
"Cannot open output file `%s': %s",
"Cannot write to output file `%s': %s",
"Cannot open listing file: %s",
"Cannot write to listing file: %s",
"Cannot read from listing file: %s",
"Too many nested constructs",
".IF nesting too deep",
"Too many symbols",
};
va_list ap; va_list ap;
va_start (ap, FatNum); va_start (ap, Format);
fprintf (stderr, "Fatal #%u: ", FatNum); fprintf (stderr, "Fatal error: ");
vfprintf (stderr, Msgs [FatNum-1], ap); vfprintf (stderr, Format, ap);
fprintf (stderr, "\n"); fprintf (stderr, "\n");
va_end (ap); va_end (ap);

View File

@@ -50,120 +50,6 @@
/* Warning numbers */
enum Warnings {
WARN_NONE, /* No warning */
WARN_SYM_NOT_REFERENCED,
WARN_IMPORT_NOT_REFERENCED,
WARN_CANNOT_TRACK_STATUS,
WARN_SUSPICIOUS_ADDREXPR,
WARN_UNNAMED_PROC,
WARN_ADDR_SIZE_MISMATCH,
WARN_USER,
WARN_COUNT /* Warning count */
};
/* Error numbers */
enum Errors {
ERR_NONE, /* No error */
ERR_NOT_IMPLEMENTED, /* Command/operation not implemented */
ERR_CANNOT_OPEN_INCLUDE,
ERR_CANNOT_READ_INCLUDE,
ERR_INCLUDE_NESTING,
ERR_INVALID_CHAR,
ERR_HEX_DIGIT_EXPECTED,
ERR_DIGIT_EXPECTED,
ERR_01_EXPECTED,
ERR_NUM_OVERFLOW,
ERR_PSEUDO_EXPECTED,
ERR_TOO_MANY_CHARS,
ERR_COLON_EXPECTED,
ERR_LPAREN_EXPECTED,
ERR_RPAREN_EXPECTED,
ERR_RBRACK_EXPECTED,
ERR_COMMA_EXPECTED,
ERR_ONOFF_EXPECTED,
ERR_Y_EXPECTED,
ERR_X_EXPECTED,
ERR_INTCON_EXPECTED,
ERR_STRCON_EXPECTED,
ERR_CHARCON_EXPECTED,
ERR_CONSTEXPR_EXPECTED,
ERR_IDENT_EXPECTED,
ERR_ENDMACRO_EXPECTED,
ERR_OPTION_KEY_EXPECTED,
ERR_EQ_EXPECTED,
ERR_ADDR_SIZE_EXPECTED,
ERR_816_MODE_ONLY,
ERR_USER,
ERR_STRING_TOO_LONG,
ERR_NEWLINE_IN_STRING,
ERR_ILLEGAL_CHARCON,
ERR_ILLEGAL_ADDR_MODE,
ERR_ILLEGAL_LOCALSTART,
ERR_ILLEGAL_LOCAL_USE,
ERR_ILLEGAL_SEGMENT,
ERR_ILLEGAL_MACPACK,
ERR_ILLEGAL_FEATURE,
ERR_ILLEGAL_SCOPE,
ERR_ILLEGAL_ASSERT_ACTION,
ERR_SYNTAX,
ERR_SYM_ALREADY_DEFINED,
ERR_SYM_UNDEFINED,
ERR_SYM_ALREADY_IMPORT,
ERR_SYM_ALREADY_EXPORT,
ERR_EXPORT_UNDEFINED,
ERR_EXPORT_MUST_BE_CONST,
ERR_UNEXPECTED_EOF,
ERR_UNEXPECTED_EOL,
ERR_UNEXPECTED,
ERR_DIV_BY_ZERO,
ERR_MOD_BY_ZERO,
ERR_RANGE,
ERR_TOO_MANY_PARAMS,
ERR_MACRO_PARAM_EXPECTED,
ERR_CIRCULAR_REFERENCE,
ERR_SYM_REDECL_MISMATCH,
ERR_ADDR_SIZE_MISMATCH,
ERR_ALIGN,
ERR_DUPLICATE_ELSE,
ERR_OPEN_IF,
ERR_OPEN_PROC,
ERR_NO_OPEN_PROC,
ERR_SEG_ATTR_MISMATCH,
ERR_SEGSTACK_OVERFLOW,
ERR_SEGSTACK_EMPTY,
ERR_SEGSTACK_NOT_EMPTY,
ERR_CPU_NOT_SUPPORTED,
ERR_COUNTER_UNDERFLOW,
ERR_UNDEFINED_LABEL,
ERR_OPEN_STMT,
ERR_FILENAME_NOT_FOUND,
ERR_COUNT /* Error count */
};
/* Fatal errors */
enum Fatals {
FAT_NONE,
FAT_MAX_INPUT_FILES,
FAT_OUT_OF_MEMORY,
FAT_TOO_MANY_SEGMENTS,
FAT_STRING_TOO_LONG,
FAT_CANNOT_OPEN_INPUT,
FAT_CANNOT_STAT_INPUT,
FAT_CANNOT_OPEN_OUTPUT,
FAT_CANNOT_WRITE_OUTPUT,
FAT_CANNOT_OPEN_LISTING,
FAT_CANNOT_WRITE_LISTING,
FAT_CANNOT_READ_LISTING,
FAT_NESTING,
FAT_IF_NESTING,
FAT_TOO_MANY_SYMBOLS,
FAT_COUNT /* Fatal error count */
};
/* Warning levels */ /* Warning levels */
extern unsigned WarnLevel; extern unsigned WarnLevel;
@@ -179,22 +65,22 @@ extern unsigned WarningCount;
void Warning (unsigned WarnNum, ...); void Warning (unsigned Level, const char* Format, ...) attribute ((format (printf, 2, 3)));
/* Print warning message. */ /* Print warning message. */
void PWarning (const FilePos* Pos, unsigned WarnNum, ...); void PWarning (const FilePos* Pos, unsigned Level, const char* Format, ...) attribute ((format (printf, 3, 4)));
/* Print warning message giving an explicit file and position. */ /* Print warning message giving an explicit file and position. */
void Error (unsigned ErrNum, ...); void Error (const char* Format, ...) attribute ((format (printf, 1, 2)));
/* Print an error message */ /* Print an error message */
void PError (const FilePos* Pos, unsigned ErrNum, ...); void PError (const FilePos* Pos, const char* Format, ...) attribute ((format (printf, 2, 3)));
/* Print an error message giving an explicit file and position. */ /* Print an error message giving an explicit file and position. */
void ErrorSkip (unsigned ErrNum, ...); void ErrorSkip (const char* Format, ...) attribute ((format (printf, 1, 2)));
/* Print an error message and skip the rest of the line */ /* Print an error message and skip the rest of the line */
void Fatal (unsigned FatNum, ...) attribute ((noreturn)); void Fatal (const char* Format, ...) attribute((noreturn, format(printf,1,2)));
/* Print a message about a fatal error and die */ /* Print a message about a fatal error and die */
void Internal (const char* Format, ...) attribute((noreturn, format(printf,1,2))); void Internal (const char* Format, ...) attribute((noreturn, format(printf,1,2)));

View File

@@ -233,7 +233,7 @@ static int DoMatch (enum TC EqualityLevel)
/* We may not end-of-line of end-of-file here */ /* We may not end-of-line of end-of-file here */
if (TokIsSep (Tok)) { if (TokIsSep (Tok)) {
Error (ERR_UNEXPECTED_EOL); Error ("Unexpected end of line");
return 0; return 0;
} }
@@ -264,7 +264,7 @@ static int DoMatch (enum TC EqualityLevel)
/* We may not end-of-line of end-of-file here */ /* We may not end-of-line of end-of-file here */
if (TokIsSep (Tok)) { if (TokIsSep (Tok)) {
Error (ERR_UNEXPECTED_EOL); Error ("Unexpected end of line");
return 0; return 0;
} }
@@ -334,7 +334,7 @@ static int FuncStrAt (void)
/* String constant expected */ /* String constant expected */
if (Tok != TOK_STRCON) { if (Tok != TOK_STRCON) {
Error (ERR_STRCON_EXPECTED); Error ("String constant expected");
NextTok (); NextTok ();
return 0; return 0;
@@ -352,7 +352,7 @@ static int FuncStrAt (void)
/* Must be a valid index */ /* Must be a valid index */
if (Index >= (long) strlen (Str)) { if (Index >= (long) strlen (Str)) {
Error (ERR_RANGE); Error ("Range error");
return 0; return 0;
} }
@@ -370,7 +370,7 @@ static int FuncStrLen (void)
/* String constant expected */ /* String constant expected */
if (Tok != TOK_STRCON) { if (Tok != TOK_STRCON) {
Error (ERR_STRCON_EXPECTED); Error ("String constant expected");
/* Smart error recovery */ /* Smart error recovery */
if (Tok != TOK_RPAREN) { if (Tok != TOK_RPAREN) {
NextTok (); NextTok ();
@@ -449,7 +449,7 @@ static ExprNode* Function (int (*F) (void))
/* Expression must be enclosed in braces */ /* Expression must be enclosed in braces */
if (Tok != TOK_LPAREN) { if (Tok != TOK_LPAREN) {
Error (ERR_LPAREN_EXPECTED); Error ("'(' expected");
SkipUntilSep (); SkipUntilSep ();
return GenLiteralExpr (0); return GenLiteralExpr (0);
} }
@@ -598,7 +598,7 @@ static ExprNode* Factor (void)
N = GenLiteralExpr (TgtTranslateChar (SVal[0])); N = GenLiteralExpr (TgtTranslateChar (SVal[0]));
} else { } else {
N = GenLiteralExpr (0); /* Dummy */ N = GenLiteralExpr (0); /* Dummy */
Error (ERR_SYNTAX); Error ("Syntax error");
} }
NextTok (); NextTok ();
break; break;
@@ -855,7 +855,7 @@ long ConstExpression (void)
if (IsConstExpr (Expr)) { if (IsConstExpr (Expr)) {
Val = GetExprVal (Expr); Val = GetExprVal (Expr);
} else { } else {
Error (ERR_CONSTEXPR_EXPECTED); Error ("Constant expression expected");
Val = 0; Val = 0;
} }
@@ -1040,7 +1040,7 @@ int IsConstExpr (ExprNode* Root)
if (Verbosity > 0) { if (Verbosity > 0) {
DumpExpr (Root); DumpExpr (Root);
} }
PError (GetSymPos (Sym), ERR_CIRCULAR_REFERENCE); PError (GetSymPos (Sym), "Circular reference in symbol definition");
Const = 0; Const = 0;
} else { } else {
SymMarkUser (Sym); SymMarkUser (Sym);
@@ -1200,7 +1200,7 @@ long GetExprVal (ExprNode* Expr)
Left = GetExprVal (Expr->Left); Left = GetExprVal (Expr->Left);
Right = GetExprVal (Expr->Right); Right = GetExprVal (Expr->Right);
if (Right == 0) { if (Right == 0) {
Error (ERR_DIV_BY_ZERO); Error ("Division by zero");
return 0; return 0;
} }
return Left / Right; return Left / Right;
@@ -1209,7 +1209,7 @@ long GetExprVal (ExprNode* Expr)
Left = GetExprVal (Expr->Left); Left = GetExprVal (Expr->Left);
Right = GetExprVal (Expr->Right); Right = GetExprVal (Expr->Right);
if (Right == 0) { if (Right == 0) {
Error (ERR_MOD_BY_ZERO); Error ("Modulo operation with zero");
return 0; return 0;
} }
return Left % Right; return Left % Right;
@@ -1315,7 +1315,7 @@ static ExprNode* RemoveSyms (ExprNode* Expr, int MustClone)
if (Verbosity) { if (Verbosity) {
DumpExpr (Expr); DumpExpr (Expr);
} }
PError (GetSymPos (Sym), ERR_CIRCULAR_REFERENCE); PError (GetSymPos (Sym), "Circular reference in symbol definition");
return GenLiteralExpr (0); /* Return a dummy value */ return GenLiteralExpr (0); /* Return a dummy value */
} }
SymMarkUser (Sym); SymMarkUser (Sym);

View File

@@ -215,7 +215,7 @@ unsigned GetFileIndex (const char* Name)
/* If we don't have this index, print a diagnostic and use the main file */ /* If we don't have this index, print a diagnostic and use the main file */
if (F == 0) { if (F == 0) {
Error (ERR_FILENAME_NOT_FOUND, Name); Error ("File name `%s' not found in file table", Name);
return 0; return 0;
} else { } else {
return F->Index; return F->Index;

View File

@@ -7,7 +7,7 @@
/* */ /* */
/* */ /* */
/* (C) 1998-2003 Ullrich von Bassewitz */ /* (C) 1998-2003 Ullrich von Bassewitz */
/* R<>merstrasse 52 */ /* R<>merstra<EFBFBD>e 52 */
/* D-70794 Filderstadt */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
/* */ /* */
@@ -578,7 +578,7 @@ static int EvalEA (const InsDesc* Ins, EffAddr* A)
/* Check if we have any adressing modes left */ /* Check if we have any adressing modes left */
if (A->AddrModeSet == 0) { if (A->AddrModeSet == 0) {
Error (ERR_ILLEGAL_ADDR_MODE); Error ("Illegal addressing mode");
return 0; return 0;
} }
A->AddrMode = BitFind (A->AddrModeSet); A->AddrMode = BitFind (A->AddrModeSet);
@@ -601,7 +601,7 @@ static int EvalEA (const InsDesc* Ins, EffAddr* A)
!SymIsZP (Left->V.Sym)) { !SymIsZP (Left->V.Sym)) {
/* Output a warning */ /* Output a warning */
Warning (WARN_SUSPICIOUS_ADDREXPR); Warning (1, "Suspicious address expression");
} }
} }
@@ -744,7 +744,7 @@ static void PutREP (const InsDesc* Ins)
/* Check the range for Val. */ /* Check the range for Val. */
if (Val < 0) { if (Val < 0) {
/* We had an error */ /* We had an error */
Warning (WARN_CANNOT_TRACK_STATUS); Warning (1, "Cannot track processor status byte");
} else { } else {
if (Val & 0x10) { if (Val & 0x10) {
/* Index registers to 16 bit */ /* Index registers to 16 bit */
@@ -772,7 +772,7 @@ static void PutSEP (const InsDesc* Ins)
/* Check the range for Val. */ /* Check the range for Val. */
if (Val < 0) { if (Val < 0) {
/* We had an error */ /* We had an error */
Warning (WARN_CANNOT_TRACK_STATUS); Warning (1, "Cannot track processor status byte");
} else { } else {
if (Val & 0x10) { if (Val & 0x10) {
/* Index registers to 8 bit */ /* Index registers to 8 bit */
@@ -862,7 +862,7 @@ void SetCPU (cpu_t NewCPU)
CPU = NewCPU; CPU = NewCPU;
InsTab = InsTabs[CPU]; InsTab = InsTabs[CPU];
} else { } else {
Error (ERR_CPU_NOT_SUPPORTED); Error ("CPU not supported");
} }
} }

View File

@@ -6,10 +6,10 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 2000 Ullrich von Bassewitz */ /* (C) 2000-2003 Ullrich von Bassewitz */
/* Wacholderweg 14 */ /* R<>merstra<72>e 52 */
/* D-70597 Stuttgart */ /* D-70794 Filderstadt */
/* EMail: uz@musoftware.de */ /* EMail: uz@cc65.org */
/* */ /* */
/* */ /* */
/* This software is provided 'as-is', without any expressed or implied */ /* This software is provided 'as-is', without any expressed or implied */
@@ -80,7 +80,7 @@ void PushInput (int (*Func) (void*), void* Data, const char* Desc)
/* Check for a stack overflow */ /* Check for a stack overflow */
if (ICount > ISTACK_MAX) { if (ICount > ISTACK_MAX) {
Fatal (FAT_NESTING); Fatal ("Maximum input stack nesting exceeded");
} }
/* Create a new stack element */ /* Create a new stack element */
@@ -153,7 +153,7 @@ void CheckInputStack (void)
*/ */
{ {
if (IStack) { if (IStack) {
Error (ERR_OPEN_STMT, IStack->Desc); Error ("Open %s", IStack->Desc);
} }
} }

View File

@@ -7,7 +7,7 @@
/* */ /* */
/* */ /* */
/* (C) 2000-2003 Ullrich von Bassewitz */ /* (C) 2000-2003 Ullrich von Bassewitz */
/* R<>merstrasse 52 */ /* R<>merstra<EFBFBD>e 52 */
/* D-70794 Filderstadt */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
/* */ /* */
@@ -146,7 +146,7 @@ void DisableListing (void)
if (Listing) { if (Listing) {
if (ListingEnabled == 0) { if (ListingEnabled == 0) {
/* Cannot switch the listing off once more */ /* Cannot switch the listing off once more */
Error (ERR_COUNTER_UNDERFLOW); Error ("Counter underflow");
} else { } else {
--ListingEnabled; --ListingEnabled;
} }
@@ -306,7 +306,7 @@ void CreateListing (void)
/* Open the real listing file */ /* Open the real listing file */
F = fopen (ListFile, "w"); F = fopen (ListFile, "w");
if (F == 0) { if (F == 0) {
Fatal (FAT_CANNOT_OPEN_LISTING, strerror (errno)); Fatal ("Cannot open listing file: %s", strerror (errno));
} }
/* Reset variables, print the header for the first page */ /* Reset variables, print the header for the first page */

View File

@@ -7,7 +7,7 @@
/* */ /* */
/* */ /* */
/* (C) 1998-2003 Ullrich von Bassewitz */ /* (C) 1998-2003 Ullrich von Bassewitz */
/* R<>merstrasse 52 */ /* R<>merstra<EFBFBD>e 52 */
/* D-70794 Filderstadt */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
/* */ /* */
@@ -311,7 +311,7 @@ static void MacSkipDef (unsigned Style)
if (Tok != TOK_EOF) { if (Tok != TOK_EOF) {
SkipUntilSep (); SkipUntilSep ();
} else { } else {
Error (ERR_ENDMACRO_EXPECTED); Error ("`.ENDMACRO' expected");
} }
} else { } else {
/* Skip until end of line */ /* Skip until end of line */
@@ -330,7 +330,7 @@ void MacDef (unsigned Style)
/* We expect a macro name here */ /* We expect a macro name here */
if (Tok != TOK_IDENT) { if (Tok != TOK_IDENT) {
Error (ERR_IDENT_EXPECTED); Error ("Identifier expected");
MacSkipDef (Style); MacSkipDef (Style);
return; return;
} }
@@ -338,7 +338,7 @@ void MacDef (unsigned Style)
/* Did we already define that macro? */ /* Did we already define that macro? */
if (HT_Find (&MacroTab, SVal) != 0) { if (HT_Find (&MacroTab, SVal) != 0) {
/* Macro is already defined */ /* Macro is already defined */
Error (ERR_SYM_ALREADY_DEFINED, SVal); Error ("A macro named `%s' is already defined", SVal);
/* Skip tokens until we reach the final .endmacro */ /* Skip tokens until we reach the final .endmacro */
MacSkipDef (Style); MacSkipDef (Style);
return; return;
@@ -380,7 +380,7 @@ void MacDef (unsigned Style)
IdDesc* List = M->Params; IdDesc* List = M->Params;
while (1) { while (1) {
if (strcmp (List->Id, SVal) == 0) { if (strcmp (List->Id, SVal) == 0) {
Error (ERR_SYM_ALREADY_DEFINED, SVal); Error ("Duplicate symbol `%s'", SVal);
} }
if (List->Next == 0) { if (List->Next == 0) {
break; break;
@@ -429,7 +429,7 @@ void MacDef (unsigned Style)
} }
/* May not have end of file in a macro definition */ /* May not have end of file in a macro definition */
if (Tok == TOK_EOF) { if (Tok == TOK_EOF) {
Error (ERR_ENDMACRO_EXPECTED); Error ("`.ENDMACRO' expected");
goto Done; goto Done;
} }
} else { } else {
@@ -451,7 +451,7 @@ void MacDef (unsigned Style)
/* Need an identifer */ /* Need an identifer */
if (Tok != TOK_IDENT) { if (Tok != TOK_IDENT) {
Error (ERR_IDENT_EXPECTED); Error ("Identifier expected");
SkipUntilSep (); SkipUntilSep ();
break; break;
} }
@@ -662,7 +662,7 @@ static void StartExpClassic (Macro* M)
/* Check for maximum parameter count */ /* Check for maximum parameter count */
if (E->ParamCount >= M->ParamCount) { if (E->ParamCount >= M->ParamCount) {
Error (ERR_TOO_MANY_PARAMS); Error ("Too many macro parameters");
SkipUntilSep (); SkipUntilSep ();
break; break;
} }
@@ -675,7 +675,7 @@ static void StartExpClassic (Macro* M)
/* Check for end of file */ /* Check for end of file */
if (Tok == TOK_EOF) { if (Tok == TOK_EOF) {
Error (ERR_UNEXPECTED_EOF); Error ("Unexpected end of file");
return; return;
} }
@@ -732,7 +732,7 @@ static void StartExpDefine (Macro* M)
/* Check if there is really a parameter */ /* Check if there is really a parameter */
if (TokIsSep (Tok) || Tok == TOK_COMMA) { if (TokIsSep (Tok) || Tok == TOK_COMMA) {
Error (ERR_MACRO_PARAM_EXPECTED); Error ("Macro parameter expected");
SkipUntilSep (); SkipUntilSep ();
return; return;
} }
@@ -767,7 +767,7 @@ static void StartExpDefine (Macro* M)
if (Tok == TOK_COMMA) { if (Tok == TOK_COMMA) {
NextTok (); NextTok ();
} else { } else {
Error (ERR_COMMA_EXPECTED); Error ("`,' expected");
} }
} }
} }

View File

@@ -7,7 +7,7 @@
/* */ /* */
/* */ /* */
/* (C) 1998-2003 Ullrich von Bassewitz */ /* (C) 1998-2003 Ullrich von Bassewitz */
/* R<>merstrasse 52 */ /* R<>merstra<EFBFBD>e 52 */
/* D-70794 Filderstadt */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
/* */ /* */
@@ -332,7 +332,7 @@ static void DoPCAssign (void)
{ {
long PC = ConstExpression (); long PC = ConstExpression ();
if (PC < 0 || PC > 0xFFFFFF) { if (PC < 0 || PC > 0xFFFFFF) {
Error (ERR_RANGE); Error ("Range error");
} else { } else {
SetAbsPC (PC); SetAbsPC (PC);
} }
@@ -398,7 +398,7 @@ static void OneLine (void)
*/ */
if (Tok != TOK_COLON) { if (Tok != TOK_COLON) {
if (HadWS || !NoColonLabels) { if (HadWS || !NoColonLabels) {
Error (ERR_COLON_EXPECTED); Error ("`:' expected");
} }
if (Tok == TOK_NAMESPACE) { if (Tok == TOK_NAMESPACE) {
/* Smart :: handling */ /* Smart :: handling */
@@ -426,7 +426,7 @@ static void OneLine (void)
} else if (PCAssignment && (Tok == TOK_STAR || Tok == TOK_PC)) { } else if (PCAssignment && (Tok == TOK_STAR || Tok == TOK_PC)) {
NextTok (); NextTok ();
if (Tok != TOK_EQ) { if (Tok != TOK_EQ) {
Error (ERR_EQ_EXPECTED); Error ("`=' expected");
SkipUntilSep (); SkipUntilSep ();
} else { } else {
/* Skip the equal sign */ /* Skip the equal sign */

View File

@@ -7,9 +7,9 @@
/* */ /* */
/* */ /* */
/* (C) 2000-2003 Ullrich von Bassewitz */ /* (C) 2000-2003 Ullrich von Bassewitz */
/* Wacholderweg 14 */ /* R<EFBFBD>merstra<EFBFBD>e 52 */
/* D-70597 Stuttgart */ /* D-70794 Filderstadt */
/* EMail: uz@musoftware.de */ /* EMail: uz@cc65.org */
/* */ /* */
/* */ /* */
/* This software is provided 'as-is', without any expressed or implied */ /* This software is provided 'as-is', without any expressed or implied */
@@ -80,7 +80,7 @@ static TokList* CollectTokens (unsigned Start, unsigned Count)
/* Check for end of line or end of input */ /* Check for end of line or end of input */
if (TokIsSep (Tok)) { if (TokIsSep (Tok)) {
Error (ERR_UNEXPECTED_EOL); Error ("Unexpected end of line");
return List; return List;
} }
@@ -133,7 +133,7 @@ static void FuncConcat (void)
/* Next token must be a string */ /* Next token must be a string */
if (Tok != TOK_STRCON) { if (Tok != TOK_STRCON) {
Error (ERR_STRCON_EXPECTED); Error ("String constant expected");
SkipUntilSep (); SkipUntilSep ();
return; return;
} }
@@ -141,7 +141,7 @@ static void FuncConcat (void)
/* Get the length of the string const and check total length */ /* Get the length of the string const and check total length */
L = strlen (SVal); L = strlen (SVal);
if (Length + L > MAX_STR_LEN) { if (Length + L > MAX_STR_LEN) {
Error (ERR_STRING_TOO_LONG); Error ("String is too long");
/* Try to recover */ /* Try to recover */
SkipUntilSep (); SkipUntilSep ();
return; return;
@@ -171,7 +171,7 @@ static void FuncConcat (void)
* by the string token just created. * by the string token just created.
*/ */
if (Tok != TOK_RPAREN) { if (Tok != TOK_RPAREN) {
Error (ERR_RPAREN_EXPECTED); Error ("`)' expected");
} else { } else {
Tok = TOK_STRCON; Tok = TOK_STRCON;
strcpy (SVal, Buf); strcpy (SVal, Buf);
@@ -195,7 +195,7 @@ static void FuncLeft (void)
/* Count argument */ /* Count argument */
Count = ConstExpression (); Count = ConstExpression ();
if (Count < 0 || Count > 100) { if (Count < 0 || Count > 100) {
Error (ERR_RANGE); Error ("Range error");
Count = 1; Count = 1;
} }
ConsumeComma (); ConsumeComma ();
@@ -237,7 +237,7 @@ static void FuncMid (void)
/* Start argument */ /* Start argument */
Start = ConstExpression (); Start = ConstExpression ();
if (Start < 0 || Start > 100) { if (Start < 0 || Start > 100) {
Error (ERR_RANGE); Error ("Range error");
Start = 0; Start = 0;
} }
ConsumeComma (); ConsumeComma ();
@@ -245,7 +245,7 @@ static void FuncMid (void)
/* Count argument */ /* Count argument */
Count = ConstExpression (); Count = ConstExpression ();
if (Count < 0 || Count > 100) { if (Count < 0 || Count > 100) {
Error (ERR_RANGE); Error ("Range error");
Count = 1; Count = 1;
} }
ConsumeComma (); ConsumeComma ();
@@ -286,7 +286,7 @@ static void FuncRight (void)
/* Count argument */ /* Count argument */
Count = ConstExpression (); Count = ConstExpression ();
if (Count < 0 || Count > 100) { if (Count < 0 || Count > 100) {
Error (ERR_RANGE); Error ("Range error");
Count = 1; Count = 1;
} }
ConsumeComma (); ConsumeComma ();
@@ -353,7 +353,7 @@ static void FuncString (void)
* by the string token just created. * by the string token just created.
*/ */
if (Tok != TOK_RPAREN) { if (Tok != TOK_RPAREN) {
Error (ERR_RPAREN_EXPECTED); Error ("`)' expected");
} else { } else {
Tok = TOK_STRCON; Tok = TOK_STRCON;
strcpy (SVal, Buf); strcpy (SVal, Buf);
@@ -404,7 +404,7 @@ void NextTok (void)
void Consume (enum Token Expected, unsigned ErrMsg) void Consume (enum Token Expected, const char* ErrMsg)
/* Consume Expected, print an error if we don't find it */ /* Consume Expected, print an error if we don't find it */
{ {
if (Tok == Expected) { if (Tok == Expected) {
@@ -422,7 +422,7 @@ void ConsumeSep (void)
/* Accept an EOF as separator */ /* Accept an EOF as separator */
if (Tok != TOK_EOF) { if (Tok != TOK_EOF) {
if (Tok != TOK_SEP) { if (Tok != TOK_SEP) {
Error (ERR_TOO_MANY_CHARS); Error ("Too many characters");
SkipUntilSep (); SkipUntilSep ();
} else { } else {
NextTok (); NextTok ();
@@ -435,7 +435,7 @@ void ConsumeSep (void)
void ConsumeLParen (void) void ConsumeLParen (void)
/* Consume a left paren */ /* Consume a left paren */
{ {
Consume (TOK_LPAREN, ERR_LPAREN_EXPECTED); Consume (TOK_LPAREN, "`(' expected");
} }
@@ -443,7 +443,7 @@ void ConsumeLParen (void)
void ConsumeRParen (void) void ConsumeRParen (void)
/* Consume a right paren */ /* Consume a right paren */
{ {
Consume (TOK_RPAREN, ERR_RPAREN_EXPECTED); Consume (TOK_RPAREN, "`)' expected");
} }
@@ -451,7 +451,7 @@ void ConsumeRParen (void)
void ConsumeComma (void) void ConsumeComma (void)
/* Consume a comma */ /* Consume a comma */
{ {
Consume (TOK_COMMA, ERR_COMMA_EXPECTED); Consume (TOK_COMMA, "`,' expected");
} }

View File

@@ -6,10 +6,10 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 2000 Ullrich von Bassewitz */ /* (C) 2000-2003 Ullrich von Bassewitz */
/* Wacholderweg 14 */ /* R<>merstra<72>e 52 */
/* D-70597 Stuttgart */ /* D-70794 Filderstadt */
/* EMail: uz@musoftware.de */ /* EMail: uz@cc65.org */
/* */ /* */
/* */ /* */
/* This software is provided 'as-is', without any expressed or implied */ /* This software is provided 'as-is', without any expressed or implied */
@@ -51,7 +51,7 @@
void NextTok (void); void NextTok (void);
/* Get next token and handle token level functions */ /* Get next token and handle token level functions */
void Consume (enum Token Expected, unsigned ErrMsg); void Consume (enum Token Expected, const char* ErrMsg);
/* Consume Token, print an error if we don't find it */ /* Consume Token, print an error if we don't find it */
void ConsumeSep (void); void ConsumeSep (void);

View File

@@ -7,7 +7,7 @@
/* */ /* */
/* */ /* */
/* (C) 1998-2003 Ullrich von Bassewitz */ /* (C) 1998-2003 Ullrich von Bassewitz */
/* R<>merstrasse 52 */ /* R<>merstra<EFBFBD>e 52 */
/* D-70794 Filderstadt */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
/* */ /* */
@@ -150,7 +150,7 @@ void EmitByte (ExprNode* Expr)
long Val = GetExprVal (Expr); long Val = GetExprVal (Expr);
FreeExpr (Expr); FreeExpr (Expr);
if ((Val & ~0xFF) != 0) { if ((Val & ~0xFF) != 0) {
Error (ERR_RANGE); Error ("Range error");
} }
Emit0 (Val & 0xFF); Emit0 (Val & 0xFF);
} else { } else {
@@ -172,7 +172,7 @@ void EmitWord (ExprNode* Expr)
long Val = GetExprVal (Expr); long Val = GetExprVal (Expr);
FreeExpr (Expr); FreeExpr (Expr);
if ((Val & ~0xFFFF) != 0) { if ((Val & ~0xFFFF) != 0) {
Error (ERR_RANGE); Error ("Range error");
} }
Emit0 (Val & 0xFF); Emit0 (Val & 0xFF);
Emit0 ((Val >> 8) & 0xFF); Emit0 ((Val >> 8) & 0xFF);
@@ -195,7 +195,7 @@ void EmitFarAddr (ExprNode* Expr)
long Val = GetExprVal (Expr); long Val = GetExprVal (Expr);
FreeExpr (Expr); FreeExpr (Expr);
if ((Val & ~0xFFFFFF) != 0) { if ((Val & ~0xFFFFFF) != 0) {
Error (ERR_RANGE); Error ("Range error");
} }
Emit0 (Val & 0xFF); Emit0 (Val & 0xFF);
Emit0 ((Val >> 8) & 0xFF); Emit0 ((Val >> 8) & 0xFF);

View File

@@ -7,7 +7,7 @@
/* */ /* */
/* */ /* */
/* (C) 1998-2003 Ullrich von Bassewitz */ /* (C) 1998-2003 Ullrich von Bassewitz */
/* R<>merstrasse 52 */ /* R<>merstra<EFBFBD>e 52 */
/* D-70794 Filderstadt */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
/* */ /* */
@@ -109,7 +109,7 @@ static void ObjWriteError (void)
remove (OutFile); remove (OutFile);
/* Now abort with a fatal error */ /* Now abort with a fatal error */
Fatal (FAT_CANNOT_WRITE_OUTPUT, OutFile, strerror (Error)); Fatal ("Cannot write to output file `%s': %s", OutFile, strerror (Error));
} }
@@ -162,7 +162,7 @@ void ObjOpen (void)
/* Create the output file */ /* Create the output file */
F = fopen (OutFile, "w+b"); F = fopen (OutFile, "w+b");
if (F == 0) { if (F == 0) {
Fatal (FAT_CANNOT_OPEN_OUTPUT, OutFile, strerror (errno)); Fatal ("Cannot open output file `%s': %s", OutFile, strerror (errno));
} }
/* Write a dummy header */ /* Write a dummy header */

View File

@@ -147,15 +147,15 @@ static void SetBoolOption (unsigned char* Flag)
} else if (Tok == TOK_IDENT) { } else if (Tok == TOK_IDENT) {
/* Map the keyword to a number */ /* Map the keyword to a number */
switch (GetSubKey (Keys, sizeof (Keys) / sizeof (Keys [0]))) { switch (GetSubKey (Keys, sizeof (Keys) / sizeof (Keys [0]))) {
case 0: *Flag = 0; NextTok (); break; case 0: *Flag = 0; NextTok (); break;
case 1: *Flag = 1; NextTok (); break; case 1: *Flag = 1; NextTok (); break;
default: ErrorSkip (ERR_ONOFF_EXPECTED); break; default: ErrorSkip ("`on' or `off' expected"); break;
} }
} else if (TokIsSep (Tok)) { } else if (TokIsSep (Tok)) {
/* Without anything assume switch on */ /* Without anything assume switch on */
*Flag = 1; *Flag = 1;
} else { } else {
ErrorSkip (ERR_ONOFF_EXPECTED); ErrorSkip ("`on' or `off' expected");
} }
} }
@@ -172,7 +172,7 @@ static void ExportImport (void (*Func) (SymEntry*, unsigned, unsigned),
/* We need an identifier here */ /* We need an identifier here */
if (Tok != TOK_IDENT) { if (Tok != TOK_IDENT) {
ErrorSkip (ERR_IDENT_EXPECTED); ErrorSkip ("Identifier expected");
return; return;
} }
@@ -213,7 +213,7 @@ static long IntArg (long Min, long Max)
} else { } else {
long Val = ConstExpression (); long Val = ConstExpression ();
if (Val < Min || Val > Max) { if (Val < Min || Val > Max) {
Error (ERR_RANGE); Error ("Range error");
Val = Min; Val = Min;
} }
return Val; return Val;
@@ -234,7 +234,7 @@ static void ConDes (const char* Name, unsigned Type)
Prio = ConstExpression (); Prio = ConstExpression ();
if (Prio < CD_PRIO_MIN || Prio > CD_PRIO_MAX) { if (Prio < CD_PRIO_MIN || Prio > CD_PRIO_MAX) {
/* Value out of range */ /* Value out of range */
Error (ERR_RANGE); Error ("Range error");
return; return;
} }
} else { } else {
@@ -258,7 +258,7 @@ static void DoA16 (void)
/* Switch the accu to 16 bit mode (assembler only) */ /* Switch the accu to 16 bit mode (assembler only) */
{ {
if (GetCPU() != CPU_65816) { if (GetCPU() != CPU_65816) {
Error (ERR_816_MODE_ONLY); Error ("Command is only valid in 65816 mode");
} else { } else {
/* Immidiate mode has two extension bytes */ /* Immidiate mode has two extension bytes */
ExtBytes [AMI_IMM_ACCU] = 2; ExtBytes [AMI_IMM_ACCU] = 2;
@@ -271,7 +271,7 @@ static void DoA8 (void)
/* Switch the accu to 8 bit mode (assembler only) */ /* Switch the accu to 8 bit mode (assembler only) */
{ {
if (GetCPU() != CPU_65816) { if (GetCPU() != CPU_65816) {
Error (ERR_816_MODE_ONLY); Error ("Command is only valid in 65816 mode");
} else { } else {
/* Immidiate mode has one extension byte */ /* Immidiate mode has one extension byte */
ExtBytes [AMI_IMM_ACCU] = 1; ExtBytes [AMI_IMM_ACCU] = 1;
@@ -310,7 +310,7 @@ static void DoAlign (void)
/* Read the alignment value */ /* Read the alignment value */
Align = ConstExpression (); Align = ConstExpression ();
if (Align <= 0 || Align > 0x10000) { if (Align <= 0 || Align > 0x10000) {
ErrorSkip (ERR_RANGE); ErrorSkip ("Range error");
return; return;
} }
@@ -320,7 +320,7 @@ static void DoAlign (void)
Val = ConstExpression (); Val = ConstExpression ();
/* We need a byte value here */ /* We need a byte value here */
if (!IsByteRange (Val)) { if (!IsByteRange (Val)) {
ErrorSkip (ERR_RANGE); ErrorSkip ("Range error");
return; return;
} }
} else { } else {
@@ -330,7 +330,7 @@ static void DoAlign (void)
/* Check if the alignment is a power of two */ /* Check if the alignment is a power of two */
Bit = BitFind (Align); Bit = BitFind (Align);
if (Align != (0x01L << Bit)) { if (Align != (0x01L << Bit)) {
Error (ERR_ALIGN); Error ("Alignment value must be a power of 2");
} else { } else {
SegAlign (Bit, (int) Val); SegAlign (Bit, (int) Val);
} }
@@ -346,7 +346,7 @@ static void DoASCIIZ (void)
while (1) { while (1) {
/* Must have a string constant */ /* Must have a string constant */
if (Tok != TOK_STRCON) { if (Tok != TOK_STRCON) {
ErrorSkip (ERR_STRCON_EXPECTED); ErrorSkip ("String constant expected");
return; return;
} }
@@ -385,7 +385,7 @@ static void DoAssert (void)
/* Action follows */ /* Action follows */
if (Tok != TOK_IDENT) { if (Tok != TOK_IDENT) {
ErrorSkip (ERR_IDENT_EXPECTED); ErrorSkip ("Identifier expected");
return; return;
} }
Action = GetSubKey (ActionTab, sizeof (ActionTab) / sizeof (ActionTab[0])); Action = GetSubKey (ActionTab, sizeof (ActionTab) / sizeof (ActionTab[0]));
@@ -403,14 +403,14 @@ static void DoAssert (void)
break; break;
default: default:
Error (ERR_ILLEGAL_ASSERT_ACTION); Error ("Illegal assert action specifier");
} }
NextTok (); NextTok ();
ConsumeComma (); ConsumeComma ();
/* Read the message */ /* Read the message */
if (Tok != TOK_STRCON) { if (Tok != TOK_STRCON) {
ErrorSkip (ERR_STRCON_EXPECTED); ErrorSkip ("String constant expected");
} else { } else {
AddAssertion (Expr, Action, GetStringId (SVal)); AddAssertion (Expr, Action, GetStringId (SVal));
NextTok (); NextTok ();
@@ -454,7 +454,7 @@ static void DoByte (void)
NextTok (); NextTok ();
/* Do smart handling of dangling comma */ /* Do smart handling of dangling comma */
if (Tok == TOK_SEP) { if (Tok == TOK_SEP) {
Error (ERR_UNEXPECTED_EOL); Error ("Unexpected end of line");
break; break;
} }
} }
@@ -482,7 +482,7 @@ static void DoCharMap (void)
Index = ConstExpression (); Index = ConstExpression ();
if (Index < 1 || Index > 255) { if (Index < 1 || Index > 255) {
/* Value out of range */ /* Value out of range */
ErrorSkip (ERR_RANGE); ErrorSkip ("Range error");
return; return;
} }
@@ -493,7 +493,7 @@ static void DoCharMap (void)
Code = ConstExpression (); Code = ConstExpression ();
if (Code < 1 || Code > 255) { if (Code < 1 || Code > 255) {
/* Value out of range */ /* Value out of range */
ErrorSkip (ERR_RANGE); ErrorSkip ("Range error");
return; return;
} }
@@ -523,7 +523,7 @@ static void DoConDes (void)
/* Symbol name follows */ /* Symbol name follows */
if (Tok != TOK_IDENT) { if (Tok != TOK_IDENT) {
ErrorSkip (ERR_IDENT_EXPECTED); ErrorSkip ("Identifier expected");
return; return;
} }
strcpy (Name, SVal); strcpy (Name, SVal);
@@ -539,7 +539,7 @@ static void DoConDes (void)
/* Check if we got a valid keyword */ /* Check if we got a valid keyword */
if (Type < 0) { if (Type < 0) {
Error (ERR_SYNTAX); Error ("Syntax error");
SkipUntilSep (); SkipUntilSep ();
return; return;
} }
@@ -550,7 +550,7 @@ static void DoConDes (void)
Type = ConstExpression (); Type = ConstExpression ();
if (Type < CD_TYPE_MIN || Type > CD_TYPE_MAX) { if (Type < CD_TYPE_MIN || Type > CD_TYPE_MAX) {
/* Value out of range */ /* Value out of range */
Error (ERR_RANGE); Error ("Range error");
return; return;
} }
@@ -569,7 +569,7 @@ static void DoConstructor (void)
/* Symbol name follows */ /* Symbol name follows */
if (Tok != TOK_IDENT) { if (Tok != TOK_IDENT) {
ErrorSkip (ERR_IDENT_EXPECTED); ErrorSkip ("Identifier expected");
return; return;
} }
strcpy (Name, SVal); strcpy (Name, SVal);
@@ -602,7 +602,7 @@ static void DoDbg (void)
/* We expect a subkey */ /* We expect a subkey */
if (Tok != TOK_IDENT) { if (Tok != TOK_IDENT) {
ErrorSkip (ERR_IDENT_EXPECTED); ErrorSkip ("Identifier expected");
return; return;
} }
@@ -617,7 +617,7 @@ static void DoDbg (void)
case 0: DbgInfoFile (); break; case 0: DbgInfoFile (); break;
case 1: DbgInfoLine (); break; case 1: DbgInfoLine (); break;
case 2: DbgInfoSym (); break; case 2: DbgInfoSym (); break;
default: ErrorSkip (ERR_SYNTAX); break; default: ErrorSkip ("Syntax error"); break;
} }
} }
@@ -661,7 +661,7 @@ static void DoDestructor (void)
/* Symbol name follows */ /* Symbol name follows */
if (Tok != TOK_IDENT) { if (Tok != TOK_IDENT) {
ErrorSkip (ERR_IDENT_EXPECTED); ErrorSkip ("Identifier expected");
return; return;
} }
strcpy (Name, SVal); strcpy (Name, SVal);
@@ -704,7 +704,7 @@ static void DoEndProc (void)
SymLeaveLevel (); SymLeaveLevel ();
} else { } else {
/* No local scope */ /* No local scope */
ErrorSkip (ERR_NO_OPEN_PROC); ErrorSkip ("No open lexical level");
} }
} }
@@ -714,9 +714,9 @@ static void DoError (void)
/* User error */ /* User error */
{ {
if (Tok != TOK_STRCON) { if (Tok != TOK_STRCON) {
ErrorSkip (ERR_STRCON_EXPECTED); ErrorSkip ("String constant expected");
} else { } else {
Error (ERR_USER, SVal); Error ("User error: %s", SVal);
SkipUntilSep (); SkipUntilSep ();
} }
} }
@@ -775,7 +775,7 @@ static void DoFeature (void)
/* We expect an identifier */ /* We expect an identifier */
if (Tok != TOK_IDENT) { if (Tok != TOK_IDENT) {
ErrorSkip (ERR_IDENT_EXPECTED); ErrorSkip ("Identifier expected");
return; return;
} }
@@ -785,7 +785,7 @@ static void DoFeature (void)
/* Set the feature and check for errors */ /* Set the feature and check for errors */
if (SetFeature (SVal) == FEAT_UNKNOWN) { if (SetFeature (SVal) == FEAT_UNKNOWN) {
/* Not found */ /* Not found */
ErrorSkip (ERR_ILLEGAL_FEATURE); ErrorSkip ("Invalid feature: `%s'", SVal);
return; return;
} else { } else {
/* Skip the keyword */ /* Skip the keyword */
@@ -820,7 +820,7 @@ static void DoFileOpt (void)
OptNum = GetSubKey (Keys, sizeof (Keys) / sizeof (Keys [0])); OptNum = GetSubKey (Keys, sizeof (Keys) / sizeof (Keys [0]));
if (OptNum < 0) { if (OptNum < 0) {
/* Not found */ /* Not found */
ErrorSkip (ERR_OPTION_KEY_EXPECTED); ErrorSkip ("File option keyword expected");
return; return;
} }
@@ -832,7 +832,7 @@ static void DoFileOpt (void)
/* We accept only string options for now */ /* We accept only string options for now */
if (Tok != TOK_STRCON) { if (Tok != TOK_STRCON) {
ErrorSkip (ERR_STRCON_EXPECTED); ErrorSkip ("String constant expected");
return; return;
} }
@@ -867,7 +867,7 @@ static void DoFileOpt (void)
/* Option given as number */ /* Option given as number */
OptNum = ConstExpression (); OptNum = ConstExpression ();
if (!IsByteRange (OptNum)) { if (!IsByteRange (OptNum)) {
ErrorSkip (ERR_RANGE); ErrorSkip ("Range error");
return; return;
} }
@@ -876,7 +876,7 @@ static void DoFileOpt (void)
/* We accept only string options for now */ /* We accept only string options for now */
if (Tok != TOK_STRCON) { if (Tok != TOK_STRCON) {
ErrorSkip (ERR_STRCON_EXPECTED); ErrorSkip ("String constant expected");
return; return;
} }
@@ -918,7 +918,7 @@ static void DoI16 (void)
/* Switch the index registers to 16 bit mode (assembler only) */ /* Switch the index registers to 16 bit mode (assembler only) */
{ {
if (GetCPU() != CPU_65816) { if (GetCPU() != CPU_65816) {
Error (ERR_816_MODE_ONLY); Error ("Command is only valid in 65816 mode");
} else { } else {
/* Immidiate mode has two extension bytes */ /* Immidiate mode has two extension bytes */
ExtBytes [AMI_IMM_INDEX] = 2; ExtBytes [AMI_IMM_INDEX] = 2;
@@ -931,7 +931,7 @@ static void DoI8 (void)
/* Switch the index registers to 16 bit mode (assembler only) */ /* Switch the index registers to 16 bit mode (assembler only) */
{ {
if (GetCPU() != CPU_65816) { if (GetCPU() != CPU_65816) {
Error (ERR_816_MODE_ONLY); Error ("Command is only valid in 65816 mode");
} else { } else {
/* Immidiate mode has one extension byte */ /* Immidiate mode has one extension byte */
ExtBytes [AMI_IMM_INDEX] = 1; ExtBytes [AMI_IMM_INDEX] = 1;
@@ -967,7 +967,7 @@ static void DoIncBin (void)
/* Name must follow */ /* Name must follow */
if (Tok != TOK_STRCON) { if (Tok != TOK_STRCON) {
ErrorSkip (ERR_STRCON_EXPECTED); ErrorSkip ("String constant expected");
return; return;
} }
strcpy (Name, SVal); strcpy (Name, SVal);
@@ -994,7 +994,7 @@ static void DoIncBin (void)
char* PathName = FindInclude (Name); char* PathName = FindInclude (Name);
if (PathName == 0 || (F = fopen (PathName, "r")) == 0) { if (PathName == 0 || (F = fopen (PathName, "r")) == 0) {
/* Not found or cannot open, print an error and bail out */ /* Not found or cannot open, print an error and bail out */
ErrorSkip (ERR_CANNOT_OPEN_INCLUDE, Name, strerror (errno)); ErrorSkip ("Cannot open include file `%s': %s", Name, strerror (errno));
} }
/* Free the allocated memory */ /* Free the allocated memory */
@@ -1015,13 +1015,13 @@ static void DoIncBin (void)
Count = Size - Start; Count = Size - Start;
if (Count < 0) { if (Count < 0) {
/* Nothing to read - flag this as a range error */ /* Nothing to read - flag this as a range error */
ErrorSkip (ERR_RANGE); ErrorSkip ("Range error");
goto Done; goto Done;
} }
} else { } else {
/* Count was given, check if it is valid */ /* Count was given, check if it is valid */
if (Start + Count > Size) { if (Start + Count > Size) {
ErrorSkip (ERR_RANGE); ErrorSkip ("Range error");
goto Done; goto Done;
} }
} }
@@ -1041,7 +1041,8 @@ static void DoIncBin (void)
size_t BytesRead = fread (Buf, 1, BytesToRead, F); size_t BytesRead = fread (Buf, 1, BytesToRead, F);
if (BytesToRead != BytesRead) { if (BytesToRead != BytesRead) {
/* Some sort of error */ /* Some sort of error */
ErrorSkip (ERR_CANNOT_READ_INCLUDE, Name, strerror (errno)); ErrorSkip ("Cannot read from include file `%s': %s",
Name, strerror (errno));
break; break;
} }
@@ -1066,7 +1067,7 @@ static void DoInclude (void)
/* Name must follow */ /* Name must follow */
if (Tok != TOK_STRCON) { if (Tok != TOK_STRCON) {
ErrorSkip (ERR_STRCON_EXPECTED); ErrorSkip ("String constant expected");
} else { } else {
strcpy (Name, SVal); strcpy (Name, SVal);
NextTok (); NextTok ();
@@ -1127,10 +1128,10 @@ static void DoLocalChar (void)
/* Define the character that starts local labels */ /* Define the character that starts local labels */
{ {
if (Tok != TOK_CHARCON) { if (Tok != TOK_CHARCON) {
ErrorSkip (ERR_CHARCON_EXPECTED); ErrorSkip ("Character constant expected");
} else { } else {
if (IVal != '@' && IVal != '?') { if (IVal != '@' && IVal != '?') {
Error (ERR_ILLEGAL_LOCALSTART); Error ("Invalid start character for locals");
} else { } else {
LocalStart = (char) IVal; LocalStart = (char) IVal;
} }
@@ -1155,7 +1156,7 @@ static void DoMacPack (void)
/* We expect an identifier */ /* We expect an identifier */
if (Tok != TOK_IDENT) { if (Tok != TOK_IDENT) {
ErrorSkip (ERR_IDENT_EXPECTED); ErrorSkip ("Identifier expected");
return; return;
} }
@@ -1163,7 +1164,7 @@ static void DoMacPack (void)
Package = GetSubKey (Keys, sizeof (Keys) / sizeof (Keys [0])); Package = GetSubKey (Keys, sizeof (Keys) / sizeof (Keys [0]));
if (Package < 0) { if (Package < 0) {
/* Not found */ /* Not found */
ErrorSkip (ERR_ILLEGAL_MACPACK); ErrorSkip ("Invalid macro package");
return; return;
} }
@@ -1197,7 +1198,7 @@ static void DoOrg (void)
{ {
long PC = ConstExpression (); long PC = ConstExpression ();
if (PC < 0 || PC > 0xFFFFFF) { if (PC < 0 || PC > 0xFFFFFF) {
Error (ERR_RANGE); Error ("Range error");
return; return;
} }
SetAbsPC (PC); SetAbsPC (PC);
@@ -1209,7 +1210,7 @@ static void DoOut (void)
/* Output a string */ /* Output a string */
{ {
if (Tok != TOK_STRCON) { if (Tok != TOK_STRCON) {
ErrorSkip (ERR_STRCON_EXPECTED); ErrorSkip ("String constant expected");
} else { } else {
/* Output the string and be sure to flush the output to keep it in /* Output the string and be sure to flush the output to keep it in
* sync with any error messages if the output is redirected to a file. * sync with any error messages if the output is redirected to a file.
@@ -1261,7 +1262,7 @@ static void DoPopSeg (void)
/* Must have a segment on the stack */ /* Must have a segment on the stack */
if (CollCount (&SegStack) == 0) { if (CollCount (&SegStack) == 0) {
ErrorSkip (ERR_SEGSTACK_EMPTY); ErrorSkip ("Segment stack is empty");
return; return;
} }
@@ -1308,7 +1309,7 @@ static void DoProc (void)
/* A .PROC statement without a name */ /* A .PROC statement without a name */
char Buf[sizeof (SVal)]; char Buf[sizeof (SVal)];
SymEnterLevel (AnonName (Buf, sizeof (Buf), "Scope"), ADDR_SIZE_DEFAULT); SymEnterLevel (AnonName (Buf, sizeof (Buf), "Scope"), ADDR_SIZE_DEFAULT);
Warning (WARN_UNNAMED_PROC); Warning (1, "Unnamed .PROCs are deprecated, please use .SCOPE");
} }
} }
@@ -1328,7 +1329,7 @@ static void DoPushSeg (void)
{ {
/* Can only push a limited size of segments */ /* Can only push a limited size of segments */
if (CollCount (&SegStack) >= MAX_PUSHED_SEGMENTS) { if (CollCount (&SegStack) >= MAX_PUSHED_SEGMENTS) {
ErrorSkip (ERR_SEGSTACK_OVERFLOW); ErrorSkip ("Segment stack overflow");
return; return;
} }
@@ -1362,7 +1363,7 @@ static void DoRes (void)
Count = ConstExpression (); Count = ConstExpression ();
if (Count > 0xFFFF || Count < 0) { if (Count > 0xFFFF || Count < 0) {
ErrorSkip (ERR_RANGE); ErrorSkip ("Range error");
return; return;
} }
if (Tok == TOK_COMMA) { if (Tok == TOK_COMMA) {
@@ -1370,7 +1371,7 @@ static void DoRes (void)
Val = ConstExpression (); Val = ConstExpression ();
/* We need a byte value here */ /* We need a byte value here */
if (!IsByteRange (Val)) { if (!IsByteRange (Val)) {
ErrorSkip (ERR_RANGE); ErrorSkip ("Range error");
return; return;
} }
@@ -1403,7 +1404,7 @@ static void DoSegment (void)
Def.Name = Name; Def.Name = Name;
if (Tok != TOK_STRCON) { if (Tok != TOK_STRCON) {
ErrorSkip (ERR_STRCON_EXPECTED); ErrorSkip ("String constant expected");
} else { } else {
/* Save the name of the segment and skip it */ /* Save the name of the segment and skip it */
@@ -1425,7 +1426,7 @@ static void DoSetCPU (void)
{ {
/* We expect an identifier */ /* We expect an identifier */
if (Tok != TOK_STRCON) { if (Tok != TOK_STRCON) {
ErrorSkip (ERR_STRCON_EXPECTED); ErrorSkip ("String constant expected");
} else { } else {
/* Try to find the CPU, then skip the identifier */ /* Try to find the CPU, then skip the identifier */
cpu_t CPU = FindCPU (SVal); cpu_t CPU = FindCPU (SVal);
@@ -1449,7 +1450,7 @@ static void DoSmart (void)
static void DoStruct (void) static void DoStruct (void)
/* Struct definition */ /* Struct definition */
{ {
Error (ERR_NOT_IMPLEMENTED); Error ("Not implemented");
} }
@@ -1465,7 +1466,7 @@ static void DoSunPlus (void)
static void DoUnion (void) static void DoUnion (void)
/* Union definition */ /* Union definition */
{ {
Error (ERR_NOT_IMPLEMENTED); Error ("Not implemented");
} }
@@ -1473,7 +1474,7 @@ static void DoUnion (void)
static void DoUnexpected (void) static void DoUnexpected (void)
/* Got an unexpected keyword */ /* Got an unexpected keyword */
{ {
Error (ERR_UNEXPECTED, Keyword); Error ("Unexpected `%s'", Keyword);
SkipUntilSep (); SkipUntilSep ();
} }
@@ -1483,9 +1484,9 @@ static void DoWarning (void)
/* User warning */ /* User warning */
{ {
if (Tok != TOK_STRCON) { if (Tok != TOK_STRCON) {
ErrorSkip (ERR_STRCON_EXPECTED); ErrorSkip ("String constant expected");
} else { } else {
Warning (WARN_USER, SVal); Warning (0, "User warning: %s", SVal);
SkipUntilSep (); SkipUntilSep ();
} }
} }
@@ -1697,7 +1698,7 @@ void SegStackCheck (void)
/* Check if the segment stack is empty at end of assembly */ /* Check if the segment stack is empty at end of assembly */
{ {
if (CollCount (&SegStack) != 0) { if (CollCount (&SegStack) != 0) {
Error (ERR_SEGSTACK_NOT_EMPTY); Error ("Segment stack is not empty");
} }
} }

View File

@@ -67,7 +67,7 @@ static TokList* CollectRepeatTokens (void)
/* Check for end of input */ /* Check for end of input */
if (Tok == TOK_EOF) { if (Tok == TOK_EOF) {
Error (ERR_UNEXPECTED_EOF); Error ("Unexpected end of file");
FreeTokList (List); FreeTokList (List);
return 0; return 0;
} }
@@ -127,7 +127,7 @@ void ParseRepeat (void)
/* Repeat count follows */ /* Repeat count follows */
long RepCount = ConstExpression (); long RepCount = ConstExpression ();
if (RepCount < 0) { if (RepCount < 0) {
Error (ERR_RANGE); Error ("Range error");
RepCount = 0; RepCount = 0;
} }
@@ -140,7 +140,7 @@ void ParseRepeat (void)
/* Check for an identifier */ /* Check for an identifier */
if (Tok != TOK_IDENT) { if (Tok != TOK_IDENT) {
ErrorSkip (ERR_IDENT_EXPECTED); ErrorSkip ("Identifier expected");
} else { } else {
/* Remember the name and skip it */ /* Remember the name and skip it */
Name = xstrdup (SVal); Name = xstrdup (SVal);

View File

@@ -7,7 +7,7 @@
/* */ /* */
/* */ /* */
/* (C) 1998-2003 Ullrich von Bassewitz */ /* (C) 1998-2003 Ullrich von Bassewitz */
/* R<>merstrasse 52 */ /* R<>merstra<EFBFBD>e 52 */
/* D-70794 Filderstadt */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
/* */ /* */
@@ -307,7 +307,7 @@ void NewInputFile (const char* Name)
/* Error (fatal error if this is the main file) */ /* Error (fatal error if this is the main file) */
if (ICount == 0) { if (ICount == 0) {
Fatal (FAT_CANNOT_OPEN_INPUT, Name, strerror (errno)); Fatal ("Cannot open input file `%s': %s", Name, strerror (errno));
} }
/* We are on include level. Search for the file in the include /* We are on include level. Search for the file in the include
@@ -316,7 +316,7 @@ void NewInputFile (const char* Name)
PathName = FindInclude (Name); PathName = FindInclude (Name);
if (PathName == 0 || (F = fopen (PathName, "r")) == 0) { if (PathName == 0 || (F = fopen (PathName, "r")) == 0) {
/* Not found or cannot open, print an error and bail out */ /* Not found or cannot open, print an error and bail out */
Error (ERR_CANNOT_OPEN_INCLUDE, Name, strerror (errno)); Error ("Cannot open include file `%s': %s", Name, strerror (errno));
} }
/* Free the allocated memory */ /* Free the allocated memory */
@@ -332,7 +332,7 @@ void NewInputFile (const char* Name)
/* Stat the file and remember the values */ /* Stat the file and remember the values */
struct stat Buf; struct stat Buf;
if (fstat (fileno (F), &Buf) != 0) { if (fstat (fileno (F), &Buf) != 0) {
Fatal (FAT_CANNOT_STAT_INPUT, Name, strerror (errno)); Fatal ("Cannot stat input file `%s': %s", Name, strerror (errno));
} }
/* Add the file to the input file table and remember the index */ /* Add the file to the input file table and remember the index */
@@ -579,13 +579,13 @@ static unsigned ReadStringConst (int StringTerm)
break; break;
} }
if (C == '\n' || C == EOF) { if (C == '\n' || C == EOF) {
Error (ERR_NEWLINE_IN_STRING); Error ("Newline in string constant");
break; break;
} }
/* Check for string length, print an error message once */ /* Check for string length, print an error message once */
if (I == MAX_STR_LEN) { if (I == MAX_STR_LEN) {
Error (ERR_STRING_TOO_LONG); Error ("Maximum string size exceeded");
} else if (I < MAX_STR_LEN) { } else if (I < MAX_STR_LEN) {
SVal [I] = C; SVal [I] = C;
} }
@@ -651,7 +651,7 @@ Again:
Tok = TOK_PC; Tok = TOK_PC;
return; return;
} else { } else {
Error (ERR_HEX_DIGIT_EXPECTED); Error ("Hexadecimal digit expected");
} }
} }
@@ -659,7 +659,7 @@ Again:
IVal = 0; IVal = 0;
while (IsXDigit (C)) { while (IsXDigit (C)) {
if (IVal & 0xF0000000) { if (IVal & 0xF0000000) {
Error (ERR_NUM_OVERFLOW); Error ("Overflow in hexadecimal number");
IVal = 0; IVal = 0;
} }
IVal = (IVal << 4) + DigitVal (C); IVal = (IVal << 4) + DigitVal (C);
@@ -677,14 +677,14 @@ Again:
/* 0 or 1 must follow */ /* 0 or 1 must follow */
if (!IsBDigit (C)) { if (!IsBDigit (C)) {
Error (ERR_01_EXPECTED); Error ("Binary digit expected");
} }
/* Read the number */ /* Read the number */
IVal = 0; IVal = 0;
while (IsBDigit (C)) { while (IsBDigit (C)) {
if (IVal & 0x80000000) { if (IVal & 0x80000000) {
Error (ERR_NUM_OVERFLOW); Error ("Overflow in binary number");
IVal = 0; IVal = 0;
} }
IVal = (IVal << 1) + DigitVal (C); IVal = (IVal << 1) + DigitVal (C);
@@ -703,7 +703,7 @@ Again:
IVal = 0; IVal = 0;
while (IsDigit (C)) { while (IsDigit (C)) {
if (IVal > (long) (0xFFFFFFFFUL / 10)) { if (IVal > (long) (0xFFFFFFFFUL / 10)) {
Error (ERR_NUM_OVERFLOW); Error ("Overflow in decimal number");
IVal = 0; IVal = 0;
} }
IVal = (IVal * 10) + DigitVal (C); IVal = (IVal * 10) + DigitVal (C);
@@ -719,7 +719,6 @@ Again:
if (C == '.') { if (C == '.') {
/* Remember and skip the dot */ /* Remember and skip the dot */
SVal[0] = C;
NextChar (); NextChar ();
/* Check if it's just a dot */ /* Check if it's just a dot */
@@ -731,6 +730,7 @@ Again:
} else { } else {
/* Read the remainder of the identifier */ /* Read the remainder of the identifier */
SVal[0] = '.';
ReadIdent (1); ReadIdent (1);
/* Dot keyword, search for it */ /* Dot keyword, search for it */
@@ -742,7 +742,7 @@ Again:
Tok = TOK_IDENT; Tok = TOK_IDENT;
} else { } else {
/* Invalid pseudo instruction */ /* Invalid pseudo instruction */
Error (ERR_PSEUDO_EXPECTED); Error ("`%s' is not a recognized control command", SVal);
goto Again; goto Again;
} }
} }
@@ -759,7 +759,7 @@ Again:
/* Start character alone is not enough */ /* Start character alone is not enough */
if (SVal [1] == '\0') { if (SVal [1] == '\0') {
Error (ERR_IDENT_EXPECTED); Error ("Invalid cheap local symbol");
goto Again; goto Again;
} }
@@ -1024,14 +1024,14 @@ CharAgain:
/* Always a character constant */ /* Always a character constant */
NextChar (); NextChar ();
if (C == '\n' || C == EOF) { if (C == '\n' || C == EOF) {
Error (ERR_ILLEGAL_CHARCON); Error ("Illegal character constant");
goto CharAgain; goto CharAgain;
} }
IVal = C; IVal = C;
Tok = TOK_CHARCON; Tok = TOK_CHARCON;
NextChar (); NextChar ();
if (C != '\'') { if (C != '\'') {
Error (ERR_ILLEGAL_CHARCON); Error ("Illegal character constant");
} else { } else {
NextChar (); NextChar ();
} }
@@ -1082,7 +1082,7 @@ CharAgain:
/* If we go here, we could not identify the current character. Skip it /* If we go here, we could not identify the current character. Skip it
* and try again. * and try again.
*/ */
Error (ERR_INVALID_CHAR, C & 0xFF); Error ("Invalid input character: 0x%02X", C & 0xFF);
NextChar (); NextChar ();
goto Again; goto Again;
} }
@@ -1150,7 +1150,7 @@ unsigned ParseAddrSize (void)
/* Check for an identifier */ /* Check for an identifier */
if (Tok != TOK_IDENT) { if (Tok != TOK_IDENT) {
Error (ERR_ADDR_SIZE_EXPECTED); Error ("Address size specifier expected");
return ADDR_SIZE_DEFAULT; return ADDR_SIZE_DEFAULT;
} }
@@ -1164,7 +1164,7 @@ unsigned ParseAddrSize (void)
case 5: return ADDR_SIZE_ABS; case 5: return ADDR_SIZE_ABS;
case 6: return ADDR_SIZE_FAR; case 6: return ADDR_SIZE_FAR;
default: default:
Error (ERR_ADDR_SIZE_EXPECTED); Error ("Address size specifier expected");
return ADDR_SIZE_DEFAULT; return ADDR_SIZE_DEFAULT;
} }
} }

View File

@@ -7,7 +7,7 @@
/* */ /* */
/* */ /* */
/* (C) 1998-2003 Ullrich von Bassewitz */ /* (C) 1998-2003 Ullrich von Bassewitz */
/* R<>merstrasse 52 */ /* R<>merstra<EFBFBD>e 52 */
/* D-70794 Filderstadt */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
/* */ /* */
@@ -109,12 +109,12 @@ static Segment* NewSegment (const char* Name, unsigned AddrSize)
/* Check for too many segments */ /* Check for too many segments */
if (SegmentCount >= 256) { if (SegmentCount >= 256) {
Fatal (FAT_TOO_MANY_SEGMENTS); Fatal ("Too many segments");
} }
/* Check the segment name for invalid names */ /* Check the segment name for invalid names */
if (!ValidSegName (Name)) { if (!ValidSegName (Name)) {
Error (ERR_ILLEGAL_SEGMENT, Name); Error ("Illegal segment name: `%s'", Name);
} }
/* Create a new segment */ /* Create a new segment */
@@ -186,7 +186,7 @@ void UseSeg (const SegDef* D)
/* We found this segment. Check if the type is identical */ /* We found this segment. Check if the type is identical */
if (D->AddrSize != ADDR_SIZE_DEFAULT && if (D->AddrSize != ADDR_SIZE_DEFAULT &&
Seg->Def->AddrSize != D->AddrSize) { Seg->Def->AddrSize != D->AddrSize) {
Error (ERR_SEG_ATTR_MISMATCH); Error ("Segment attribute mismatch");
/* Use the new attribute to avoid errors */ /* Use the new attribute to avoid errors */
Seg->Def->AddrSize = D->AddrSize; Seg->Def->AddrSize = D->AddrSize;
} }
@@ -303,24 +303,24 @@ void SegCheck (void)
if (Abs) { if (Abs) {
/* Absolute value */ /* Absolute value */
if (Val > 255) { if (Val > 255) {
PError (&F->Pos, ERR_RANGE); PError (&F->Pos, "Range error");
} }
} else { } else {
/* PC relative value */ /* PC relative value */
if (Val < -128 || Val > 127) { if (Val < -128 || Val > 127) {
PError (&F->Pos, ERR_RANGE); PError (&F->Pos, "Range error");
} }
} }
} else if (F->Len == 2) { } else if (F->Len == 2) {
if (Abs) { if (Abs) {
/* Absolute value */ /* Absolute value */
if (Val > 65535) { if (Val > 65535) {
PError (&F->Pos, ERR_RANGE); PError (&F->Pos, "Range error");
} }
} else { } else {
/* PC relative value */ /* PC relative value */
if (Val < -32768 || Val > 32767) { if (Val < -32768 || Val > 32767) {
PError (&F->Pos, ERR_RANGE); PError (&F->Pos, "Range error");
} }
} }
} }
@@ -340,7 +340,7 @@ void SegCheck (void)
* byte expressions and we will do so. * byte expressions and we will do so.
*/ */
if (F->Type == FRAG_EXPR && F->Len == 1 && !IsByteExpr (F->V.Expr)) { if (F->Type == FRAG_EXPR && F->Len == 1 && !IsByteExpr (F->V.Expr)) {
PError (&F->Pos, ERR_RANGE); PError (&F->Pos, "Range error");
} }
} }
} }

View File

@@ -7,7 +7,7 @@
/* */ /* */
/* */ /* */
/* (C) 1998-2003 Ullrich von Bassewitz */ /* (C) 1998-2003 Ullrich von Bassewitz */
/* R<>merstrasse 52 */ /* R<>merstra<EFBFBD>e 52 */
/* D-70794 Filderstadt */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
/* */ /* */
@@ -76,7 +76,7 @@ SymEntry* ParseScopedSymName (int AllocNew)
/* An identifier must follow. Remember and skip it. */ /* An identifier must follow. Remember and skip it. */
char Name[sizeof (SVal)]; char Name[sizeof (SVal)];
if (Tok != TOK_IDENT) { if (Tok != TOK_IDENT) {
Error (ERR_IDENT_EXPECTED); Error ("Identifier expected");
return 0; return 0;
} }
strcpy (Name, SVal); strcpy (Name, SVal);

View File

@@ -46,6 +46,7 @@
#include "scanner.h" #include "scanner.h"
#include "spool.h" #include "spool.h"
#include "symentry.h" #include "symentry.h"
#include "symtab.h"
@@ -143,12 +144,12 @@ void SymDef (SymEntry* S, ExprNode* Expr, unsigned AddrSize, unsigned Flags)
{ {
if (S->Flags & SF_IMPORT) { if (S->Flags & SF_IMPORT) {
/* Defined symbol is marked as imported external symbol */ /* Defined symbol is marked as imported external symbol */
Error (ERR_SYM_ALREADY_IMPORT, GetSymName (S)); Error ("Symbol `%s' is already an import", GetSymName (S));
return; return;
} }
if (S->Flags & SF_DEFINED) { if (S->Flags & SF_DEFINED) {
/* Multiple definition */ /* Multiple definition */
Error (ERR_SYM_ALREADY_DEFINED, GetSymName (S)); Error ("Symbol `%s' is already defined", GetSymName (S));
S->Flags |= SF_MULTDEF; S->Flags |= SF_MULTDEF;
return; return;
} }
@@ -182,7 +183,7 @@ void SymDef (SymEntry* S, ExprNode* Expr, unsigned AddrSize, unsigned Flags)
/* If the symbol is exported, check the address sizes */ /* If the symbol is exported, check the address sizes */
if (S->Flags & SF_EXPORT) { if (S->Flags & SF_EXPORT) {
if (S->AddrSize > S->ExportSize) { if (S->AddrSize > S->ExportSize) {
Warning (WARN_ADDR_SIZE_MISMATCH, GetSymName (S)); Warning (1, "Address size mismatch for symbol `%s'", GetSymName (S));
} }
} }
@@ -190,7 +191,7 @@ void SymDef (SymEntry* S, ExprNode* Expr, unsigned AddrSize, unsigned Flags)
if (S->AddrSize == ADDR_SIZE_ZP) { if (S->AddrSize == ADDR_SIZE_ZP) {
/* Already marked as ZP symbol by some means */ /* Already marked as ZP symbol by some means */
if (!IsByteExpr (Expr)) { if (!IsByteExpr (Expr)) {
Error (ERR_RANGE); Error ("Range error");
} }
} }
@@ -207,18 +208,18 @@ void SymImport (SymEntry* S, unsigned AddrSize, unsigned Flags)
{ {
/* Don't accept local symbols */ /* Don't accept local symbols */
if (IsLocalNameId (S->Name)) { if (IsLocalNameId (S->Name)) {
Error (ERR_ILLEGAL_LOCAL_USE); Error ("Illegal use of a local symbol");
return; return;
} }
if (S->Flags & SF_DEFINED) { if (S->Flags & SF_DEFINED) {
Error (ERR_SYM_ALREADY_DEFINED, GetSymName (S)); Error ("Symbol `%s' is already defined", GetSymName (S));
S->Flags |= SF_MULTDEF; S->Flags |= SF_MULTDEF;
return; return;
} }
if (S->Flags & SF_EXPORT) { if (S->Flags & SF_EXPORT) {
/* The symbol is already marked as exported symbol */ /* The symbol is already marked as exported symbol */
Error (ERR_SYM_ALREADY_EXPORT, GetSymName (S)); Error ("Cannot import exported symbol `%s'", GetSymName (S));
return; return;
} }
@@ -233,7 +234,7 @@ void SymImport (SymEntry* S, unsigned AddrSize, unsigned Flags)
if (S->Flags & (SF_IMPORT | SF_GLOBAL)) { if (S->Flags & (SF_IMPORT | SF_GLOBAL)) {
if ((Flags & SF_FORCED) != (S->Flags & SF_FORCED) || if ((Flags & SF_FORCED) != (S->Flags & SF_FORCED) ||
AddrSize != S->AddrSize) { AddrSize != S->AddrSize) {
Error (ERR_SYM_REDECL_MISMATCH, GetSymName (S)); Error ("Redeclaration mismatch for symbol `%s'", GetSymName (S));
} }
S->Flags &= ~SF_GLOBAL; S->Flags &= ~SF_GLOBAL;
} }
@@ -250,14 +251,14 @@ void SymExport (SymEntry* S, unsigned AddrSize, unsigned Flags)
{ {
/* Don't accept local symbols */ /* Don't accept local symbols */
if (IsLocalNameId (S->Name)) { if (IsLocalNameId (S->Name)) {
Error (ERR_ILLEGAL_LOCAL_USE); Error ("Illegal use of a local symbol");
return; return;
} }
/* Check if it's ok to export the symbol */ /* Check if it's ok to export the symbol */
if (S->Flags & SF_IMPORT) { if (S->Flags & SF_IMPORT) {
/* The symbol is already marked as imported external symbol */ /* The symbol is already marked as imported external symbol */
Error (ERR_SYM_ALREADY_IMPORT, GetSymName (S)); Error ("Symbol `%s' is already an import", GetSymName (S));
return; return;
} }
@@ -272,7 +273,7 @@ void SymExport (SymEntry* S, unsigned AddrSize, unsigned Flags)
*/ */
if (S->Flags & (SF_EXPORT | SF_GLOBAL)) { if (S->Flags & (SF_EXPORT | SF_GLOBAL)) {
if (S->ExportSize != AddrSize) { if (S->ExportSize != AddrSize) {
Error (ERR_ADDR_SIZE_MISMATCH, GetSymName (S)); Error ("Address size mismatch for symbol `%s'", GetSymName (S));
} }
S->Flags &= ~SF_GLOBAL; S->Flags &= ~SF_GLOBAL;
} }
@@ -283,7 +284,7 @@ void SymExport (SymEntry* S, unsigned AddrSize, unsigned Flags)
*/ */
if (S->Flags & SF_DEFINED) { if (S->Flags & SF_DEFINED) {
if (S->AddrSize > S->ExportSize) { if (S->AddrSize > S->ExportSize) {
Warning (WARN_ADDR_SIZE_MISMATCH, GetSymName (S)); Warning (1, "Address size mismatch for symbol `%s'", GetSymName (S));
} }
} }
@@ -300,7 +301,7 @@ void SymGlobal (SymEntry* S, unsigned AddrSize, unsigned Flags)
{ {
/* Don't accept local symbols */ /* Don't accept local symbols */
if (IsLocalNameId (S->Name)) { if (IsLocalNameId (S->Name)) {
Error (ERR_ILLEGAL_LOCAL_USE); Error ("Illegal use of a local symbol");
return; return;
} }
@@ -314,13 +315,13 @@ void SymGlobal (SymEntry* S, unsigned AddrSize, unsigned Flags)
*/ */
if (S->Flags & SF_IMPORT) { if (S->Flags & SF_IMPORT) {
if (AddrSize != S->AddrSize) { if (AddrSize != S->AddrSize) {
Error (ERR_ADDR_SIZE_MISMATCH, GetSymName (S)); Error ("Address size mismatch for symbol `%s'", GetSymName (S));
} }
return; return;
} }
if (S->Flags & SF_EXPORT) { if (S->Flags & SF_EXPORT) {
if (AddrSize != S->ExportSize) { if (AddrSize != S->ExportSize) {
Error (ERR_ADDR_SIZE_MISMATCH, GetSymName (S)); Error ("Address size mismatch for symbol `%s'", GetSymName (S));
} }
return; return;
} }
@@ -331,7 +332,7 @@ void SymGlobal (SymEntry* S, unsigned AddrSize, unsigned Flags)
if (S->Flags & SF_DEFINED) { if (S->Flags & SF_DEFINED) {
/* The symbol is defined, export it */ /* The symbol is defined, export it */
if (S->ExportSize != AddrSize) { if (S->ExportSize != AddrSize) {
Error (ERR_ADDR_SIZE_MISMATCH, GetSymName (S)); Error ("Address size mismatch for symbol `%s'", GetSymName (S));
} }
S->Flags |= (SF_EXPORT | Flags); S->Flags |= (SF_EXPORT | Flags);
S->ExportSize = AddrSize; S->ExportSize = AddrSize;

View File

@@ -48,6 +48,7 @@
#include "expr.h" #include "expr.h"
#include "objfile.h" #include "objfile.h"
#include "scanner.h" #include "scanner.h"
#include "segment.h"
#include "spool.h" #include "spool.h"
#include "symtab.h" #include "symtab.h"
@@ -95,7 +96,7 @@ static unsigned ScopeTableSize (unsigned Level)
static SymTable* NewSymTable (SymTable* Parent, unsigned AddrSize, const char* Name) static SymTable* NewSymTable (SymTable* Parent, const char* Name)
/* Allocate a symbol table on the heap and return it */ /* Allocate a symbol table on the heap and return it */
{ {
/* Determine the lexical level and the number of table slots */ /* Determine the lexical level and the number of table slots */
@@ -109,7 +110,8 @@ static SymTable* NewSymTable (SymTable* Parent, unsigned AddrSize, const char* N
S->Left = 0; S->Left = 0;
S->Right = 0; S->Right = 0;
S->Childs = 0; S->Childs = 0;
S->AddrSize = AddrSize; S->Flags = ST_NONE;
S->AddrSize = ADDR_SIZE_DEFAULT;
S->Type = 0; S->Type = 0;
S->Level = Level; S->Level = Level;
S->TableSlots = Slots; S->TableSlots = Slots;
@@ -207,16 +209,22 @@ static int SearchSymTree (SymEntry* T, const char* Name, SymEntry** E)
void SymEnterLevel (const char* ScopeName, unsigned AddrSize) void SymEnterLevel (const char* ScopeName, unsigned AddrSize)
/* Enter a new lexical level */ /* Enter a new lexical level */
{ {
/* ### Check existing scope */
/* Map a default address size to something real */ /* Map a default address size to something real */
if (AddrSize == ADDR_SIZE_DEFAULT) { if (AddrSize == ADDR_SIZE_DEFAULT) {
/* Use the segment address size */ /* Use the segment address size */
AddrSize = GetCurrentSegAddrSize (); AddrSize = GetCurrentSegAddrSize ();
} }
/* Create the new table */ /* Search for an existing table/create a new one */
CurrentScope = NewSymTable (CurrentScope, ScopeName); CurrentScope = SymFindScope (CurrentScope, ScopeName, SYM_ALLOC_NEW);
/* Check if the scope has been defined before */
if (CurrentScope->Flags & ST_DEFINED) {
Error ("Duplicate scope `%s'", ScopeName);
}
/* Mark the scope as defined */
CurrentScope->Flags |= ST_DEFINED;
} }
@@ -270,7 +278,7 @@ SymEntry* SymFind (SymTable* Scope, const char* Name, int AllocNew)
/* Local symbol, get the table */ /* Local symbol, get the table */
if (!SymLast) { if (!SymLast) {
/* No last global, so there's no local table */ /* No last global, so there's no local table */
Error (ERR_ILLEGAL_LOCAL_USE); Error ("No preceeding global symbol");
if (AllocNew) { if (AllocNew) {
return NewSymEntry (Name); return NewSymEntry (Name);
} else { } else {
@@ -385,7 +393,7 @@ void SymConDes (const char* Name, unsigned Type, unsigned Prio)
/* Don't accept local symbols */ /* Don't accept local symbols */
if (IsLocalName (Name)) { if (IsLocalName (Name)) {
Error (ERR_ILLEGAL_LOCAL_USE); Error ("Illegal use of a local symbol");
return; return;
} }
@@ -393,7 +401,7 @@ void SymConDes (const char* Name, unsigned Type, unsigned Prio)
S = SymFind (CurrentScope, Name, SYM_ALLOC_NEW); S = SymFind (CurrentScope, Name, SYM_ALLOC_NEW);
if (S->Flags & SF_IMPORT) { if (S->Flags & SF_IMPORT) {
/* The symbol is already marked as imported external symbol */ /* The symbol is already marked as imported external symbol */
Error (ERR_SYM_ALREADY_IMPORT, Name); Error ("Symbol `%s' is already an import", Name);
return; return;
} }
@@ -404,7 +412,7 @@ void SymConDes (const char* Name, unsigned Type, unsigned Prio)
/* Check if the symbol was not already defined as ZP symbol */ /* Check if the symbol was not already defined as ZP symbol */
if (S->AddrSize == ADDR_SIZE_ZP) { if (S->AddrSize == ADDR_SIZE_ZP) {
Error (ERR_SYM_REDECL_MISMATCH, Name); Error ("Redeclaration mismatch for symbol `%s'", Name);
} }
/* If the symbol was already declared as a condes, check if the new /* If the symbol was already declared as a condes, check if the new
@@ -412,7 +420,7 @@ void SymConDes (const char* Name, unsigned Type, unsigned Prio)
*/ */
if (S->ConDesPrio[Type] != CD_PRIO_NONE) { if (S->ConDesPrio[Type] != CD_PRIO_NONE) {
if (S->ConDesPrio[Type] != Prio) { if (S->ConDesPrio[Type] != Prio) {
Error (ERR_SYM_REDECL_MISMATCH, Name); Error ("Redeclaration mismatch for symbol `%s'", Name);
} }
} }
S->ConDesPrio[Type] = Prio; S->ConDesPrio[Type] = Prio;
@@ -527,7 +535,7 @@ static void SymCheckUndefined (SymEntry* S)
if (S->Flags & SF_EXPORT) { if (S->Flags & SF_EXPORT) {
if (Sym->Flags & SF_IMPORT) { if (Sym->Flags & SF_IMPORT) {
/* The symbol is already marked as imported external symbol */ /* The symbol is already marked as imported external symbol */
PError (&S->Pos, ERR_SYM_ALREADY_IMPORT, GetString (S->Name)); PError (&S->Pos, "Symbol `%s' is already an import", GetString (S->Name));
} }
Sym->Flags |= S->Flags & (SF_EXPORT | SF_ZP); Sym->Flags |= S->Flags & (SF_EXPORT | SF_ZP);
} }
@@ -539,14 +547,15 @@ static void SymCheckUndefined (SymEntry* S)
/* The symbol is definitely undefined */ /* The symbol is definitely undefined */
if (S->Flags & SF_EXPORT) { if (S->Flags & SF_EXPORT) {
/* We will not auto-import an export */ /* We will not auto-import an export */
PError (&S->Pos, ERR_EXPORT_UNDEFINED, GetString (S->Name)); PError (&S->Pos, "Exported symbol `%s' was never defined",
GetString (S->Name));
} else { } else {
if (AutoImport) { if (AutoImport) {
/* Mark as import, will be indexed later */ /* Mark as import, will be indexed later */
S->Flags |= SF_IMPORT; S->Flags |= SF_IMPORT;
} else { } else {
/* Error */ /* Error */
PError (&S->Pos, ERR_SYM_UNDEFINED, GetString (S->Name)); PError (&S->Pos, "Symbol `%s' is undefined", GetString (S->Name));
} }
} }
} }
@@ -559,9 +568,9 @@ void SymCheck (void)
{ {
SymEntry* S; SymEntry* S;
/* Check for open lexical levels */ /* Check for open scopes */
if (CurrentScope->Parent != 0) { if (CurrentScope->Parent != 0) {
Error (ERR_OPEN_PROC); Error ("Local scope was not closed");
} }
/* First pass: Walk through all symbols, checking for undefined's and /* First pass: Walk through all symbols, checking for undefined's and
@@ -601,12 +610,16 @@ void SymCheck (void)
(S->Flags & SF_UNDEFMASK) != SF_UNDEFVAL) { (S->Flags & SF_UNDEFMASK) != SF_UNDEFVAL) {
if ((S->Flags & SF_DEFINED) != 0 && (S->Flags & SF_REFERENCED) == 0) { if ((S->Flags & SF_DEFINED) != 0 && (S->Flags & SF_REFERENCED) == 0) {
/* Symbol was defined but never referenced */ /* Symbol was defined but never referenced */
PWarning (&S->Pos, WARN_SYM_NOT_REFERENCED, GetString (S->Name)); PWarning (&S->Pos, 2,
"Symbol `%s' is defined but never used",
GetString (S->Name));
} }
if (S->Flags & SF_IMPORT) { if (S->Flags & SF_IMPORT) {
if ((S->Flags & (SF_REFERENCED | SF_FORCED)) == SF_NONE) { if ((S->Flags & (SF_REFERENCED | SF_FORCED)) == SF_NONE) {
/* Imported symbol is not referenced */ /* Imported symbol is not referenced */
PWarning (&S->Pos, WARN_IMPORT_NOT_REFERENCED, GetString (S->Name)); PWarning (&S->Pos, 2,
"Symbol `%s' is imported but never used",
GetString (S->Name));
} else { } else {
/* Give the import an index, count imports */ /* Give the import an index, count imports */
S->Index = ImportCount++; S->Index = ImportCount++;

View File

@@ -54,6 +54,10 @@
/* Symbol table flags */
#define ST_NONE 0x00 /* No flags */
#define ST_DEFINED 0x01 /* Scope has been defined */
/* A symbol table */ /* A symbol table */
typedef struct SymTable SymTable; typedef struct SymTable SymTable;
struct SymTable { struct SymTable {
@@ -61,6 +65,7 @@ struct SymTable {
SymTable* Right; /* Pointer to greater entry */ SymTable* Right; /* Pointer to greater entry */
SymTable* Parent; /* Link to enclosing scope if any */ SymTable* Parent; /* Link to enclosing scope if any */
SymTable* Childs; /* Pointer to child scopes */ SymTable* Childs; /* Pointer to child scopes */
unsigned short Flags; /* Symbol table flags */
unsigned char AddrSize; /* Address size */ unsigned char AddrSize; /* Address size */
unsigned char Type; /* Type of the scope */ unsigned char Type; /* Type of the scope */
unsigned Level; /* Lexical level */ unsigned Level; /* Lexical level */

View File

@@ -7,7 +7,7 @@
/* */ /* */
/* */ /* */
/* (C) 2000-2003 Ullrich von Bassewitz */ /* (C) 2000-2003 Ullrich von Bassewitz */
/* R<>merstrasse 52 */ /* R<>merstra<EFBFBD>e 52 */
/* D-70794 Filderstadt */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
/* */ /* */
@@ -135,7 +135,7 @@ ExprNode* ULabRef (int Which)
} }
if (L == 0) { if (L == 0) {
/* Label does not exist */ /* Label does not exist */
Error (ERR_UNDEFINED_LABEL); Error ("Undefined label");
/* We must return something valid */ /* We must return something valid */
return GenCurrentPC(); return GenCurrentPC();
} else { } else {
@@ -216,7 +216,7 @@ void ULabCheck (void)
if (ULabLastDef) { if (ULabLastDef) {
L = ULabLastDef->Next; L = ULabLastDef->Next;
while (L) { while (L) {
PError (&L->Pos, ERR_UNDEFINED_LABEL); PError (&L->Pos, "Undefined label");
L = L->Next; L = L->Next;
} }
} }