/* */
/* */
/* */
-/* (C) 2000-2010, Ullrich von Bassewitz */
+/* (C) 2000-2011, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
/* */
-/* (C) 1998-2010, Ullrich von Bassewitz */
+/* (C) 1998-2011, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* We have a list of tokens that ends with the closing paren. Skip
* the tokens, and count them. Allow optionally curly braces.
*/
- Token Term = GetTokListTerm (TOK_RPAREN);
+ token_t Term = GetTokListTerm (TOK_RPAREN);
unsigned Count = 0;
while (Tok != Term) {
* single linked list of tokens including attributes. The list is
* either enclosed in curly braces, or terminated by a comma.
*/
- Token Term = GetTokListTerm (TOK_COMMA);
+ token_t Term = GetTokListTerm (TOK_COMMA);
while (Tok != Term) {
/* We may not end-of-line of end-of-file here */
/* We have a list of tokens that ends with the closing paren. Skip
* the tokens, and count them. Allow optionally curly braces.
*/
- Token Term = GetTokListTerm (TOK_RPAREN);
+ token_t Term = GetTokListTerm (TOK_RPAREN);
int Count = 0;
while (Tok != Term) {
ExprNode* Right;
/* Remember the token and skip it */
- Token T = Tok;
+ token_t T = Tok;
NextTok ();
/* Move root to left side and read the right side */
ExprNode* Right;
/* Remember the token and skip it */
- Token T = Tok;
+ token_t T = Tok;
NextTok ();
/* Move root to left side and read the right side */
ExprNode* Right;
/* Remember the token and skip it */
- Token T = Tok;
+ token_t T = Tok;
NextTok ();
/* Move root to left side and read the right side */
ExprNode* Right;
/* Remember the token and skip it */
- Token T = Tok;
+ token_t T = Tok;
NextTok ();
/* Move root to left side and read the right side */
ExprNode* Right;
/* Remember the token and skip it */
- Token T = Tok;
+ token_t T = Tok;
NextTok ();
/* Move root to left side and read the right side */
/* Start expanding the classic macro M */
{
MacExp* E;
- Token Term;
+ token_t Term;
/* Skip the macro name */
TokNode* Last;
/* The macro may optionally be enclosed in curly braces */
- Token Term = GetTokListTerm (TOK_COMMA);
+ token_t Term = GetTokListTerm (TOK_COMMA);
/* Check if there is really a parameter */
if (TokIsSep (Tok) || Tok == Term) {
/* */
/* */
/* */
-/* (C) 2000-2010, Ullrich von Bassewitz */
+/* (C) 2000-2011, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
TokList* List = NewTokList ();
/* Determine if the list is enclosed in curly braces. */
- Token Term = GetTokListTerm (TOK_RPAREN);
+ token_t Term = GetTokListTerm (TOK_RPAREN);
/* Read the token list */
unsigned Current = 0;
/* Handle the .IDENT function */
{
StrBuf Buf = STATIC_STRBUF_INITIALIZER;
- Token Id;
+ token_t Id;
unsigned I;
/* Skip it */
-void Consume (Token Expected, const char* ErrMsg)
+void Consume (token_t Expected, const char* ErrMsg)
/* Consume Expected, print an error if we don't find it */
{
if (Tok == Expected) {
/* */
/* */
/* */
-/* (C) 2000-2007 Ullrich von Bassewitz */
-/* Roemerstrasse 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 2000-2011, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
void NextTok (void);
/* Get next token and handle token level functions */
-void Consume (Token Expected, const char* ErrMsg);
+void Consume (token_t Expected, const char* ErrMsg);
/* Consume Token, print an error if we don't find it */
void ConsumeSep (void);
-Token Tok = TOK_NONE; /* Current token */
+token_t Tok = TOK_NONE; /* Current token */
int WS; /* Flag: Whitespace before token */
long IVal; /* Integer token attribute */
StrBuf SVal = STATIC_STRBUF_INITIALIZER;/* String token attribute */
-FilePos CurPos = { 0, 0, 0 }; /* Name and position in current file */
+FilePos CurPos = STATIC_FILEPOS_INITIALIZER; /* Name and position in current file */
struct InputFile {
FILE* F; /* Input file descriptor */
FilePos Pos; /* Position in file */
- Token Tok; /* Last token */
+ token_t Tok; /* Last token */
int C; /* Last character */
char Line[256]; /* The current input line */
int IncSearchPath; /* True if we've added a search path */
char* Text; /* Pointer to the text data */
const char* Pos; /* Pointer to current position */
int Malloced; /* Memory was malloced */
- Token Tok; /* Last token */
+ token_t Tok; /* Last token */
int C; /* Last character */
InputData* Next; /* Linked list of input data */
};
/* Input source: Either file or data */
struct CharSource {
CharSource* Next; /* Linked list of char sources */
- Token Tok; /* Last token */
+ token_t Tok; /* Last token */
int C; /* Last character */
const CharSourceFunctions* Func; /* Pointer to function table */
union {
/* List of dot keywords with the corresponding tokens */
struct DotKeyword {
const char* Key; /* MUST be first field */
- Token Tok;
+ token_t Tok;
} DotKeywords [] = {
{ ".A16", TOK_A16 },
{ ".A8", TOK_A8 },
/* */
/* */
/* */
-/* (C) 1998-2007 Ullrich von Bassewitz */
-/* Roemerstrasse 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 1998-2011, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/* Scanner variables */
-extern Token Tok; /* Current token */
+extern token_t Tok; /* Current token */
extern int WS; /* Flag: Whitespace before token */
extern long IVal; /* Integer token attribute */
extern StrBuf SVal; /* String token attribute */
/* */
/* */
/* */
-/* (C) 2007 Ullrich von Bassewitz */
-/* Roemerstrasse 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 2007-2011, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
-int TokHasSVal (Token Tok)
+int TokHasSVal (token_t Tok)
/* Return true if the given token has an attached SVal */
{
return (Tok == TOK_IDENT || Tok == TOK_LOCAL_IDENT || Tok == TOK_STRCON);
-int TokHasIVal (Token Tok)
+int TokHasIVal (token_t Tok)
/* Return true if the given token has an attached IVal */
{
return (Tok == TOK_INTCON || Tok == TOK_CHARCON || Tok == TOK_REG);
-/* Tokens */
-typedef enum Token {
+/* Tokens */
+typedef enum token_t {
TOK_NONE, /* Start value, invalid */
TOK_EOF, /* End of input file */
TOK_SEP, /* Separator (usually newline) */
TOK_LASTPSEUDO = TOK_ZEROPAGE,
TOK_COUNT /* Count of tokens */
-} Token;
+} token_t;
-int TokHasSVal (Token Tok);
+int TokHasSVal (token_t Tok);
/* Return true if the given token has an attached SVal */
-int TokHasIVal (Token Tok);
+int TokHasIVal (token_t Tok);
/* Return true if the given token has an attached IVal */
#if defined(HAVE_INLINE)
-INLINE int TokIsSep (enum Token T)
+INLINE int TokIsSep (enum token_t T)
/* Return true if this is a separator token */
{
return (T == TOK_SEP || T == TOK_EOF);
/* */
/* */
/* */
-/* (C) 1998-2010, Ullrich von Bassewitz */
+/* (C) 1998-2011, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
-enum Token GetTokListTerm (enum Token Term)
+enum token_t GetTokListTerm (enum token_t Term)
/* Determine if the following token list is enclosed in curly braces. This is
* the case if the next token is the opening brace. If so, skip it and return
* a closing brace, otherwise return Term.
/* */
/* */
/* */
-/* (C) 2000-2008, Ullrich von Bassewitz */
+/* (C) 2000-2011, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
typedef struct TokNode TokNode;
struct TokNode {
TokNode* Next; /* For single linked list */
- Token Tok; /* Token value */
+ token_t Tok; /* Token value */
int WS; /* Whitespace before token? */
long IVal; /* Integer token attribute */
StrBuf SVal; /* String attribute, dyn. allocated */
void FreeTokList (TokList* T);
/* Delete the token list including all token nodes */
-Token GetTokListTerm (Token Term);
+token_t GetTokListTerm (token_t Term);
/* Determine if the following token list is enclosed in curly braces. This is
* the case if the next token is the opening brace. If so, skip it and return
* a closing brace, otherwise return Term.