]> git.sur5r.net Git - cc65/blob - src/ca65/scanner.h
Move more stuff from scanner.c into the new module token.c.
[cc65] / src / ca65 / scanner.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                 scanner.h                                 */
4 /*                                                                           */
5 /*                  The scanner for the ca65 macroassembler                  */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 1998-2007 Ullrich von Bassewitz                                       */
10 /*               Roemerstrasse 52                                            */
11 /*               D-70794 Filderstadt                                         */
12 /* EMail:        uz@cc65.org                                                 */
13 /*                                                                           */
14 /*                                                                           */
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.                                    */
18 /*                                                                           */
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:                            */
22 /*                                                                           */
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              */
30 /*    distribution.                                                          */
31 /*                                                                           */
32 /*****************************************************************************/
33
34
35
36 #ifndef SCANNER_H
37 #define SCANNER_H
38
39
40
41 /* common */
42 #include "filepos.h"
43
44 /* ca65 */
45 #include "token.h"
46
47
48
49 /*****************************************************************************/
50 /*                                   Data                                    */
51 /*****************************************************************************/
52
53
54
55 /* Scanner variables */
56 #define MAX_INPUT_FILES 254             /* No more than this files total */
57 #define MAX_STR_LEN     255             /* Maximum length of any string */
58 extern Token Tok;                       /* Current token */
59 extern int WS;                          /* Flag: Whitespace before token */
60 extern long IVal;                       /* Integer token attribute */
61 extern char SVal[MAX_STR_LEN+1];        /* String token attribute */
62
63 extern FilePos  CurPos;                 /* Name and position in file */
64 extern int      ForcedEnd;              /* Force end of assembly */
65
66
67
68 /*****************************************************************************/
69 /*                                   Code                                    */
70 /*****************************************************************************/
71
72
73
74 int IsIdChar (int C);
75 /* Return true if the character is a valid character for an identifier */
76
77 int IsIdStart (int C);
78 /* Return true if the character may start an identifier */
79
80 void NewInputFile (const char* Name);
81 /* Open a new input file */
82
83 void NewInputData (char* Text, int Malloced);
84 /* Add a chunk of input data to the input stream */
85
86 void LocaseSVal (void);
87 /* Make SVal lower case */
88
89 void UpcaseSVal (void);
90 /* Make SVal upper case */
91
92 void NextRawTok (void);
93 /* Read the next raw token from the input stream */
94
95 int GetSubKey (const char** Keys, unsigned Count);
96 /* Search for a subkey in a table of keywords. The current token must be an
97  * identifier and all keys must be in upper case. The identifier will be
98  * uppercased in the process. The function returns the index of the keyword,
99  * or -1 if the keyword was not found.
100  */
101
102 unsigned char ParseAddrSize (void);
103 /* Check if the next token is a keyword that denotes an address size specifier.
104  * If so, return the corresponding address size constant, otherwise output an
105  * error message and return ADDR_SIZE_DEFAULT.
106  */
107
108 void InitScanner (const char* InFile);
109 /* Initialize the scanner, open the given input file */
110
111 void DoneScanner (void);
112 /* Release scanner resources */
113
114
115
116 /* End of scanner.h */
117
118 #endif
119
120
121
122