2000-05-28 13:40:48 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* */
|
2013-05-09 11:56:54 +00:00
|
|
|
/* scanner.h */
|
2000-05-28 13:40:48 +00:00
|
|
|
/* */
|
2013-05-09 11:56:54 +00:00
|
|
|
/* The scanner for the ca65 macroassembler */
|
2000-05-28 13:40:48 +00:00
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* */
|
2011-01-16 14:51:13 +00:00
|
|
|
/* (C) 1998-2011, Ullrich von Bassewitz */
|
|
|
|
/* Roemerstrasse 52 */
|
|
|
|
/* D-70794 Filderstadt */
|
|
|
|
/* EMail: uz@cc65.org */
|
2000-05-28 13:40:48 +00:00
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* This software is provided 'as-is', without any expressed or implied */
|
|
|
|
/* warranty. In no event will the authors be held liable for any damages */
|
|
|
|
/* arising from the use of this software. */
|
|
|
|
/* */
|
|
|
|
/* Permission is granted to anyone to use this software for any purpose, */
|
|
|
|
/* including commercial applications, and to alter it and redistribute it */
|
|
|
|
/* freely, subject to the following restrictions: */
|
|
|
|
/* */
|
|
|
|
/* 1. The origin of this software must not be misrepresented; you must not */
|
|
|
|
/* claim that you wrote the original software. If you use this software */
|
|
|
|
/* in a product, an acknowledgment in the product documentation would be */
|
|
|
|
/* appreciated but is not required. */
|
|
|
|
/* 2. Altered source versions must be plainly marked as such, and must not */
|
|
|
|
/* be misrepresented as being the original software. */
|
|
|
|
/* 3. This notice may not be removed or altered from any source */
|
|
|
|
/* distribution. */
|
|
|
|
/* */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef SCANNER_H
|
|
|
|
#define SCANNER_H
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-08-27 20:39:02 +00:00
|
|
|
/* ca65 */
|
|
|
|
#include "token.h"
|
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2013-05-09 11:56:54 +00:00
|
|
|
/* Data */
|
2000-05-28 13:40:48 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Scanner variables */
|
2011-01-16 16:05:43 +00:00
|
|
|
extern Token CurTok; /* Current input token incl. attributes */
|
2013-05-09 11:56:54 +00:00
|
|
|
extern int ForcedEnd; /* Force end of assembly */
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2013-05-09 11:56:54 +00:00
|
|
|
/* Code */
|
2000-05-28 13:40:48 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
2003-06-06 12:45:19 +00:00
|
|
|
|
2005-05-09 18:57:03 +00:00
|
|
|
int IsIdChar (int C);
|
|
|
|
/* Return true if the character is a valid character for an identifier */
|
|
|
|
|
|
|
|
int IsIdStart (int C);
|
|
|
|
/* Return true if the character may start an identifier */
|
|
|
|
|
2009-01-18 15:07:55 +00:00
|
|
|
int NewInputFile (const char* Name);
|
|
|
|
/* Open a new input file. Returns true if the file could be successfully opened
|
|
|
|
* and false otherwise.
|
|
|
|
*/
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2007-08-27 20:39:02 +00:00
|
|
|
void NewInputData (char* Text, int Malloced);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Add a chunk of input data to the input stream */
|
|
|
|
|
2000-09-02 11:35:22 +00:00
|
|
|
void LocaseSVal (void);
|
|
|
|
/* Make SVal lower case */
|
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
void UpcaseSVal (void);
|
|
|
|
/* Make SVal upper case */
|
|
|
|
|
2000-06-03 11:15:11 +00:00
|
|
|
void NextRawTok (void);
|
|
|
|
/* Read the next raw token from the input stream */
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
int GetSubKey (const char** Keys, unsigned Count);
|
|
|
|
/* Search for a subkey in a table of keywords. The current token must be an
|
|
|
|
* identifier and all keys must be in upper case. The identifier will be
|
|
|
|
* uppercased in the process. The function returns the index of the keyword,
|
|
|
|
* or -1 if the keyword was not found.
|
|
|
|
*/
|
|
|
|
|
2003-11-13 00:21:31 +00:00
|
|
|
unsigned char ParseAddrSize (void);
|
2003-11-07 19:28:37 +00:00
|
|
|
/* Check if the next token is a keyword that denotes an address size specifier.
|
|
|
|
* If so, return the corresponding address size constant, otherwise output an
|
|
|
|
* error message and return ADDR_SIZE_DEFAULT.
|
|
|
|
*/
|
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
void InitScanner (const char* InFile);
|
|
|
|
/* Initialize the scanner, open the given input file */
|
|
|
|
|
|
|
|
void DoneScanner (void);
|
|
|
|
/* Release scanner resources */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* End of scanner.h */
|
|
|
|
|
|
|
|
#endif
|