1
0
mirror of https://github.com/cc65/cc65.git synced 2025-02-05 20:31:53 +00:00

Add new feature "leading_dot_in_identifiers".

git-svn-id: svn://svn.cc65.org/cc65/trunk@1156 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2002-02-14 10:05:51 +00:00
parent 6126672784
commit 2d96df46f1
6 changed files with 213 additions and 196 deletions

View File

@ -146,7 +146,7 @@ void ErrorMsg (const FilePos* Pos, unsigned ErrNum, va_list ap)
"Character constant expected",
"Constant expression expected",
"Identifier expected",
"`.endmacro' expected",
"`.ENDMACRO' expected",
"Option key expected",
"`=' expected",
"Command is only valid in 65816 mode",

View File

@ -6,10 +6,10 @@
/* */
/* */
/* */
/* (C) 2000 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */
/* (C) 2000-2002 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
@ -55,6 +55,7 @@ static const char* FeatureKeys[FEAT_COUNT] = {
"loose_char_term",
"at_in_identifiers",
"dollar_in_identifiers",
"leading_dot_in_identifiers",
"pc_assignment",
};
@ -98,15 +99,16 @@ feature_t SetFeature (const char* Key)
/* Set the flags */
switch (Feature) {
case FEAT_DOLLAR_IS_PC: DollarIsPC = 1; break;
case FEAT_LABELS_WITHOUT_COLONS: NoColonLabels = 1; break;
case FEAT_LOOSE_STRING_TERM: LooseStringTerm= 1; break;
case FEAT_LOOSE_CHAR_TERM: LooseCharTerm = 1; break;
case FEAT_AT_IN_IDENTIFIERS: AtInIdents = 1; break;
case FEAT_DOLLAR_IN_IDENTIFIERS: DollarInIdents = 1; break;
case FEAT_PC_ASSIGNMENT: PCAssignment = 1; break;
default: /* Keep gcc silent */ break;
}
case FEAT_DOLLAR_IS_PC: DollarIsPC = 1; break;
case FEAT_LABELS_WITHOUT_COLONS: NoColonLabels = 1; break;
case FEAT_LOOSE_STRING_TERM: LooseStringTerm = 1; break;
case FEAT_LOOSE_CHAR_TERM: LooseCharTerm = 1; break;
case FEAT_AT_IN_IDENTIFIERS: AtInIdents = 1; break;
case FEAT_DOLLAR_IN_IDENTIFIERS: DollarInIdents = 1; break;
case FEAT_LEADING_DOT_IN_IDENTIFIERS: LeadingDotInIdents= 1; break;
case FEAT_PC_ASSIGNMENT: PCAssignment = 1; break;
default: /* Keep gcc silent */ break;
}
/* Return the value found */
return Feature;

View File

@ -6,10 +6,10 @@
/* */
/* */
/* */
/* (C) 2000 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */
/* (C) 2000-2002 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
@ -52,6 +52,7 @@ typedef enum {
FEAT_LOOSE_CHAR_TERM,
FEAT_AT_IN_IDENTIFIERS,
FEAT_DOLLAR_IN_IDENTIFIERS,
FEAT_LEADING_DOT_IN_IDENTIFIERS,
FEAT_PC_ASSIGNMENT,
/* Special value: Number of features available */

View File

@ -6,7 +6,7 @@
/* */
/* */
/* */
/* (C) 1998-2000 Ullrich von Bassewitz */
/* (C) 1998-2002 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */
@ -44,31 +44,32 @@
/* File names */
const char* InFile = 0; /* Name of input file */
const char* OutFile = 0; /* Name of output file */
const char* ListFile = 0; /* Name of listing file */
const char* InFile = 0; /* Name of input file */
const char* OutFile = 0; /* Name of output file */
const char* ListFile = 0; /* Name of listing file */
/* Default extensions */
const char ObjExt[] = ".o"; /* Default object extension */
const char ListExt[] = ".lst"; /* Default listing extension */
const char ObjExt[] = ".o";/* Default object extension */
const char ListExt[] = ".lst"; /* Default listing extension */
char LocalStart = '@'; /* This char starts local symbols */
char LocalStart = '@'; /* This char starts local symbols */
unsigned char IgnoreCase = 0; /* Ignore case on identifiers? */
unsigned char AutoImport = 0; /* Mark unresolveds as import */
unsigned char SmartMode = 0; /* Smart mode */
unsigned char DbgSyms = 0; /* Add debug symbols */
unsigned char Listing = 0; /* Create listing file */
unsigned char LineCont = 0; /* Allow line continuation */
unsigned char IgnoreCase = 0; /* Ignore case on identifiers? */
unsigned char AutoImport = 0; /* Mark unresolveds as import */
unsigned char SmartMode = 0; /* Smart mode */
unsigned char DbgSyms = 0; /* Add debug symbols */
unsigned char Listing = 0; /* Create listing file */
unsigned char LineCont = 0; /* Allow line continuation */
/* Emulation features */
unsigned char DollarIsPC = 0; /* Allow the $ symbol as current PC */
unsigned char NoColonLabels = 0; /* Allow labels without a colon */
unsigned char LooseStringTerm = 0; /* Allow ' as string terminator */
unsigned char LooseCharTerm = 0; /* Allow " for char constants */
unsigned char AtInIdents = 0; /* Allow '@' in identifiers */
unsigned char DollarInIdents = 0; /* Allow '$' in identifiers */
unsigned char PCAssignment = 0; /* Allow "* = $XXX" or "$ = $XXX" */
unsigned char DollarIsPC = 0; /* Allow the $ symbol as current PC */
unsigned char NoColonLabels = 0; /* Allow labels without a colon */
unsigned char LooseStringTerm = 0; /* Allow ' as string terminator */
unsigned char LooseCharTerm = 0; /* Allow " for char constants */
unsigned char AtInIdents = 0; /* Allow '@' in identifiers */
unsigned char DollarInIdents = 0; /* Allow '$' in identifiers */
unsigned char LeadingDotInIdents = 0; /* Allow '.' to start an identifier */
unsigned char PCAssignment = 0; /* Allow "* = $XXX" or "$ = $XXX" */

View File

@ -6,7 +6,7 @@
/* */
/* */
/* */
/* (C) 1998-2000 Ullrich von Bassewitz */
/* (C) 1998-2002 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */
@ -39,37 +39,38 @@
/*****************************************************************************/
/* Data */
/* Data */
/*****************************************************************************/
/* File names */
extern const char* InFile; /* Name of input file */
extern const char* OutFile; /* Name of output file */
extern const char* ListFile; /* Name of listing file */
extern const char* InFile; /* Name of input file */
extern const char* OutFile; /* Name of output file */
extern const char* ListFile; /* Name of listing file */
/* Default extensions */
extern const char ObjExt[]; /* Default object extension */
extern const char ListExt[]; /* Default listing extension */
extern const char ObjExt[]; /* Default object extension */
extern const char ListExt[]; /* Default listing extension */
extern char LocalStart; /* This char starts local symbols */
extern char LocalStart; /* This char starts local symbols */
extern unsigned char IgnoreCase; /* Ignore case on identifiers? */
extern unsigned char AutoImport; /* Mark unresolveds as import */
extern unsigned char SmartMode; /* Smart mode */
extern unsigned char DbgSyms; /* Add debug symbols */
extern unsigned char Listing; /* Create listing file */
extern unsigned char LineCont; /* Allow line continuation */
extern unsigned char IgnoreCase; /* Ignore case on identifiers? */
extern unsigned char AutoImport; /* Mark unresolveds as import */
extern unsigned char SmartMode; /* Smart mode */
extern unsigned char DbgSyms; /* Add debug symbols */
extern unsigned char Listing; /* Create listing file */
extern unsigned char LineCont; /* Allow line continuation */
/* Emulation features */
extern unsigned char DollarIsPC; /* Allow the $ symbol as current PC */
extern unsigned char NoColonLabels; /* Allow labels without a colon */
extern unsigned char LooseStringTerm;/* Allow ' as string terminator */
extern unsigned char LooseCharTerm; /* Allow " for char constants */
extern unsigned char AtInIdents; /* Allow '@' in identifiers */
extern unsigned char DollarInIdents; /* Allow '$' in identifiers */
extern unsigned char PCAssignment; /* Allow "* = $XXX" or "$ = $XXX" */
extern unsigned char DollarIsPC; /* Allow the $ symbol as current PC */
extern unsigned char NoColonLabels; /* Allow labels without a colon */
extern unsigned char LooseStringTerm; /* Allow ' as string terminator */
extern unsigned char LooseCharTerm; /* Allow " for char constants */
extern unsigned char AtInIdents; /* Allow '@' in identifiers */
extern unsigned char DollarInIdents; /* Allow '$' in identifiers */
extern unsigned char LeadingDotInIdents; /* Allow '.' to start an identifier */
extern unsigned char PCAssignment; /* Allow "* = $XXX" or "$ = $XXX" */

View File

@ -6,7 +6,7 @@
/* */
/* */
/* */
/* (C) 1998-2000 Ullrich von Bassewitz */
/* (C) 1998-2002 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */
@ -117,121 +117,121 @@ struct DotKeyword {
const char* Key; /* MUST be first field */
enum Token Tok;
} DotKeywords [] = {
{ "A16", TOK_A16 },
{ "A8", TOK_A8 },
{ "ADDR", TOK_ADDR },
{ "ALIGN", TOK_ALIGN },
{ "AND", TOK_BAND },
{ "ASCIIZ", TOK_ASCIIZ },
{ "AUTOIMPORT", TOK_AUTOIMPORT },
{ "BITAND", TOK_AND },
{ "BITNOT", TOK_NOT },
{ "BITOR", TOK_OR },
{ "BITXOR", TOK_XOR },
{ "BLANK", TOK_BLANK },
{ "BSS", TOK_BSS },
{ "BYT", TOK_BYTE },
{ "BYTE", TOK_BYTE },
{ "CASE", TOK_CASE },
{ "CODE", TOK_CODE },
{ "CONCAT", TOK_CONCAT },
{ "CONDES", TOK_CONDES },
{ "CONST", TOK_CONST },
{ "CONSTRUCTOR", TOK_CONSTRUCTOR },
{ "CPU", TOK_CPU },
{ "DATA", TOK_DATA },
{ "DBG", TOK_DBG },
{ "DBYT", TOK_DBYT },
{ "DEBUGINFO", TOK_DEBUGINFO },
{ "DEF", TOK_DEFINED },
{ "DEFINE", TOK_DEFINE },
{ "DEFINED", TOK_DEFINED },
{ "DESTRUCTOR", TOK_DESTRUCTOR },
{ "DWORD", TOK_DWORD },
{ "ELSE", TOK_ELSE },
{ "ELSEIF", TOK_ELSEIF },
{ "END", TOK_END },
{ "ENDIF", TOK_ENDIF },
{ "ENDMAC", TOK_ENDMACRO },
{ "ENDMACRO", TOK_ENDMACRO },
{ "ENDPROC", TOK_ENDPROC },
{ "ENDREP", TOK_ENDREP },
{ "ENDREPEAT", TOK_ENDREP },
{ "ERROR", TOK_ERROR },
{ "EXITMAC", TOK_EXITMACRO },
{ "EXITMACRO", TOK_EXITMACRO },
{ "EXPORT", TOK_EXPORT },
{ "EXPORTZP", TOK_EXPORTZP },
{ "FARADDR", TOK_FARADDR },
{ "FEATURE", TOK_FEATURE },
{ "FILEOPT", TOK_FILEOPT },
{ "FOPT", TOK_FILEOPT },
{ "FORCEWORD", TOK_FORCEWORD },
{ "GLOBAL", TOK_GLOBAL },
{ "GLOBALZP", TOK_GLOBALZP },
{ "I16", TOK_I16 },
{ "I8", TOK_I8 },
{ "IF", TOK_IF },
{ "IFBLANK", TOK_IFBLANK },
{ "IFCONST", TOK_IFCONST },
{ "IFDEF", TOK_IFDEF },
{ "IFNBLANK", TOK_IFNBLANK },
{ "IFNCONST", TOK_IFNCONST },
{ "IFNDEF", TOK_IFNDEF },
{ "IFNREF", TOK_IFNREF },
{ "IFP02", TOK_IFP02 },
{ "IFP816", TOK_IFP816 },
{ "IFPC02", TOK_IFPC02 },
{ "IFREF", TOK_IFREF },
{ "IMPORT", TOK_IMPORT },
{ "IMPORTZP", TOK_IMPORTZP },
{ "INCBIN", TOK_INCBIN },
{ "INCLUDE", TOK_INCLUDE },
{ "LEFT", TOK_LEFT },
{ "LINECONT", TOK_LINECONT },
{ "LIST", TOK_LIST },
{ "LISTBYTES", TOK_LISTBYTES },
{ "LOCAL", TOK_LOCAL },
{ "LOCALCHAR", TOK_LOCALCHAR },
{ "MAC", TOK_MACRO },
{ "MACPACK", TOK_MACPACK },
{ "MACRO", TOK_MACRO },
{ "MATCH", TOK_MATCH },
{ "MID", TOK_MID },
{ "MOD", TOK_MOD },
{ "NOT", TOK_BNOT },
{ "NULL", TOK_NULL },
{ "OR", TOK_BOR },
{ "ORG", TOK_ORG },
{ "OUT", TOK_OUT },
{ "P02", TOK_P02 },
{ "P816", TOK_P816 },
{ "PAGELEN", TOK_PAGELENGTH },
{ "PAGELENGTH", TOK_PAGELENGTH },
{ "PARAMCOUNT", TOK_PARAMCOUNT },
{ "PC02", TOK_PC02 },
{ "PROC", TOK_PROC },
{ "REF", TOK_REFERENCED },
{ "REFERENCED", TOK_REFERENCED },
{ "RELOC", TOK_RELOC },
{ "REPEAT", TOK_REPEAT },
{ "RES", TOK_RES },
{ "RIGHT", TOK_RIGHT },
{ "RODATA", TOK_RODATA },
{ "SEGMENT", TOK_SEGMENT },
{ "SHL", TOK_SHL },
{ "SHR", TOK_SHR },
{ "SMART", TOK_SMART },
{ "STRAT", TOK_STRAT },
{ "STRING", TOK_STRING },
{ "STRLEN", TOK_STRLEN },
{ "SUNPLUS", TOK_SUNPLUS },
{ "TCOUNT", TOK_TCOUNT },
{ "WARNING", TOK_WARNING },
{ "WORD", TOK_WORD },
{ "XMATCH", TOK_XMATCH },
{ "XOR", TOK_BXOR },
{ "ZEROPAGE", TOK_ZEROPAGE },
{ ".A16", TOK_A16 },
{ ".A8", TOK_A8 },
{ ".ADDR", TOK_ADDR },
{ ".ALIGN", TOK_ALIGN },
{ ".AND", TOK_BAND },
{ ".ASCIIZ", TOK_ASCIIZ },
{ ".AUTOIMPORT", TOK_AUTOIMPORT },
{ ".BITAND", TOK_AND },
{ ".BITNOT", TOK_NOT },
{ ".BITOR", TOK_OR },
{ ".BITXOR", TOK_XOR },
{ ".BLANK", TOK_BLANK },
{ ".BSS", TOK_BSS },
{ ".BYT", TOK_BYTE },
{ ".BYTE", TOK_BYTE },
{ ".CASE", TOK_CASE },
{ ".CODE", TOK_CODE },
{ ".CONCAT", TOK_CONCAT },
{ ".CONDES", TOK_CONDES },
{ ".CONST", TOK_CONST },
{ ".CONSTRUCTOR", TOK_CONSTRUCTOR },
{ ".CPU", TOK_CPU },
{ ".DATA", TOK_DATA },
{ ".DBG", TOK_DBG },
{ ".DBYT", TOK_DBYT },
{ ".DEBUGINFO", TOK_DEBUGINFO },
{ ".DEF", TOK_DEFINED },
{ ".DEFINE", TOK_DEFINE },
{ ".DEFINED", TOK_DEFINED },
{ ".DESTRUCTOR", TOK_DESTRUCTOR },
{ ".DWORD", TOK_DWORD },
{ ".ELSE", TOK_ELSE },
{ ".ELSEIF", TOK_ELSEIF },
{ ".END", TOK_END },
{ ".ENDIF", TOK_ENDIF },
{ ".ENDMAC", TOK_ENDMACRO },
{ ".ENDMACRO", TOK_ENDMACRO },
{ ".ENDPROC", TOK_ENDPROC },
{ ".ENDREP", TOK_ENDREP },
{ ".ENDREPEAT", TOK_ENDREP },
{ ".ERROR", TOK_ERROR },
{ ".EXITMAC", TOK_EXITMACRO },
{ ".EXITMACRO", TOK_EXITMACRO },
{ ".EXPORT", TOK_EXPORT },
{ ".EXPORTZP", TOK_EXPORTZP },
{ ".FARADDR", TOK_FARADDR },
{ ".FEATURE", TOK_FEATURE },
{ ".FILEOPT", TOK_FILEOPT },
{ ".FOPT", TOK_FILEOPT },
{ ".FORCEWORD", TOK_FORCEWORD },
{ ".GLOBAL", TOK_GLOBAL },
{ ".GLOBALZP", TOK_GLOBALZP },
{ ".I16", TOK_I16 },
{ ".I8", TOK_I8 },
{ ".IF", TOK_IF },
{ ".IFBLANK", TOK_IFBLANK },
{ ".IFCONST", TOK_IFCONST },
{ ".IFDEF", TOK_IFDEF },
{ ".IFNBLANK", TOK_IFNBLANK },
{ ".IFNCONST", TOK_IFNCONST },
{ ".IFNDEF", TOK_IFNDEF },
{ ".IFNREF", TOK_IFNREF },
{ ".IFP02", TOK_IFP02 },
{ ".IFP816", TOK_IFP816 },
{ ".IFPC02", TOK_IFPC02 },
{ ".IFREF", TOK_IFREF },
{ ".IMPORT", TOK_IMPORT },
{ ".IMPORTZP", TOK_IMPORTZP },
{ ".INCBIN", TOK_INCBIN },
{ ".INCLUDE", TOK_INCLUDE },
{ ".LEFT", TOK_LEFT },
{ ".LINECONT", TOK_LINECONT },
{ ".LIST", TOK_LIST },
{ ".LISTBYTES", TOK_LISTBYTES },
{ ".LOCAL", TOK_LOCAL },
{ ".LOCALCHAR", TOK_LOCALCHAR },
{ ".MAC", TOK_MACRO },
{ ".MACPACK", TOK_MACPACK },
{ ".MACRO", TOK_MACRO },
{ ".MATCH", TOK_MATCH },
{ ".MID", TOK_MID },
{ ".MOD", TOK_MOD },
{ ".NOT", TOK_BNOT },
{ ".NULL", TOK_NULL },
{ ".OR", TOK_BOR },
{ ".ORG", TOK_ORG },
{ ".OUT", TOK_OUT },
{ ".P02", TOK_P02 },
{ ".P816", TOK_P816 },
{ ".PAGELEN", TOK_PAGELENGTH },
{ ".PAGELENGTH", TOK_PAGELENGTH },
{ ".PARAMCOUNT", TOK_PARAMCOUNT },
{ ".PC02", TOK_PC02 },
{ ".PROC", TOK_PROC },
{ ".REF", TOK_REFERENCED },
{ ".REFERENCED", TOK_REFERENCED },
{ ".RELOC", TOK_RELOC },
{ ".REPEAT", TOK_REPEAT },
{ ".RES", TOK_RES },
{ ".RIGHT", TOK_RIGHT },
{ ".RODATA", TOK_RODATA },
{ ".SEGMENT", TOK_SEGMENT },
{ ".SHL", TOK_SHL },
{ ".SHR", TOK_SHR },
{ ".SMART", TOK_SMART },
{ ".STRAT", TOK_STRAT },
{ ".STRING", TOK_STRING },
{ ".STRLEN", TOK_STRLEN },
{ ".SUNPLUS", TOK_SUNPLUS },
{ ".TCOUNT", TOK_TCOUNT },
{ ".WARNING", TOK_WARNING },
{ ".WORD", TOK_WORD },
{ ".XMATCH", TOK_XMATCH },
{ ".XOR", TOK_BXOR },
{ ".ZEROPAGE", TOK_ZEROPAGE },
};
@ -524,20 +524,20 @@ static unsigned char FindDotKeyword (void)
static void ReadIdent (void)
/* Read an identifier from the current input position into Ident. It is
* assumed that the first character has already been checked.
static void ReadIdent (unsigned Index)
/* Read an identifier from the current input position into Ident. Filling SVal
* starts at Index with the current character in C. It is assumed that any
* characters already filled in are ok, and the character in C is checked.
*/
{
/* Read the identifier */
unsigned I = 0;
do {
if (I < MAX_STR_LEN) {
SVal [I++] = C;
if (Index < MAX_STR_LEN) {
SVal [Index++] = C;
}
NextChar ();
} while (IsIdChar (C));
SVal [I] = '\0';
SVal [Index] = '\0';
/* If we should ignore case, convert the identifier to upper case */
if (IgnoreCase) {
@ -656,7 +656,7 @@ Again:
return;
}
/* Dual number? */
/* Binary number? */
if (C == '%') {
NextChar ();
@ -703,23 +703,35 @@ Again:
/* Control command? */
if (C == '.') {
/* Remember and skip the dot */
SVal[0] = C;
NextChar ();
if (!IsIdStart (C)) {
/* Check if it's just a dot */
if (!IsIdStart (C)) {
/* Just a dot */
Tok = TOK_DOT;
return;
}
/* Read the identifier */
ReadIdent ();
} else {
/* Read the remainder of the identifier */
ReadIdent (1);
/* Dot keyword, search for it */
Tok = FindDotKeyword ();
if (Tok == TOK_NONE) {
/* Not found */
if (LeadingDotInIdents) {
/* An identifier with a dot */
Tok = TOK_IDENT;
} else {
/* Invalid pseudo instruction */
Error (ERR_PSEUDO_EXPECTED);
goto Again;
}
}
/* Search the keyword */
Tok = FindDotKeyword ();
if (Tok == TOK_NONE) {
/* Not found */
Error (ERR_PSEUDO_EXPECTED);
goto Again;
}
return;
}
@ -728,7 +740,7 @@ Again:
if (C == LocalStart) {
/* Read the identifier */
ReadIdent ();
ReadIdent (0);
/* Start character alone is not enough */
if (SVal [1] == '\0') {
@ -746,7 +758,7 @@ Again:
if (IsIdStart (C)) {
/* Read the identifier */
ReadIdent ();
ReadIdent (0);
/* Check for special names */
if (SVal [1] == '\0') {