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:
165
src/ca65/error.c
165
src/ca65/error.c
@@ -7,7 +7,7 @@
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||
/* R<>merstrasse 52 */
|
||||
/* R<>merstra<EFBFBD>e 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* 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. */
|
||||
{
|
||||
static const struct {
|
||||
unsigned char Level;
|
||||
const char* Msg;
|
||||
} Warnings [WARN_COUNT-1] = {
|
||||
{ 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);
|
||||
if (Level <= WarnLevel) {
|
||||
fprintf (stderr, "%s(%lu): Warning: ",
|
||||
GetFileName (Pos->Name), Pos->Line);
|
||||
vfprintf (stderr, Format, ap);
|
||||
fprintf (stderr, "\n");
|
||||
++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. */
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, WarnNum);
|
||||
WarningMsg (&CurPos, WarnNum, ap);
|
||||
va_start (ap, Format);
|
||||
WarningMsg (&CurPos, Level, Format, 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. */
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, WarnNum);
|
||||
WarningMsg (Pos, WarnNum, ap);
|
||||
va_start (ap, Format);
|
||||
WarningMsg (Pos, Level, Format, 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 */
|
||||
{
|
||||
static const char* Msgs [ERR_COUNT-1] = {
|
||||
"Command/operation not implemented",
|
||||
"Cannot open include file `%s': %s",
|
||||
"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, "%s(%lu): Error: ",
|
||||
GetFileName (Pos->Name), Pos->Line);
|
||||
vfprintf (stderr, Format, ap);
|
||||
fprintf (stderr, "\n");
|
||||
++ErrorCount;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Error (unsigned ErrNum, ...)
|
||||
void Error (const char* Format, ...)
|
||||
/* Print an error message */
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, ErrNum);
|
||||
ErrorMsg (&CurPos, ErrNum, ap);
|
||||
va_start (ap, Format);
|
||||
ErrorMsg (&CurPos, Format, 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. */
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, ErrNum);
|
||||
ErrorMsg (Pos, ErrNum, ap);
|
||||
va_start (ap, Format);
|
||||
ErrorMsg (Pos, Format, ap);
|
||||
va_end (ap);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ErrorSkip (unsigned ErrNum, ...)
|
||||
void ErrorSkip (const char* Format, ...)
|
||||
/* Print an error message and skip the rest of the line */
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, ErrNum);
|
||||
ErrorMsg (&CurPos, ErrNum, ap);
|
||||
va_start (ap, Format);
|
||||
ErrorMsg (&CurPos, Format, ap);
|
||||
va_end (ap);
|
||||
|
||||
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 */
|
||||
{
|
||||
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_start (ap, FatNum);
|
||||
fprintf (stderr, "Fatal #%u: ", FatNum);
|
||||
vfprintf (stderr, Msgs [FatNum-1], ap);
|
||||
va_start (ap, Format);
|
||||
fprintf (stderr, "Fatal error: ");
|
||||
vfprintf (stderr, Format, ap);
|
||||
fprintf (stderr, "\n");
|
||||
va_end (ap);
|
||||
|
||||
@@ -286,7 +181,7 @@ void Internal (const char* Format, ...)
|
||||
/* Print a message about an internal compiler error and die. */
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, Format);
|
||||
va_start (ap, Format);
|
||||
fprintf (stderr, "Internal assembler error\n");
|
||||
vfprintf (stderr, Format, ap);
|
||||
va_end (ap);
|
||||
|
||||
Reference in New Issue
Block a user