mirror of
https://github.com/cc65/cc65.git
synced 2025-01-11 11:30:13 +00:00
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:
parent
7e74078801
commit
44976a0461
@ -7,9 +7,9 @@
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2000-2003 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* EMail: uz@musoftware.de */
|
||||
/* Römerstraße 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* 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 */
|
||||
if (IfCount >= MAX_IFS) {
|
||||
Fatal (FAT_IF_NESTING);
|
||||
Fatal ("Too many nested .IFs");
|
||||
}
|
||||
|
||||
/* Alloc one element */
|
||||
@ -126,7 +126,7 @@ static void FreeIf (void)
|
||||
do {
|
||||
IfDesc* D = GetCurrentIf();
|
||||
if (D == 0) {
|
||||
Error (ERR_UNEXPECTED, ".ENDIF");
|
||||
Error (" Unexpected .ENDIF");
|
||||
Done = 1;
|
||||
} else {
|
||||
Done = (D->Flags & ifNeedTerm) != 0;
|
||||
@ -210,10 +210,10 @@ void DoConditionals (void)
|
||||
case TOK_ELSE:
|
||||
D = GetCurrentIf ();
|
||||
if (D == 0) {
|
||||
Error (ERR_UNEXPECTED, ".ELSE");
|
||||
Error ("Unexpected .ELSE");
|
||||
} else if (GetElse(D)) {
|
||||
/* We already had a .ELSE ! */
|
||||
Error (ERR_DUPLICATE_ELSE);
|
||||
Error ("Duplicate .ELSE");
|
||||
} else {
|
||||
/* Allow an .ELSE */
|
||||
InvertIfCond (D);
|
||||
@ -228,10 +228,10 @@ void DoConditionals (void)
|
||||
case TOK_ELSEIF:
|
||||
D = GetCurrentIf ();
|
||||
if (D == 0) {
|
||||
Error (ERR_UNEXPECTED, ".ELSEIF");
|
||||
Error ("Unexpected .ELSEIF");
|
||||
} else if (GetElse(D)) {
|
||||
/* We already had a .ELSE */
|
||||
Error (ERR_DUPLICATE_ELSE);
|
||||
Error ("Duplicate .ELSE");
|
||||
} else {
|
||||
/* Handle as if there was an .ELSE first */
|
||||
InvertIfCond (D);
|
||||
@ -434,7 +434,7 @@ void CheckOpenIfs (void)
|
||||
}
|
||||
|
||||
/* 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 ();
|
||||
}
|
||||
}
|
||||
|
@ -6,9 +6,9 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2000-2001 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* (C) 2000-2003 Ullrich von Bassewitz */
|
||||
/* Römerstraße 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
@ -63,7 +63,7 @@ void DbgInfoFile (void)
|
||||
|
||||
/* Name */
|
||||
if (Tok != TOK_STRCON) {
|
||||
ErrorSkip (ERR_STRCON_EXPECTED);
|
||||
ErrorSkip ("String constant expected");
|
||||
return;
|
||||
}
|
||||
strcpy (Name, SVal);
|
||||
@ -106,7 +106,7 @@ void DbgInfoLine (void)
|
||||
|
||||
/* The name of the file follows */
|
||||
if (Tok != TOK_STRCON) {
|
||||
ErrorSkip (ERR_STRCON_EXPECTED);
|
||||
ErrorSkip ("String constant expected");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ void DbgInfoLine (void)
|
||||
/* Line number */
|
||||
LineNum = ConstExpression ();
|
||||
if (LineNum < 0) {
|
||||
ErrorSkip (ERR_RANGE);
|
||||
ErrorSkip ("Line number is out of valid range");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ void DbgInfoLine (void)
|
||||
void DbgInfoSym (void)
|
||||
/* Parse and handle SYM subcommand of the .dbg pseudo instruction */
|
||||
{
|
||||
ErrorSkip (ERR_NOT_IMPLEMENTED);
|
||||
ErrorSkip ("Not implemented");
|
||||
}
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||
/* Römerstrasse 52 */
|
||||
/* Römerstraße 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
@ -102,11 +102,11 @@ void GetEA (EffAddr* A)
|
||||
/* [dir] or [dir],y */
|
||||
NextTok ();
|
||||
A->Expr = Expression ();
|
||||
Consume (TOK_RBRACK, ERR_RBRACK_EXPECTED);
|
||||
Consume (TOK_RBRACK, "']' expected");
|
||||
if (Tok == TOK_COMMA) {
|
||||
/* [dir],y */
|
||||
NextTok ();
|
||||
Consume (TOK_Y, ERR_Y_EXPECTED);
|
||||
Consume (TOK_Y, "`Y' expected");
|
||||
A->AddrModeSet = AM_DIR_IND_LONG_Y;
|
||||
} else {
|
||||
/* [dir] */
|
||||
@ -134,9 +134,9 @@ void GetEA (EffAddr* A)
|
||||
A->AddrModeSet = AM_STACK_REL_IND_Y;
|
||||
ConsumeRParen ();
|
||||
ConsumeComma ();
|
||||
Consume (TOK_Y, ERR_Y_EXPECTED);
|
||||
Consume (TOK_Y, "`Y' expected");
|
||||
} else {
|
||||
Error (ERR_SYNTAX);
|
||||
Error ("Syntax error");
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -146,7 +146,7 @@ void GetEA (EffAddr* A)
|
||||
if (Tok == TOK_COMMA) {
|
||||
/* (adr),y */
|
||||
NextTok ();
|
||||
Consume (TOK_Y, ERR_Y_EXPECTED);
|
||||
Consume (TOK_Y, "`Y' expected");
|
||||
A->AddrModeSet = AM_DIR_IND_Y;
|
||||
} else {
|
||||
/* (adr) */
|
||||
@ -176,7 +176,7 @@ void GetEA (EffAddr* A)
|
||||
if (Tok == TOK_COMMA) {
|
||||
/* bank.adr,x */
|
||||
NextTok ();
|
||||
Consume (TOK_X, ERR_X_EXPECTED);
|
||||
Consume (TOK_X, "`X' expected");
|
||||
A->AddrModeSet = AM_ABS_LONG_X;
|
||||
} else {
|
||||
/* bank.adr */
|
||||
@ -206,7 +206,7 @@ void GetEA (EffAddr* A)
|
||||
break;
|
||||
|
||||
default:
|
||||
Error (ERR_SYNTAX);
|
||||
Error ("Syntax error");
|
||||
|
||||
}
|
||||
|
||||
|
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ß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);
|
||||
|
126
src/ca65/error.h
126
src/ca65/error.h
@ -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 */
|
||||
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. */
|
||||
|
||||
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. */
|
||||
|
||||
void Error (unsigned ErrNum, ...);
|
||||
void Error (const char* Format, ...) attribute ((format (printf, 1, 2)));
|
||||
/* 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. */
|
||||
|
||||
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 */
|
||||
|
||||
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 */
|
||||
|
||||
void Internal (const char* Format, ...) attribute((noreturn, format(printf,1,2)));
|
||||
|
@ -233,7 +233,7 @@ static int DoMatch (enum TC EqualityLevel)
|
||||
|
||||
/* We may not end-of-line of end-of-file here */
|
||||
if (TokIsSep (Tok)) {
|
||||
Error (ERR_UNEXPECTED_EOL);
|
||||
Error ("Unexpected end of line");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -264,7 +264,7 @@ static int DoMatch (enum TC EqualityLevel)
|
||||
|
||||
/* We may not end-of-line of end-of-file here */
|
||||
if (TokIsSep (Tok)) {
|
||||
Error (ERR_UNEXPECTED_EOL);
|
||||
Error ("Unexpected end of line");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -334,7 +334,7 @@ static int FuncStrAt (void)
|
||||
|
||||
/* String constant expected */
|
||||
if (Tok != TOK_STRCON) {
|
||||
Error (ERR_STRCON_EXPECTED);
|
||||
Error ("String constant expected");
|
||||
NextTok ();
|
||||
return 0;
|
||||
|
||||
@ -352,7 +352,7 @@ static int FuncStrAt (void)
|
||||
|
||||
/* Must be a valid index */
|
||||
if (Index >= (long) strlen (Str)) {
|
||||
Error (ERR_RANGE);
|
||||
Error ("Range error");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -370,7 +370,7 @@ static int FuncStrLen (void)
|
||||
/* String constant expected */
|
||||
if (Tok != TOK_STRCON) {
|
||||
|
||||
Error (ERR_STRCON_EXPECTED);
|
||||
Error ("String constant expected");
|
||||
/* Smart error recovery */
|
||||
if (Tok != TOK_RPAREN) {
|
||||
NextTok ();
|
||||
@ -449,7 +449,7 @@ static ExprNode* Function (int (*F) (void))
|
||||
|
||||
/* Expression must be enclosed in braces */
|
||||
if (Tok != TOK_LPAREN) {
|
||||
Error (ERR_LPAREN_EXPECTED);
|
||||
Error ("'(' expected");
|
||||
SkipUntilSep ();
|
||||
return GenLiteralExpr (0);
|
||||
}
|
||||
@ -598,7 +598,7 @@ static ExprNode* Factor (void)
|
||||
N = GenLiteralExpr (TgtTranslateChar (SVal[0]));
|
||||
} else {
|
||||
N = GenLiteralExpr (0); /* Dummy */
|
||||
Error (ERR_SYNTAX);
|
||||
Error ("Syntax error");
|
||||
}
|
||||
NextTok ();
|
||||
break;
|
||||
@ -855,7 +855,7 @@ long ConstExpression (void)
|
||||
if (IsConstExpr (Expr)) {
|
||||
Val = GetExprVal (Expr);
|
||||
} else {
|
||||
Error (ERR_CONSTEXPR_EXPECTED);
|
||||
Error ("Constant expression expected");
|
||||
Val = 0;
|
||||
}
|
||||
|
||||
@ -1040,8 +1040,8 @@ int IsConstExpr (ExprNode* Root)
|
||||
if (Verbosity > 0) {
|
||||
DumpExpr (Root);
|
||||
}
|
||||
PError (GetSymPos (Sym), ERR_CIRCULAR_REFERENCE);
|
||||
Const = 0;
|
||||
PError (GetSymPos (Sym), "Circular reference in symbol definition");
|
||||
Const = 0;
|
||||
} else {
|
||||
SymMarkUser (Sym);
|
||||
Const = SymIsConst (Sym);
|
||||
@ -1200,7 +1200,7 @@ long GetExprVal (ExprNode* Expr)
|
||||
Left = GetExprVal (Expr->Left);
|
||||
Right = GetExprVal (Expr->Right);
|
||||
if (Right == 0) {
|
||||
Error (ERR_DIV_BY_ZERO);
|
||||
Error ("Division by zero");
|
||||
return 0;
|
||||
}
|
||||
return Left / Right;
|
||||
@ -1209,7 +1209,7 @@ long GetExprVal (ExprNode* Expr)
|
||||
Left = GetExprVal (Expr->Left);
|
||||
Right = GetExprVal (Expr->Right);
|
||||
if (Right == 0) {
|
||||
Error (ERR_MOD_BY_ZERO);
|
||||
Error ("Modulo operation with zero");
|
||||
return 0;
|
||||
}
|
||||
return Left % Right;
|
||||
@ -1315,7 +1315,7 @@ static ExprNode* RemoveSyms (ExprNode* Expr, int MustClone)
|
||||
if (Verbosity) {
|
||||
DumpExpr (Expr);
|
||||
}
|
||||
PError (GetSymPos (Sym), ERR_CIRCULAR_REFERENCE);
|
||||
PError (GetSymPos (Sym), "Circular reference in symbol definition");
|
||||
return GenLiteralExpr (0); /* Return a dummy value */
|
||||
}
|
||||
SymMarkUser (Sym);
|
||||
|
@ -215,8 +215,8 @@ unsigned GetFileIndex (const char* Name)
|
||||
|
||||
/* If we don't have this index, print a diagnostic and use the main file */
|
||||
if (F == 0) {
|
||||
Error (ERR_FILENAME_NOT_FOUND, Name);
|
||||
return 0;
|
||||
Error ("File name `%s' not found in file table", Name);
|
||||
return 0;
|
||||
} else {
|
||||
return F->Index;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||
/* Römerstrasse 52 */
|
||||
/* Römerstraße 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
@ -578,7 +578,7 @@ static int EvalEA (const InsDesc* Ins, EffAddr* A)
|
||||
|
||||
/* Check if we have any adressing modes left */
|
||||
if (A->AddrModeSet == 0) {
|
||||
Error (ERR_ILLEGAL_ADDR_MODE);
|
||||
Error ("Illegal addressing mode");
|
||||
return 0;
|
||||
}
|
||||
A->AddrMode = BitFind (A->AddrModeSet);
|
||||
@ -601,7 +601,7 @@ static int EvalEA (const InsDesc* Ins, EffAddr* A)
|
||||
!SymIsZP (Left->V.Sym)) {
|
||||
|
||||
/* 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. */
|
||||
if (Val < 0) {
|
||||
/* We had an error */
|
||||
Warning (WARN_CANNOT_TRACK_STATUS);
|
||||
Warning (1, "Cannot track processor status byte");
|
||||
} else {
|
||||
if (Val & 0x10) {
|
||||
/* Index registers to 16 bit */
|
||||
@ -772,7 +772,7 @@ static void PutSEP (const InsDesc* Ins)
|
||||
/* Check the range for Val. */
|
||||
if (Val < 0) {
|
||||
/* We had an error */
|
||||
Warning (WARN_CANNOT_TRACK_STATUS);
|
||||
Warning (1, "Cannot track processor status byte");
|
||||
} else {
|
||||
if (Val & 0x10) {
|
||||
/* Index registers to 8 bit */
|
||||
@ -862,7 +862,7 @@ void SetCPU (cpu_t NewCPU)
|
||||
CPU = NewCPU;
|
||||
InsTab = InsTabs[CPU];
|
||||
} else {
|
||||
Error (ERR_CPU_NOT_SUPPORTED);
|
||||
Error ("CPU not supported");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,10 +6,10 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2000 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* EMail: uz@musoftware.de */
|
||||
/* (C) 2000-2003 Ullrich von Bassewitz */
|
||||
/* Römerstraße 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
@ -36,7 +36,7 @@
|
||||
/* common */
|
||||
#include "check.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
|
||||
/* ca65 */
|
||||
#include "error.h"
|
||||
#include "istack.h"
|
||||
@ -80,8 +80,8 @@ void PushInput (int (*Func) (void*), void* Data, const char* Desc)
|
||||
|
||||
/* Check for a stack overflow */
|
||||
if (ICount > ISTACK_MAX) {
|
||||
Fatal (FAT_NESTING);
|
||||
}
|
||||
Fatal ("Maximum input stack nesting exceeded");
|
||||
}
|
||||
|
||||
/* Create a new stack element */
|
||||
E = xmalloc (sizeof (*E));
|
||||
@ -153,7 +153,7 @@ void CheckInputStack (void)
|
||||
*/
|
||||
{
|
||||
if (IStack) {
|
||||
Error (ERR_OPEN_STMT, IStack->Desc);
|
||||
Error ("Open %s", IStack->Desc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2000-2003 Ullrich von Bassewitz */
|
||||
/* Römerstrasse 52 */
|
||||
/* Römerstraße 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
@ -146,7 +146,7 @@ void DisableListing (void)
|
||||
if (Listing) {
|
||||
if (ListingEnabled == 0) {
|
||||
/* Cannot switch the listing off once more */
|
||||
Error (ERR_COUNTER_UNDERFLOW);
|
||||
Error ("Counter underflow");
|
||||
} else {
|
||||
--ListingEnabled;
|
||||
}
|
||||
@ -306,7 +306,7 @@ void CreateListing (void)
|
||||
/* Open the real listing file */
|
||||
F = fopen (ListFile, "w");
|
||||
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 */
|
||||
|
@ -7,7 +7,7 @@
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||
/* Römerstrasse 52 */
|
||||
/* Römerstraße 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
@ -311,7 +311,7 @@ static void MacSkipDef (unsigned Style)
|
||||
if (Tok != TOK_EOF) {
|
||||
SkipUntilSep ();
|
||||
} else {
|
||||
Error (ERR_ENDMACRO_EXPECTED);
|
||||
Error ("`.ENDMACRO' expected");
|
||||
}
|
||||
} else {
|
||||
/* Skip until end of line */
|
||||
@ -330,7 +330,7 @@ void MacDef (unsigned Style)
|
||||
|
||||
/* We expect a macro name here */
|
||||
if (Tok != TOK_IDENT) {
|
||||
Error (ERR_IDENT_EXPECTED);
|
||||
Error ("Identifier expected");
|
||||
MacSkipDef (Style);
|
||||
return;
|
||||
}
|
||||
@ -338,7 +338,7 @@ void MacDef (unsigned Style)
|
||||
/* Did we already define that macro? */
|
||||
if (HT_Find (&MacroTab, SVal) != 0) {
|
||||
/* 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 */
|
||||
MacSkipDef (Style);
|
||||
return;
|
||||
@ -380,8 +380,8 @@ void MacDef (unsigned Style)
|
||||
IdDesc* List = M->Params;
|
||||
while (1) {
|
||||
if (strcmp (List->Id, SVal) == 0) {
|
||||
Error (ERR_SYM_ALREADY_DEFINED, SVal);
|
||||
}
|
||||
Error ("Duplicate symbol `%s'", SVal);
|
||||
}
|
||||
if (List->Next == 0) {
|
||||
break;
|
||||
} else {
|
||||
@ -429,7 +429,7 @@ void MacDef (unsigned Style)
|
||||
}
|
||||
/* May not have end of file in a macro definition */
|
||||
if (Tok == TOK_EOF) {
|
||||
Error (ERR_ENDMACRO_EXPECTED);
|
||||
Error ("`.ENDMACRO' expected");
|
||||
goto Done;
|
||||
}
|
||||
} else {
|
||||
@ -451,7 +451,7 @@ void MacDef (unsigned Style)
|
||||
|
||||
/* Need an identifer */
|
||||
if (Tok != TOK_IDENT) {
|
||||
Error (ERR_IDENT_EXPECTED);
|
||||
Error ("Identifier expected");
|
||||
SkipUntilSep ();
|
||||
break;
|
||||
}
|
||||
@ -662,8 +662,8 @@ static void StartExpClassic (Macro* M)
|
||||
|
||||
/* Check for maximum parameter count */
|
||||
if (E->ParamCount >= M->ParamCount) {
|
||||
Error (ERR_TOO_MANY_PARAMS);
|
||||
SkipUntilSep ();
|
||||
Error ("Too many macro parameters");
|
||||
SkipUntilSep ();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -675,7 +675,7 @@ static void StartExpClassic (Macro* M)
|
||||
|
||||
/* Check for end of file */
|
||||
if (Tok == TOK_EOF) {
|
||||
Error (ERR_UNEXPECTED_EOF);
|
||||
Error ("Unexpected end of file");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -732,7 +732,7 @@ static void StartExpDefine (Macro* M)
|
||||
|
||||
/* Check if there is really a parameter */
|
||||
if (TokIsSep (Tok) || Tok == TOK_COMMA) {
|
||||
Error (ERR_MACRO_PARAM_EXPECTED);
|
||||
Error ("Macro parameter expected");
|
||||
SkipUntilSep ();
|
||||
return;
|
||||
}
|
||||
@ -767,7 +767,7 @@ static void StartExpDefine (Macro* M)
|
||||
if (Tok == TOK_COMMA) {
|
||||
NextTok ();
|
||||
} else {
|
||||
Error (ERR_COMMA_EXPECTED);
|
||||
Error ("`,' expected");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||
/* Römerstrasse 52 */
|
||||
/* Römerstraße 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
@ -332,7 +332,7 @@ static void DoPCAssign (void)
|
||||
{
|
||||
long PC = ConstExpression ();
|
||||
if (PC < 0 || PC > 0xFFFFFF) {
|
||||
Error (ERR_RANGE);
|
||||
Error ("Range error");
|
||||
} else {
|
||||
SetAbsPC (PC);
|
||||
}
|
||||
@ -398,7 +398,7 @@ static void OneLine (void)
|
||||
*/
|
||||
if (Tok != TOK_COLON) {
|
||||
if (HadWS || !NoColonLabels) {
|
||||
Error (ERR_COLON_EXPECTED);
|
||||
Error ("`:' expected");
|
||||
}
|
||||
if (Tok == TOK_NAMESPACE) {
|
||||
/* Smart :: handling */
|
||||
@ -426,7 +426,7 @@ static void OneLine (void)
|
||||
} else if (PCAssignment && (Tok == TOK_STAR || Tok == TOK_PC)) {
|
||||
NextTok ();
|
||||
if (Tok != TOK_EQ) {
|
||||
Error (ERR_EQ_EXPECTED);
|
||||
Error ("`=' expected");
|
||||
SkipUntilSep ();
|
||||
} else {
|
||||
/* Skip the equal sign */
|
||||
|
@ -7,9 +7,9 @@
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2000-2003 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* EMail: uz@musoftware.de */
|
||||
/* Römerstraße 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* 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 */
|
||||
if (TokIsSep (Tok)) {
|
||||
Error (ERR_UNEXPECTED_EOL);
|
||||
Error ("Unexpected end of line");
|
||||
return List;
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ static void FuncConcat (void)
|
||||
|
||||
/* Next token must be a string */
|
||||
if (Tok != TOK_STRCON) {
|
||||
Error (ERR_STRCON_EXPECTED);
|
||||
Error ("String constant expected");
|
||||
SkipUntilSep ();
|
||||
return;
|
||||
}
|
||||
@ -141,7 +141,7 @@ static void FuncConcat (void)
|
||||
/* Get the length of the string const and check total length */
|
||||
L = strlen (SVal);
|
||||
if (Length + L > MAX_STR_LEN) {
|
||||
Error (ERR_STRING_TOO_LONG);
|
||||
Error ("String is too long");
|
||||
/* Try to recover */
|
||||
SkipUntilSep ();
|
||||
return;
|
||||
@ -171,7 +171,7 @@ static void FuncConcat (void)
|
||||
* by the string token just created.
|
||||
*/
|
||||
if (Tok != TOK_RPAREN) {
|
||||
Error (ERR_RPAREN_EXPECTED);
|
||||
Error ("`)' expected");
|
||||
} else {
|
||||
Tok = TOK_STRCON;
|
||||
strcpy (SVal, Buf);
|
||||
@ -195,7 +195,7 @@ static void FuncLeft (void)
|
||||
/* Count argument */
|
||||
Count = ConstExpression ();
|
||||
if (Count < 0 || Count > 100) {
|
||||
Error (ERR_RANGE);
|
||||
Error ("Range error");
|
||||
Count = 1;
|
||||
}
|
||||
ConsumeComma ();
|
||||
@ -237,7 +237,7 @@ static void FuncMid (void)
|
||||
/* Start argument */
|
||||
Start = ConstExpression ();
|
||||
if (Start < 0 || Start > 100) {
|
||||
Error (ERR_RANGE);
|
||||
Error ("Range error");
|
||||
Start = 0;
|
||||
}
|
||||
ConsumeComma ();
|
||||
@ -245,7 +245,7 @@ static void FuncMid (void)
|
||||
/* Count argument */
|
||||
Count = ConstExpression ();
|
||||
if (Count < 0 || Count > 100) {
|
||||
Error (ERR_RANGE);
|
||||
Error ("Range error");
|
||||
Count = 1;
|
||||
}
|
||||
ConsumeComma ();
|
||||
@ -286,7 +286,7 @@ static void FuncRight (void)
|
||||
/* Count argument */
|
||||
Count = ConstExpression ();
|
||||
if (Count < 0 || Count > 100) {
|
||||
Error (ERR_RANGE);
|
||||
Error ("Range error");
|
||||
Count = 1;
|
||||
}
|
||||
ConsumeComma ();
|
||||
@ -353,7 +353,7 @@ static void FuncString (void)
|
||||
* by the string token just created.
|
||||
*/
|
||||
if (Tok != TOK_RPAREN) {
|
||||
Error (ERR_RPAREN_EXPECTED);
|
||||
Error ("`)' expected");
|
||||
} else {
|
||||
Tok = TOK_STRCON;
|
||||
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 */
|
||||
{
|
||||
if (Tok == Expected) {
|
||||
@ -422,7 +422,7 @@ void ConsumeSep (void)
|
||||
/* Accept an EOF as separator */
|
||||
if (Tok != TOK_EOF) {
|
||||
if (Tok != TOK_SEP) {
|
||||
Error (ERR_TOO_MANY_CHARS);
|
||||
Error ("Too many characters");
|
||||
SkipUntilSep ();
|
||||
} else {
|
||||
NextTok ();
|
||||
@ -435,7 +435,7 @@ void ConsumeSep (void)
|
||||
void ConsumeLParen (void)
|
||||
/* Consume a left paren */
|
||||
{
|
||||
Consume (TOK_LPAREN, ERR_LPAREN_EXPECTED);
|
||||
Consume (TOK_LPAREN, "`(' expected");
|
||||
}
|
||||
|
||||
|
||||
@ -443,7 +443,7 @@ void ConsumeLParen (void)
|
||||
void ConsumeRParen (void)
|
||||
/* Consume a right paren */
|
||||
{
|
||||
Consume (TOK_RPAREN, ERR_RPAREN_EXPECTED);
|
||||
Consume (TOK_RPAREN, "`)' expected");
|
||||
}
|
||||
|
||||
|
||||
@ -451,7 +451,7 @@ void ConsumeRParen (void)
|
||||
void ConsumeComma (void)
|
||||
/* Consume a comma */
|
||||
{
|
||||
Consume (TOK_COMMA, ERR_COMMA_EXPECTED);
|
||||
Consume (TOK_COMMA, "`,' expected");
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,10 +6,10 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2000 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* EMail: uz@musoftware.de */
|
||||
/* (C) 2000-2003 Ullrich von Bassewitz */
|
||||
/* Römerstraße 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
@ -51,7 +51,7 @@
|
||||
void NextTok (void);
|
||||
/* 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 */
|
||||
|
||||
void ConsumeSep (void);
|
||||
|
@ -7,7 +7,7 @@
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||
/* Römerstrasse 52 */
|
||||
/* Römerstraße 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
@ -150,7 +150,7 @@ void EmitByte (ExprNode* Expr)
|
||||
long Val = GetExprVal (Expr);
|
||||
FreeExpr (Expr);
|
||||
if ((Val & ~0xFF) != 0) {
|
||||
Error (ERR_RANGE);
|
||||
Error ("Range error");
|
||||
}
|
||||
Emit0 (Val & 0xFF);
|
||||
} else {
|
||||
@ -172,7 +172,7 @@ void EmitWord (ExprNode* Expr)
|
||||
long Val = GetExprVal (Expr);
|
||||
FreeExpr (Expr);
|
||||
if ((Val & ~0xFFFF) != 0) {
|
||||
Error (ERR_RANGE);
|
||||
Error ("Range error");
|
||||
}
|
||||
Emit0 (Val & 0xFF);
|
||||
Emit0 ((Val >> 8) & 0xFF);
|
||||
@ -195,7 +195,7 @@ void EmitFarAddr (ExprNode* Expr)
|
||||
long Val = GetExprVal (Expr);
|
||||
FreeExpr (Expr);
|
||||
if ((Val & ~0xFFFFFF) != 0) {
|
||||
Error (ERR_RANGE);
|
||||
Error ("Range error");
|
||||
}
|
||||
Emit0 (Val & 0xFF);
|
||||
Emit0 ((Val >> 8) & 0xFF);
|
||||
|
@ -7,7 +7,7 @@
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||
/* Römerstrasse 52 */
|
||||
/* Römerstraße 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
@ -109,7 +109,7 @@ static void ObjWriteError (void)
|
||||
remove (OutFile);
|
||||
|
||||
/* 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 */
|
||||
F = fopen (OutFile, "w+b");
|
||||
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 */
|
||||
|
@ -147,15 +147,15 @@ static void SetBoolOption (unsigned char* Flag)
|
||||
} else if (Tok == TOK_IDENT) {
|
||||
/* Map the keyword to a number */
|
||||
switch (GetSubKey (Keys, sizeof (Keys) / sizeof (Keys [0]))) {
|
||||
case 0: *Flag = 0; NextTok (); break;
|
||||
case 1: *Flag = 1; NextTok (); break;
|
||||
default: ErrorSkip (ERR_ONOFF_EXPECTED); break;
|
||||
case 0: *Flag = 0; NextTok (); break;
|
||||
case 1: *Flag = 1; NextTok (); break;
|
||||
default: ErrorSkip ("`on' or `off' expected"); break;
|
||||
}
|
||||
} else if (TokIsSep (Tok)) {
|
||||
/* Without anything assume switch on */
|
||||
*Flag = 1;
|
||||
} 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 */
|
||||
if (Tok != TOK_IDENT) {
|
||||
ErrorSkip (ERR_IDENT_EXPECTED);
|
||||
ErrorSkip ("Identifier expected");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -213,7 +213,7 @@ static long IntArg (long Min, long Max)
|
||||
} else {
|
||||
long Val = ConstExpression ();
|
||||
if (Val < Min || Val > Max) {
|
||||
Error (ERR_RANGE);
|
||||
Error ("Range error");
|
||||
Val = Min;
|
||||
}
|
||||
return Val;
|
||||
@ -234,7 +234,7 @@ static void ConDes (const char* Name, unsigned Type)
|
||||
Prio = ConstExpression ();
|
||||
if (Prio < CD_PRIO_MIN || Prio > CD_PRIO_MAX) {
|
||||
/* Value out of range */
|
||||
Error (ERR_RANGE);
|
||||
Error ("Range error");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@ -256,9 +256,9 @@ static void ConDes (const char* Name, unsigned Type)
|
||||
|
||||
static void DoA16 (void)
|
||||
/* Switch the accu to 16 bit mode (assembler only) */
|
||||
{
|
||||
{
|
||||
if (GetCPU() != CPU_65816) {
|
||||
Error (ERR_816_MODE_ONLY);
|
||||
Error ("Command is only valid in 65816 mode");
|
||||
} else {
|
||||
/* Immidiate mode has two extension bytes */
|
||||
ExtBytes [AMI_IMM_ACCU] = 2;
|
||||
@ -271,7 +271,7 @@ static void DoA8 (void)
|
||||
/* Switch the accu to 8 bit mode (assembler only) */
|
||||
{
|
||||
if (GetCPU() != CPU_65816) {
|
||||
Error (ERR_816_MODE_ONLY);
|
||||
Error ("Command is only valid in 65816 mode");
|
||||
} else {
|
||||
/* Immidiate mode has one extension byte */
|
||||
ExtBytes [AMI_IMM_ACCU] = 1;
|
||||
@ -310,7 +310,7 @@ static void DoAlign (void)
|
||||
/* Read the alignment value */
|
||||
Align = ConstExpression ();
|
||||
if (Align <= 0 || Align > 0x10000) {
|
||||
ErrorSkip (ERR_RANGE);
|
||||
ErrorSkip ("Range error");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -320,7 +320,7 @@ static void DoAlign (void)
|
||||
Val = ConstExpression ();
|
||||
/* We need a byte value here */
|
||||
if (!IsByteRange (Val)) {
|
||||
ErrorSkip (ERR_RANGE);
|
||||
ErrorSkip ("Range error");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@ -330,7 +330,7 @@ static void DoAlign (void)
|
||||
/* Check if the alignment is a power of two */
|
||||
Bit = BitFind (Align);
|
||||
if (Align != (0x01L << Bit)) {
|
||||
Error (ERR_ALIGN);
|
||||
Error ("Alignment value must be a power of 2");
|
||||
} else {
|
||||
SegAlign (Bit, (int) Val);
|
||||
}
|
||||
@ -346,7 +346,7 @@ static void DoASCIIZ (void)
|
||||
while (1) {
|
||||
/* Must have a string constant */
|
||||
if (Tok != TOK_STRCON) {
|
||||
ErrorSkip (ERR_STRCON_EXPECTED);
|
||||
ErrorSkip ("String constant expected");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -385,7 +385,7 @@ static void DoAssert (void)
|
||||
|
||||
/* Action follows */
|
||||
if (Tok != TOK_IDENT) {
|
||||
ErrorSkip (ERR_IDENT_EXPECTED);
|
||||
ErrorSkip ("Identifier expected");
|
||||
return;
|
||||
}
|
||||
Action = GetSubKey (ActionTab, sizeof (ActionTab) / sizeof (ActionTab[0]));
|
||||
@ -403,14 +403,14 @@ static void DoAssert (void)
|
||||
break;
|
||||
|
||||
default:
|
||||
Error (ERR_ILLEGAL_ASSERT_ACTION);
|
||||
Error ("Illegal assert action specifier");
|
||||
}
|
||||
NextTok ();
|
||||
ConsumeComma ();
|
||||
|
||||
/* Read the message */
|
||||
if (Tok != TOK_STRCON) {
|
||||
ErrorSkip (ERR_STRCON_EXPECTED);
|
||||
ErrorSkip ("String constant expected");
|
||||
} else {
|
||||
AddAssertion (Expr, Action, GetStringId (SVal));
|
||||
NextTok ();
|
||||
@ -454,7 +454,7 @@ static void DoByte (void)
|
||||
NextTok ();
|
||||
/* Do smart handling of dangling comma */
|
||||
if (Tok == TOK_SEP) {
|
||||
Error (ERR_UNEXPECTED_EOL);
|
||||
Error ("Unexpected end of line");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -482,7 +482,7 @@ static void DoCharMap (void)
|
||||
Index = ConstExpression ();
|
||||
if (Index < 1 || Index > 255) {
|
||||
/* Value out of range */
|
||||
ErrorSkip (ERR_RANGE);
|
||||
ErrorSkip ("Range error");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -493,7 +493,7 @@ static void DoCharMap (void)
|
||||
Code = ConstExpression ();
|
||||
if (Code < 1 || Code > 255) {
|
||||
/* Value out of range */
|
||||
ErrorSkip (ERR_RANGE);
|
||||
ErrorSkip ("Range error");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -523,7 +523,7 @@ static void DoConDes (void)
|
||||
|
||||
/* Symbol name follows */
|
||||
if (Tok != TOK_IDENT) {
|
||||
ErrorSkip (ERR_IDENT_EXPECTED);
|
||||
ErrorSkip ("Identifier expected");
|
||||
return;
|
||||
}
|
||||
strcpy (Name, SVal);
|
||||
@ -539,7 +539,7 @@ static void DoConDes (void)
|
||||
|
||||
/* Check if we got a valid keyword */
|
||||
if (Type < 0) {
|
||||
Error (ERR_SYNTAX);
|
||||
Error ("Syntax error");
|
||||
SkipUntilSep ();
|
||||
return;
|
||||
}
|
||||
@ -550,7 +550,7 @@ static void DoConDes (void)
|
||||
Type = ConstExpression ();
|
||||
if (Type < CD_TYPE_MIN || Type > CD_TYPE_MAX) {
|
||||
/* Value out of range */
|
||||
Error (ERR_RANGE);
|
||||
Error ("Range error");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -569,7 +569,7 @@ static void DoConstructor (void)
|
||||
|
||||
/* Symbol name follows */
|
||||
if (Tok != TOK_IDENT) {
|
||||
ErrorSkip (ERR_IDENT_EXPECTED);
|
||||
ErrorSkip ("Identifier expected");
|
||||
return;
|
||||
}
|
||||
strcpy (Name, SVal);
|
||||
@ -602,7 +602,7 @@ static void DoDbg (void)
|
||||
|
||||
/* We expect a subkey */
|
||||
if (Tok != TOK_IDENT) {
|
||||
ErrorSkip (ERR_IDENT_EXPECTED);
|
||||
ErrorSkip ("Identifier expected");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -617,7 +617,7 @@ static void DoDbg (void)
|
||||
case 0: DbgInfoFile (); break;
|
||||
case 1: DbgInfoLine (); 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 */
|
||||
if (Tok != TOK_IDENT) {
|
||||
ErrorSkip (ERR_IDENT_EXPECTED);
|
||||
ErrorSkip ("Identifier expected");
|
||||
return;
|
||||
}
|
||||
strcpy (Name, SVal);
|
||||
@ -704,7 +704,7 @@ static void DoEndProc (void)
|
||||
SymLeaveLevel ();
|
||||
} else {
|
||||
/* No local scope */
|
||||
ErrorSkip (ERR_NO_OPEN_PROC);
|
||||
ErrorSkip ("No open lexical level");
|
||||
}
|
||||
}
|
||||
|
||||
@ -714,9 +714,9 @@ static void DoError (void)
|
||||
/* User error */
|
||||
{
|
||||
if (Tok != TOK_STRCON) {
|
||||
ErrorSkip (ERR_STRCON_EXPECTED);
|
||||
ErrorSkip ("String constant expected");
|
||||
} else {
|
||||
Error (ERR_USER, SVal);
|
||||
Error ("User error: %s", SVal);
|
||||
SkipUntilSep ();
|
||||
}
|
||||
}
|
||||
@ -775,7 +775,7 @@ static void DoFeature (void)
|
||||
|
||||
/* We expect an identifier */
|
||||
if (Tok != TOK_IDENT) {
|
||||
ErrorSkip (ERR_IDENT_EXPECTED);
|
||||
ErrorSkip ("Identifier expected");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -785,14 +785,14 @@ static void DoFeature (void)
|
||||
/* Set the feature and check for errors */
|
||||
if (SetFeature (SVal) == FEAT_UNKNOWN) {
|
||||
/* Not found */
|
||||
ErrorSkip (ERR_ILLEGAL_FEATURE);
|
||||
ErrorSkip ("Invalid feature: `%s'", SVal);
|
||||
return;
|
||||
} else {
|
||||
/* Skip the keyword */
|
||||
NextTok ();
|
||||
}
|
||||
|
||||
/* Allow more than one keyword */
|
||||
/* Allow more than one keyword */
|
||||
if (Tok == TOK_COMMA) {
|
||||
NextTok ();
|
||||
} else {
|
||||
@ -820,7 +820,7 @@ static void DoFileOpt (void)
|
||||
OptNum = GetSubKey (Keys, sizeof (Keys) / sizeof (Keys [0]));
|
||||
if (OptNum < 0) {
|
||||
/* Not found */
|
||||
ErrorSkip (ERR_OPTION_KEY_EXPECTED);
|
||||
ErrorSkip ("File option keyword expected");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -832,7 +832,7 @@ static void DoFileOpt (void)
|
||||
|
||||
/* We accept only string options for now */
|
||||
if (Tok != TOK_STRCON) {
|
||||
ErrorSkip (ERR_STRCON_EXPECTED);
|
||||
ErrorSkip ("String constant expected");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -867,7 +867,7 @@ static void DoFileOpt (void)
|
||||
/* Option given as number */
|
||||
OptNum = ConstExpression ();
|
||||
if (!IsByteRange (OptNum)) {
|
||||
ErrorSkip (ERR_RANGE);
|
||||
ErrorSkip ("Range error");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -876,7 +876,7 @@ static void DoFileOpt (void)
|
||||
|
||||
/* We accept only string options for now */
|
||||
if (Tok != TOK_STRCON) {
|
||||
ErrorSkip (ERR_STRCON_EXPECTED);
|
||||
ErrorSkip ("String constant expected");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -918,7 +918,7 @@ static void DoI16 (void)
|
||||
/* Switch the index registers to 16 bit mode (assembler only) */
|
||||
{
|
||||
if (GetCPU() != CPU_65816) {
|
||||
Error (ERR_816_MODE_ONLY);
|
||||
Error ("Command is only valid in 65816 mode");
|
||||
} else {
|
||||
/* Immidiate mode has two extension bytes */
|
||||
ExtBytes [AMI_IMM_INDEX] = 2;
|
||||
@ -931,7 +931,7 @@ static void DoI8 (void)
|
||||
/* Switch the index registers to 16 bit mode (assembler only) */
|
||||
{
|
||||
if (GetCPU() != CPU_65816) {
|
||||
Error (ERR_816_MODE_ONLY);
|
||||
Error ("Command is only valid in 65816 mode");
|
||||
} else {
|
||||
/* Immidiate mode has one extension byte */
|
||||
ExtBytes [AMI_IMM_INDEX] = 1;
|
||||
@ -967,7 +967,7 @@ static void DoIncBin (void)
|
||||
|
||||
/* Name must follow */
|
||||
if (Tok != TOK_STRCON) {
|
||||
ErrorSkip (ERR_STRCON_EXPECTED);
|
||||
ErrorSkip ("String constant expected");
|
||||
return;
|
||||
}
|
||||
strcpy (Name, SVal);
|
||||
@ -994,7 +994,7 @@ static void DoIncBin (void)
|
||||
char* PathName = FindInclude (Name);
|
||||
if (PathName == 0 || (F = fopen (PathName, "r")) == 0) {
|
||||
/* 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 */
|
||||
@ -1015,13 +1015,13 @@ static void DoIncBin (void)
|
||||
Count = Size - Start;
|
||||
if (Count < 0) {
|
||||
/* Nothing to read - flag this as a range error */
|
||||
ErrorSkip (ERR_RANGE);
|
||||
ErrorSkip ("Range error");
|
||||
goto Done;
|
||||
}
|
||||
} else {
|
||||
/* Count was given, check if it is valid */
|
||||
if (Start + Count > Size) {
|
||||
ErrorSkip (ERR_RANGE);
|
||||
ErrorSkip ("Range error");
|
||||
goto Done;
|
||||
}
|
||||
}
|
||||
@ -1041,7 +1041,8 @@ static void DoIncBin (void)
|
||||
size_t BytesRead = fread (Buf, 1, BytesToRead, F);
|
||||
if (BytesToRead != BytesRead) {
|
||||
/* Some sort of error */
|
||||
ErrorSkip (ERR_CANNOT_READ_INCLUDE, Name, strerror (errno));
|
||||
ErrorSkip ("Cannot read from include file `%s': %s",
|
||||
Name, strerror (errno));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1066,7 +1067,7 @@ static void DoInclude (void)
|
||||
|
||||
/* Name must follow */
|
||||
if (Tok != TOK_STRCON) {
|
||||
ErrorSkip (ERR_STRCON_EXPECTED);
|
||||
ErrorSkip ("String constant expected");
|
||||
} else {
|
||||
strcpy (Name, SVal);
|
||||
NextTok ();
|
||||
@ -1127,10 +1128,10 @@ static void DoLocalChar (void)
|
||||
/* Define the character that starts local labels */
|
||||
{
|
||||
if (Tok != TOK_CHARCON) {
|
||||
ErrorSkip (ERR_CHARCON_EXPECTED);
|
||||
ErrorSkip ("Character constant expected");
|
||||
} else {
|
||||
if (IVal != '@' && IVal != '?') {
|
||||
Error (ERR_ILLEGAL_LOCALSTART);
|
||||
Error ("Invalid start character for locals");
|
||||
} else {
|
||||
LocalStart = (char) IVal;
|
||||
}
|
||||
@ -1155,7 +1156,7 @@ static void DoMacPack (void)
|
||||
|
||||
/* We expect an identifier */
|
||||
if (Tok != TOK_IDENT) {
|
||||
ErrorSkip (ERR_IDENT_EXPECTED);
|
||||
ErrorSkip ("Identifier expected");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1163,7 +1164,7 @@ static void DoMacPack (void)
|
||||
Package = GetSubKey (Keys, sizeof (Keys) / sizeof (Keys [0]));
|
||||
if (Package < 0) {
|
||||
/* Not found */
|
||||
ErrorSkip (ERR_ILLEGAL_MACPACK);
|
||||
ErrorSkip ("Invalid macro package");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1197,7 +1198,7 @@ static void DoOrg (void)
|
||||
{
|
||||
long PC = ConstExpression ();
|
||||
if (PC < 0 || PC > 0xFFFFFF) {
|
||||
Error (ERR_RANGE);
|
||||
Error ("Range error");
|
||||
return;
|
||||
}
|
||||
SetAbsPC (PC);
|
||||
@ -1209,7 +1210,7 @@ static void DoOut (void)
|
||||
/* Output a string */
|
||||
{
|
||||
if (Tok != TOK_STRCON) {
|
||||
ErrorSkip (ERR_STRCON_EXPECTED);
|
||||
ErrorSkip ("String constant expected");
|
||||
} else {
|
||||
/* 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.
|
||||
@ -1261,7 +1262,7 @@ static void DoPopSeg (void)
|
||||
|
||||
/* Must have a segment on the stack */
|
||||
if (CollCount (&SegStack) == 0) {
|
||||
ErrorSkip (ERR_SEGSTACK_EMPTY);
|
||||
ErrorSkip ("Segment stack is empty");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1308,7 +1309,7 @@ static void DoProc (void)
|
||||
/* A .PROC statement without a name */
|
||||
char Buf[sizeof (SVal)];
|
||||
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 */
|
||||
if (CollCount (&SegStack) >= MAX_PUSHED_SEGMENTS) {
|
||||
ErrorSkip (ERR_SEGSTACK_OVERFLOW);
|
||||
ErrorSkip ("Segment stack overflow");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1362,7 +1363,7 @@ static void DoRes (void)
|
||||
|
||||
Count = ConstExpression ();
|
||||
if (Count > 0xFFFF || Count < 0) {
|
||||
ErrorSkip (ERR_RANGE);
|
||||
ErrorSkip ("Range error");
|
||||
return;
|
||||
}
|
||||
if (Tok == TOK_COMMA) {
|
||||
@ -1370,7 +1371,7 @@ static void DoRes (void)
|
||||
Val = ConstExpression ();
|
||||
/* We need a byte value here */
|
||||
if (!IsByteRange (Val)) {
|
||||
ErrorSkip (ERR_RANGE);
|
||||
ErrorSkip ("Range error");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1403,7 +1404,7 @@ static void DoSegment (void)
|
||||
Def.Name = Name;
|
||||
|
||||
if (Tok != TOK_STRCON) {
|
||||
ErrorSkip (ERR_STRCON_EXPECTED);
|
||||
ErrorSkip ("String constant expected");
|
||||
} else {
|
||||
|
||||
/* Save the name of the segment and skip it */
|
||||
@ -1425,7 +1426,7 @@ static void DoSetCPU (void)
|
||||
{
|
||||
/* We expect an identifier */
|
||||
if (Tok != TOK_STRCON) {
|
||||
ErrorSkip (ERR_STRCON_EXPECTED);
|
||||
ErrorSkip ("String constant expected");
|
||||
} else {
|
||||
/* Try to find the CPU, then skip the identifier */
|
||||
cpu_t CPU = FindCPU (SVal);
|
||||
@ -1449,7 +1450,7 @@ static void DoSmart (void)
|
||||
static void DoStruct (void)
|
||||
/* Struct definition */
|
||||
{
|
||||
Error (ERR_NOT_IMPLEMENTED);
|
||||
Error ("Not implemented");
|
||||
}
|
||||
|
||||
|
||||
@ -1465,7 +1466,7 @@ static void DoSunPlus (void)
|
||||
static void DoUnion (void)
|
||||
/* Union definition */
|
||||
{
|
||||
Error (ERR_NOT_IMPLEMENTED);
|
||||
Error ("Not implemented");
|
||||
}
|
||||
|
||||
|
||||
@ -1473,7 +1474,7 @@ static void DoUnion (void)
|
||||
static void DoUnexpected (void)
|
||||
/* Got an unexpected keyword */
|
||||
{
|
||||
Error (ERR_UNEXPECTED, Keyword);
|
||||
Error ("Unexpected `%s'", Keyword);
|
||||
SkipUntilSep ();
|
||||
}
|
||||
|
||||
@ -1483,9 +1484,9 @@ static void DoWarning (void)
|
||||
/* User warning */
|
||||
{
|
||||
if (Tok != TOK_STRCON) {
|
||||
ErrorSkip (ERR_STRCON_EXPECTED);
|
||||
ErrorSkip ("String constant expected");
|
||||
} else {
|
||||
Warning (WARN_USER, SVal);
|
||||
Warning (0, "User warning: %s", SVal);
|
||||
SkipUntilSep ();
|
||||
}
|
||||
}
|
||||
@ -1697,7 +1698,7 @@ void SegStackCheck (void)
|
||||
/* Check if the segment stack is empty at end of assembly */
|
||||
{
|
||||
if (CollCount (&SegStack) != 0) {
|
||||
Error (ERR_SEGSTACK_NOT_EMPTY);
|
||||
Error ("Segment stack is not empty");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ static TokList* CollectRepeatTokens (void)
|
||||
|
||||
/* Check for end of input */
|
||||
if (Tok == TOK_EOF) {
|
||||
Error (ERR_UNEXPECTED_EOF);
|
||||
Error ("Unexpected end of file");
|
||||
FreeTokList (List);
|
||||
return 0;
|
||||
}
|
||||
@ -127,7 +127,7 @@ void ParseRepeat (void)
|
||||
/* Repeat count follows */
|
||||
long RepCount = ConstExpression ();
|
||||
if (RepCount < 0) {
|
||||
Error (ERR_RANGE);
|
||||
Error ("Range error");
|
||||
RepCount = 0;
|
||||
}
|
||||
|
||||
@ -140,7 +140,7 @@ void ParseRepeat (void)
|
||||
|
||||
/* Check for an identifier */
|
||||
if (Tok != TOK_IDENT) {
|
||||
ErrorSkip (ERR_IDENT_EXPECTED);
|
||||
ErrorSkip ("Identifier expected");
|
||||
} else {
|
||||
/* Remember the name and skip it */
|
||||
Name = xstrdup (SVal);
|
||||
|
@ -7,7 +7,7 @@
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||
/* Römerstrasse 52 */
|
||||
/* Römerstraße 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
@ -307,7 +307,7 @@ void NewInputFile (const char* Name)
|
||||
|
||||
/* Error (fatal error if this is the main file) */
|
||||
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
|
||||
@ -316,7 +316,7 @@ void NewInputFile (const char* Name)
|
||||
PathName = FindInclude (Name);
|
||||
if (PathName == 0 || (F = fopen (PathName, "r")) == 0) {
|
||||
/* 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 */
|
||||
@ -332,7 +332,7 @@ void NewInputFile (const char* Name)
|
||||
/* Stat the file and remember the values */
|
||||
struct stat Buf;
|
||||
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 */
|
||||
@ -579,13 +579,13 @@ static unsigned ReadStringConst (int StringTerm)
|
||||
break;
|
||||
}
|
||||
if (C == '\n' || C == EOF) {
|
||||
Error (ERR_NEWLINE_IN_STRING);
|
||||
Error ("Newline in string constant");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Check for string length, print an error message once */
|
||||
if (I == MAX_STR_LEN) {
|
||||
Error (ERR_STRING_TOO_LONG);
|
||||
Error ("Maximum string size exceeded");
|
||||
} else if (I < MAX_STR_LEN) {
|
||||
SVal [I] = C;
|
||||
}
|
||||
@ -651,7 +651,7 @@ Again:
|
||||
Tok = TOK_PC;
|
||||
return;
|
||||
} else {
|
||||
Error (ERR_HEX_DIGIT_EXPECTED);
|
||||
Error ("Hexadecimal digit expected");
|
||||
}
|
||||
}
|
||||
|
||||
@ -659,7 +659,7 @@ Again:
|
||||
IVal = 0;
|
||||
while (IsXDigit (C)) {
|
||||
if (IVal & 0xF0000000) {
|
||||
Error (ERR_NUM_OVERFLOW);
|
||||
Error ("Overflow in hexadecimal number");
|
||||
IVal = 0;
|
||||
}
|
||||
IVal = (IVal << 4) + DigitVal (C);
|
||||
@ -677,14 +677,14 @@ Again:
|
||||
|
||||
/* 0 or 1 must follow */
|
||||
if (!IsBDigit (C)) {
|
||||
Error (ERR_01_EXPECTED);
|
||||
Error ("Binary digit expected");
|
||||
}
|
||||
|
||||
/* Read the number */
|
||||
IVal = 0;
|
||||
while (IsBDigit (C)) {
|
||||
if (IVal & 0x80000000) {
|
||||
Error (ERR_NUM_OVERFLOW);
|
||||
Error ("Overflow in binary number");
|
||||
IVal = 0;
|
||||
}
|
||||
IVal = (IVal << 1) + DigitVal (C);
|
||||
@ -703,7 +703,7 @@ Again:
|
||||
IVal = 0;
|
||||
while (IsDigit (C)) {
|
||||
if (IVal > (long) (0xFFFFFFFFUL / 10)) {
|
||||
Error (ERR_NUM_OVERFLOW);
|
||||
Error ("Overflow in decimal number");
|
||||
IVal = 0;
|
||||
}
|
||||
IVal = (IVal * 10) + DigitVal (C);
|
||||
@ -719,7 +719,6 @@ Again:
|
||||
if (C == '.') {
|
||||
|
||||
/* Remember and skip the dot */
|
||||
SVal[0] = C;
|
||||
NextChar ();
|
||||
|
||||
/* Check if it's just a dot */
|
||||
@ -731,6 +730,7 @@ Again:
|
||||
} else {
|
||||
|
||||
/* Read the remainder of the identifier */
|
||||
SVal[0] = '.';
|
||||
ReadIdent (1);
|
||||
|
||||
/* Dot keyword, search for it */
|
||||
@ -742,7 +742,7 @@ Again:
|
||||
Tok = TOK_IDENT;
|
||||
} else {
|
||||
/* Invalid pseudo instruction */
|
||||
Error (ERR_PSEUDO_EXPECTED);
|
||||
Error ("`%s' is not a recognized control command", SVal);
|
||||
goto Again;
|
||||
}
|
||||
}
|
||||
@ -759,7 +759,7 @@ Again:
|
||||
|
||||
/* Start character alone is not enough */
|
||||
if (SVal [1] == '\0') {
|
||||
Error (ERR_IDENT_EXPECTED);
|
||||
Error ("Invalid cheap local symbol");
|
||||
goto Again;
|
||||
}
|
||||
|
||||
@ -1024,14 +1024,14 @@ CharAgain:
|
||||
/* Always a character constant */
|
||||
NextChar ();
|
||||
if (C == '\n' || C == EOF) {
|
||||
Error (ERR_ILLEGAL_CHARCON);
|
||||
Error ("Illegal character constant");
|
||||
goto CharAgain;
|
||||
}
|
||||
IVal = C;
|
||||
Tok = TOK_CHARCON;
|
||||
NextChar ();
|
||||
if (C != '\'') {
|
||||
Error (ERR_ILLEGAL_CHARCON);
|
||||
Error ("Illegal character constant");
|
||||
} else {
|
||||
NextChar ();
|
||||
}
|
||||
@ -1082,7 +1082,7 @@ CharAgain:
|
||||
/* If we go here, we could not identify the current character. Skip it
|
||||
* and try again.
|
||||
*/
|
||||
Error (ERR_INVALID_CHAR, C & 0xFF);
|
||||
Error ("Invalid input character: 0x%02X", C & 0xFF);
|
||||
NextChar ();
|
||||
goto Again;
|
||||
}
|
||||
@ -1150,7 +1150,7 @@ unsigned ParseAddrSize (void)
|
||||
|
||||
/* Check for an identifier */
|
||||
if (Tok != TOK_IDENT) {
|
||||
Error (ERR_ADDR_SIZE_EXPECTED);
|
||||
Error ("Address size specifier expected");
|
||||
return ADDR_SIZE_DEFAULT;
|
||||
}
|
||||
|
||||
@ -1164,7 +1164,7 @@ unsigned ParseAddrSize (void)
|
||||
case 5: return ADDR_SIZE_ABS;
|
||||
case 6: return ADDR_SIZE_FAR;
|
||||
default:
|
||||
Error (ERR_ADDR_SIZE_EXPECTED);
|
||||
Error ("Address size specifier expected");
|
||||
return ADDR_SIZE_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||
/* Römerstrasse 52 */
|
||||
/* Römerstraße 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
@ -109,12 +109,12 @@ static Segment* NewSegment (const char* Name, unsigned AddrSize)
|
||||
|
||||
/* Check for too many segments */
|
||||
if (SegmentCount >= 256) {
|
||||
Fatal (FAT_TOO_MANY_SEGMENTS);
|
||||
Fatal ("Too many segments");
|
||||
}
|
||||
|
||||
/* Check the segment name for invalid names */
|
||||
if (!ValidSegName (Name)) {
|
||||
Error (ERR_ILLEGAL_SEGMENT, Name);
|
||||
Error ("Illegal segment name: `%s'", Name);
|
||||
}
|
||||
|
||||
/* Create a new segment */
|
||||
@ -186,7 +186,7 @@ void UseSeg (const SegDef* D)
|
||||
/* We found this segment. Check if the type is identical */
|
||||
if (D->AddrSize != ADDR_SIZE_DEFAULT &&
|
||||
Seg->Def->AddrSize != D->AddrSize) {
|
||||
Error (ERR_SEG_ATTR_MISMATCH);
|
||||
Error ("Segment attribute mismatch");
|
||||
/* Use the new attribute to avoid errors */
|
||||
Seg->Def->AddrSize = D->AddrSize;
|
||||
}
|
||||
@ -303,24 +303,24 @@ void SegCheck (void)
|
||||
if (Abs) {
|
||||
/* Absolute value */
|
||||
if (Val > 255) {
|
||||
PError (&F->Pos, ERR_RANGE);
|
||||
PError (&F->Pos, "Range error");
|
||||
}
|
||||
} else {
|
||||
/* PC relative value */
|
||||
if (Val < -128 || Val > 127) {
|
||||
PError (&F->Pos, ERR_RANGE);
|
||||
PError (&F->Pos, "Range error");
|
||||
}
|
||||
}
|
||||
} else if (F->Len == 2) {
|
||||
if (Abs) {
|
||||
/* Absolute value */
|
||||
if (Val > 65535) {
|
||||
PError (&F->Pos, ERR_RANGE);
|
||||
PError (&F->Pos, "Range error");
|
||||
}
|
||||
} else {
|
||||
/* PC relative value */
|
||||
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.
|
||||
*/
|
||||
if (F->Type == FRAG_EXPR && F->Len == 1 && !IsByteExpr (F->V.Expr)) {
|
||||
PError (&F->Pos, ERR_RANGE);
|
||||
PError (&F->Pos, "Range error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||
/* Römerstrasse 52 */
|
||||
/* Römerstraße 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
@ -76,7 +76,7 @@ SymEntry* ParseScopedSymName (int AllocNew)
|
||||
/* An identifier must follow. Remember and skip it. */
|
||||
char Name[sizeof (SVal)];
|
||||
if (Tok != TOK_IDENT) {
|
||||
Error (ERR_IDENT_EXPECTED);
|
||||
Error ("Identifier expected");
|
||||
return 0;
|
||||
}
|
||||
strcpy (Name, SVal);
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "scanner.h"
|
||||
#include "spool.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) {
|
||||
/* 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;
|
||||
}
|
||||
if (S->Flags & SF_DEFINED) {
|
||||
/* Multiple definition */
|
||||
Error (ERR_SYM_ALREADY_DEFINED, GetSymName (S));
|
||||
Error ("Symbol `%s' is already defined", GetSymName (S));
|
||||
S->Flags |= SF_MULTDEF;
|
||||
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 (S->Flags & SF_EXPORT) {
|
||||
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) {
|
||||
/* Already marked as ZP symbol by some means */
|
||||
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 */
|
||||
if (IsLocalNameId (S->Name)) {
|
||||
Error (ERR_ILLEGAL_LOCAL_USE);
|
||||
Error ("Illegal use of a local symbol");
|
||||
return;
|
||||
}
|
||||
|
||||
if (S->Flags & SF_DEFINED) {
|
||||
Error (ERR_SYM_ALREADY_DEFINED, GetSymName (S));
|
||||
Error ("Symbol `%s' is already defined", GetSymName (S));
|
||||
S->Flags |= SF_MULTDEF;
|
||||
return;
|
||||
}
|
||||
if (S->Flags & SF_EXPORT) {
|
||||
/* The symbol is already marked as exported symbol */
|
||||
Error (ERR_SYM_ALREADY_EXPORT, GetSymName (S));
|
||||
Error ("Cannot import exported symbol `%s'", GetSymName (S));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -233,7 +234,7 @@ void SymImport (SymEntry* S, unsigned AddrSize, unsigned Flags)
|
||||
if (S->Flags & (SF_IMPORT | SF_GLOBAL)) {
|
||||
if ((Flags & SF_FORCED) != (S->Flags & SF_FORCED) ||
|
||||
AddrSize != S->AddrSize) {
|
||||
Error (ERR_SYM_REDECL_MISMATCH, GetSymName (S));
|
||||
Error ("Redeclaration mismatch for symbol `%s'", GetSymName (S));
|
||||
}
|
||||
S->Flags &= ~SF_GLOBAL;
|
||||
}
|
||||
@ -250,14 +251,14 @@ void SymExport (SymEntry* S, unsigned AddrSize, unsigned Flags)
|
||||
{
|
||||
/* Don't accept local symbols */
|
||||
if (IsLocalNameId (S->Name)) {
|
||||
Error (ERR_ILLEGAL_LOCAL_USE);
|
||||
Error ("Illegal use of a local symbol");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check if it's ok to export the symbol */
|
||||
if (S->Flags & SF_IMPORT) {
|
||||
/* 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;
|
||||
}
|
||||
|
||||
@ -272,7 +273,7 @@ void SymExport (SymEntry* S, unsigned AddrSize, unsigned Flags)
|
||||
*/
|
||||
if (S->Flags & (SF_EXPORT | SF_GLOBAL)) {
|
||||
if (S->ExportSize != AddrSize) {
|
||||
Error (ERR_ADDR_SIZE_MISMATCH, GetSymName (S));
|
||||
Error ("Address size mismatch for symbol `%s'", GetSymName (S));
|
||||
}
|
||||
S->Flags &= ~SF_GLOBAL;
|
||||
}
|
||||
@ -283,7 +284,7 @@ void SymExport (SymEntry* S, unsigned AddrSize, unsigned Flags)
|
||||
*/
|
||||
if (S->Flags & SF_DEFINED) {
|
||||
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 */
|
||||
if (IsLocalNameId (S->Name)) {
|
||||
Error (ERR_ILLEGAL_LOCAL_USE);
|
||||
Error ("Illegal use of a local symbol");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -314,13 +315,13 @@ void SymGlobal (SymEntry* S, unsigned AddrSize, unsigned Flags)
|
||||
*/
|
||||
if (S->Flags & SF_IMPORT) {
|
||||
if (AddrSize != S->AddrSize) {
|
||||
Error (ERR_ADDR_SIZE_MISMATCH, GetSymName (S));
|
||||
Error ("Address size mismatch for symbol `%s'", GetSymName (S));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (S->Flags & SF_EXPORT) {
|
||||
if (AddrSize != S->ExportSize) {
|
||||
Error (ERR_ADDR_SIZE_MISMATCH, GetSymName (S));
|
||||
Error ("Address size mismatch for symbol `%s'", GetSymName (S));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -331,7 +332,7 @@ void SymGlobal (SymEntry* S, unsigned AddrSize, unsigned Flags)
|
||||
if (S->Flags & SF_DEFINED) {
|
||||
/* The symbol is defined, export it */
|
||||
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->ExportSize = AddrSize;
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "expr.h"
|
||||
#include "objfile.h"
|
||||
#include "scanner.h"
|
||||
#include "segment.h"
|
||||
#include "spool.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 */
|
||||
{
|
||||
/* 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->Right = 0;
|
||||
S->Childs = 0;
|
||||
S->AddrSize = AddrSize;
|
||||
S->Flags = ST_NONE;
|
||||
S->AddrSize = ADDR_SIZE_DEFAULT;
|
||||
S->Type = 0;
|
||||
S->Level = Level;
|
||||
S->TableSlots = Slots;
|
||||
@ -207,16 +209,22 @@ static int SearchSymTree (SymEntry* T, const char* Name, SymEntry** E)
|
||||
void SymEnterLevel (const char* ScopeName, unsigned AddrSize)
|
||||
/* Enter a new lexical level */
|
||||
{
|
||||
/* ### Check existing scope */
|
||||
|
||||
/* Map a default address size to something real */
|
||||
if (AddrSize == ADDR_SIZE_DEFAULT) {
|
||||
if (AddrSize == ADDR_SIZE_DEFAULT) {
|
||||
/* Use the segment address size */
|
||||
AddrSize = GetCurrentSegAddrSize ();
|
||||
}
|
||||
|
||||
/* Create the new table */
|
||||
CurrentScope = NewSymTable (CurrentScope, ScopeName);
|
||||
/* Search for an existing table/create a new one */
|
||||
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 */
|
||||
if (!SymLast) {
|
||||
/* No last global, so there's no local table */
|
||||
Error (ERR_ILLEGAL_LOCAL_USE);
|
||||
Error ("No preceeding global symbol");
|
||||
if (AllocNew) {
|
||||
return NewSymEntry (Name);
|
||||
} else {
|
||||
@ -385,7 +393,7 @@ void SymConDes (const char* Name, unsigned Type, unsigned Prio)
|
||||
|
||||
/* Don't accept local symbols */
|
||||
if (IsLocalName (Name)) {
|
||||
Error (ERR_ILLEGAL_LOCAL_USE);
|
||||
Error ("Illegal use of a local symbol");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -393,7 +401,7 @@ void SymConDes (const char* Name, unsigned Type, unsigned Prio)
|
||||
S = SymFind (CurrentScope, Name, SYM_ALLOC_NEW);
|
||||
if (S->Flags & SF_IMPORT) {
|
||||
/* The symbol is already marked as imported external symbol */
|
||||
Error (ERR_SYM_ALREADY_IMPORT, Name);
|
||||
Error ("Symbol `%s' is already an import", Name);
|
||||
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 */
|
||||
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
|
||||
@ -412,7 +420,7 @@ void SymConDes (const char* Name, unsigned Type, unsigned Prio)
|
||||
*/
|
||||
if (S->ConDesPrio[Type] != CD_PRIO_NONE) {
|
||||
if (S->ConDesPrio[Type] != Prio) {
|
||||
Error (ERR_SYM_REDECL_MISMATCH, Name);
|
||||
Error ("Redeclaration mismatch for symbol `%s'", Name);
|
||||
}
|
||||
}
|
||||
S->ConDesPrio[Type] = Prio;
|
||||
@ -527,7 +535,7 @@ static void SymCheckUndefined (SymEntry* S)
|
||||
if (S->Flags & SF_EXPORT) {
|
||||
if (Sym->Flags & SF_IMPORT) {
|
||||
/* 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);
|
||||
}
|
||||
@ -539,14 +547,15 @@ static void SymCheckUndefined (SymEntry* S)
|
||||
/* The symbol is definitely undefined */
|
||||
if (S->Flags & SF_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 {
|
||||
if (AutoImport) {
|
||||
/* Mark as import, will be indexed later */
|
||||
S->Flags |= SF_IMPORT;
|
||||
} else {
|
||||
/* 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;
|
||||
|
||||
/* Check for open lexical levels */
|
||||
/* Check for open scopes */
|
||||
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
|
||||
@ -601,12 +610,16 @@ void SymCheck (void)
|
||||
(S->Flags & SF_UNDEFMASK) != SF_UNDEFVAL) {
|
||||
if ((S->Flags & SF_DEFINED) != 0 && (S->Flags & SF_REFERENCED) == 0) {
|
||||
/* 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_REFERENCED | SF_FORCED)) == SF_NONE) {
|
||||
/* 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 {
|
||||
/* Give the import an index, count imports */
|
||||
S->Index = ImportCount++;
|
||||
|
@ -54,6 +54,10 @@
|
||||
|
||||
|
||||
|
||||
/* Symbol table flags */
|
||||
#define ST_NONE 0x00 /* No flags */
|
||||
#define ST_DEFINED 0x01 /* Scope has been defined */
|
||||
|
||||
/* A symbol table */
|
||||
typedef struct SymTable SymTable;
|
||||
struct SymTable {
|
||||
@ -61,6 +65,7 @@ struct SymTable {
|
||||
SymTable* Right; /* Pointer to greater entry */
|
||||
SymTable* Parent; /* Link to enclosing scope if any */
|
||||
SymTable* Childs; /* Pointer to child scopes */
|
||||
unsigned short Flags; /* Symbol table flags */
|
||||
unsigned char AddrSize; /* Address size */
|
||||
unsigned char Type; /* Type of the scope */
|
||||
unsigned Level; /* Lexical level */
|
||||
|
@ -7,7 +7,7 @@
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2000-2003 Ullrich von Bassewitz */
|
||||
/* Römerstrasse 52 */
|
||||
/* Römerstraße 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
@ -135,7 +135,7 @@ ExprNode* ULabRef (int Which)
|
||||
}
|
||||
if (L == 0) {
|
||||
/* Label does not exist */
|
||||
Error (ERR_UNDEFINED_LABEL);
|
||||
Error ("Undefined label");
|
||||
/* We must return something valid */
|
||||
return GenCurrentPC();
|
||||
} else {
|
||||
@ -216,7 +216,7 @@ void ULabCheck (void)
|
||||
if (ULabLastDef) {
|
||||
L = ULabLastDef->Next;
|
||||
while (L) {
|
||||
PError (&L->Pos, ERR_UNDEFINED_LABEL);
|
||||
PError (&L->Pos, "Undefined label");
|
||||
L = L->Next;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user