1 /*****************************************************************************/
5 /* The scanner for the ca65 macroassembler */
9 /* (C) 1998-2007 Ullrich von Bassewitz */
10 /* Roemerstrasse 52 */
11 /* D-70794 Filderstadt */
12 /* EMail: uz@cc65.org */
15 /* This software is provided 'as-is', without any expressed or implied */
16 /* warranty. In no event will the authors be held liable for any damages */
17 /* arising from the use of this software. */
19 /* Permission is granted to anyone to use this software for any purpose, */
20 /* including commercial applications, and to alter it and redistribute it */
21 /* freely, subject to the following restrictions: */
23 /* 1. The origin of this software must not be misrepresented; you must not */
24 /* claim that you wrote the original software. If you use this software */
25 /* in a product, an acknowledgment in the product documentation would be */
26 /* appreciated but is not required. */
27 /* 2. Altered source versions must be plainly marked as such, and must not */
28 /* be misrepresented as being the original software. */
29 /* 3. This notice may not be removed or altered from any source */
32 /*****************************************************************************/
50 /*****************************************************************************/
52 /*****************************************************************************/
56 /* Scanner variables */
57 #define MAX_INPUT_FILES 254 /* No more than this files total */
58 #define MAX_STR_LEN 255 /* Maximum length of any string */
59 extern Token Tok; /* Current token */
60 extern int WS; /* Flag: Whitespace before token */
61 extern long IVal; /* Integer token attribute */
62 extern StrBuf SVal; /* String token attribute */
64 extern FilePos CurPos; /* Name and position in file */
65 extern int ForcedEnd; /* Force end of assembly */
69 /*****************************************************************************/
71 /*****************************************************************************/
76 /* Return true if the character is a valid character for an identifier */
78 int IsIdStart (int C);
79 /* Return true if the character may start an identifier */
81 int NewInputFile (const char* Name);
82 /* Open a new input file. Returns true if the file could be successfully opened
83 * and false otherwise.
86 void NewInputData (char* Text, int Malloced);
87 /* Add a chunk of input data to the input stream */
89 void LocaseSVal (void);
90 /* Make SVal lower case */
92 void UpcaseSVal (void);
93 /* Make SVal upper case */
95 void NextRawTok (void);
96 /* Read the next raw token from the input stream */
98 int GetSubKey (const char** Keys, unsigned Count);
99 /* Search for a subkey in a table of keywords. The current token must be an
100 * identifier and all keys must be in upper case. The identifier will be
101 * uppercased in the process. The function returns the index of the keyword,
102 * or -1 if the keyword was not found.
105 unsigned char ParseAddrSize (void);
106 /* Check if the next token is a keyword that denotes an address size specifier.
107 * If so, return the corresponding address size constant, otherwise output an
108 * error message and return ADDR_SIZE_DEFAULT.
111 void InitScanner (const char* InFile);
112 /* Initialize the scanner, open the given input file */
114 void DoneScanner (void);
115 /* Release scanner resources */
119 /* End of scanner.h */