1 /*****************************************************************************/
5 /* The scanner for the ca65 macroassembler */
9 /* (C) 1998-2010, 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 /*****************************************************************************/
41 #include <sys/types.h> /* EMX needs this */
67 /*****************************************************************************/
69 /*****************************************************************************/
73 Token Tok = TOK_NONE; /* Current token */
74 int WS; /* Flag: Whitespace before token */
75 long IVal; /* Integer token attribute */
76 StrBuf SVal = STATIC_STRBUF_INITIALIZER;/* String token attribute */
78 FilePos CurPos = { 0, 0, 0 }; /* Name and position in current file */
82 /* Struct to handle include files. */
83 typedef struct InputFile InputFile;
85 FILE* F; /* Input file descriptor */
86 FilePos Pos; /* Position in file */
87 Token Tok; /* Last token */
88 int C; /* Last character */
89 char Line[256]; /* The current input line */
90 InputFile* Next; /* Linked list of input files */
93 /* Struct to handle textual input data */
94 typedef struct InputData InputData;
96 char* Text; /* Pointer to the text data */
97 const char* Pos; /* Pointer to current position */
98 int Malloced; /* Memory was malloced */
99 Token Tok; /* Last token */
100 int C; /* Last character */
101 InputData* Next; /* Linked list of input data */
104 /* Input source: Either file or data */
105 typedef struct CharSource CharSource;
107 /* Set of input functions */
108 typedef struct CharSourceFunctions CharSourceFunctions;
109 struct CharSourceFunctions {
110 void (*MarkStart) (CharSource*); /* Mark the start pos of a token */
111 void (*NextChar) (CharSource*); /* Read next char from input */
112 void (*Done) (CharSource*); /* Close input source */
115 /* Input source: Either file or data */
117 CharSource* Next; /* Linked list of char sources */
118 Token Tok; /* Last token */
119 int C; /* Last character */
120 const CharSourceFunctions* Func; /* Pointer to function table */
122 InputFile File; /* File data */
123 InputData Data; /* Textual data */
127 /* Current input variables */
128 static CharSource* Source = 0; /* Current char source */
129 static unsigned FCount = 0; /* Count of input files */
130 static int C = 0; /* Current input character */
132 /* Force end of assembly */
135 /* List of dot keywords with the corresponding tokens */
137 const char* Key; /* MUST be first field */
142 { ".ADDR", TOK_ADDR },
143 { ".ALIGN", TOK_ALIGN },
144 { ".AND", TOK_BOOLAND },
145 { ".ASCIIZ", TOK_ASCIIZ },
146 { ".ASSERT", TOK_ASSERT },
147 { ".AUTOIMPORT", TOK_AUTOIMPORT },
148 { ".BANKBYTE", TOK_BANKBYTE },
149 { ".BANKBYTES", TOK_BANKBYTES },
150 { ".BITAND", TOK_AND },
151 { ".BITNOT", TOK_NOT },
152 { ".BITOR", TOK_OR },
153 { ".BITXOR", TOK_XOR },
154 { ".BLANK", TOK_BLANK },
156 { ".BYT", TOK_BYTE },
157 { ".BYTE", TOK_BYTE },
158 { ".CASE", TOK_CASE },
159 { ".CHARMAP", TOK_CHARMAP },
160 { ".CODE", TOK_CODE },
161 { ".CONCAT", TOK_CONCAT },
162 { ".CONDES", TOK_CONDES },
163 { ".CONST", TOK_CONST },
164 { ".CONSTRUCTOR", TOK_CONSTRUCTOR },
166 { ".DATA", TOK_DATA },
168 { ".DBYT", TOK_DBYT },
169 { ".DEBUGINFO", TOK_DEBUGINFO },
170 { ".DEF", TOK_DEFINED },
171 { ".DEFINE", TOK_DEFINE },
172 { ".DEFINED", TOK_DEFINED },
173 { ".DESTRUCTOR", TOK_DESTRUCTOR },
174 { ".DWORD", TOK_DWORD },
175 { ".ELSE", TOK_ELSE },
176 { ".ELSEIF", TOK_ELSEIF },
178 { ".ENDENUM", TOK_ENDENUM },
179 { ".ENDIF", TOK_ENDIF },
180 { ".ENDMAC", TOK_ENDMACRO },
181 { ".ENDMACRO", TOK_ENDMACRO },
182 { ".ENDPROC", TOK_ENDPROC },
183 { ".ENDREP", TOK_ENDREP },
184 { ".ENDREPEAT", TOK_ENDREP },
185 { ".ENDSCOPE", TOK_ENDSCOPE },
186 { ".ENDSTRUCT", TOK_ENDSTRUCT },
187 { ".ENDUNION", TOK_ENDUNION },
188 { ".ENUM", TOK_ENUM },
189 { ".ERROR", TOK_ERROR },
190 { ".EXITMAC", TOK_EXITMACRO },
191 { ".EXITMACRO", TOK_EXITMACRO },
192 { ".EXPORT", TOK_EXPORT },
193 { ".EXPORTZP", TOK_EXPORTZP },
194 { ".FARADDR", TOK_FARADDR },
195 { ".FEATURE", TOK_FEATURE },
196 { ".FILEOPT", TOK_FILEOPT },
197 { ".FOPT", TOK_FILEOPT },
198 { ".FORCEIMPORT", TOK_FORCEIMPORT },
199 { ".FORCEWORD", TOK_FORCEWORD },
200 { ".GLOBAL", TOK_GLOBAL },
201 { ".GLOBALZP", TOK_GLOBALZP },
202 { ".HIBYTE", TOK_HIBYTE },
203 { ".HIBYTES", TOK_HIBYTES },
204 { ".HIWORD", TOK_HIWORD },
207 { ".IDENT", TOK_MAKEIDENT },
209 { ".IFBLANK", TOK_IFBLANK },
210 { ".IFCONST", TOK_IFCONST },
211 { ".IFDEF", TOK_IFDEF },
212 { ".IFNBLANK", TOK_IFNBLANK },
213 { ".IFNCONST", TOK_IFNCONST },
214 { ".IFNDEF", TOK_IFNDEF },
215 { ".IFNREF", TOK_IFNREF },
216 { ".IFP02", TOK_IFP02 },
217 { ".IFP816", TOK_IFP816 },
218 { ".IFPC02", TOK_IFPC02 },
219 { ".IFPSC02", TOK_IFPSC02 },
220 { ".IFREF", TOK_IFREF },
221 { ".IMPORT", TOK_IMPORT },
222 { ".IMPORTZP", TOK_IMPORTZP },
223 { ".INCBIN", TOK_INCBIN },
224 { ".INCLUDE", TOK_INCLUDE },
225 { ".INTERRUPTOR", TOK_INTERRUPTOR },
226 { ".LEFT", TOK_LEFT },
227 { ".LINECONT", TOK_LINECONT },
228 { ".LIST", TOK_LIST },
229 { ".LISTBYTES", TOK_LISTBYTES },
230 { ".LOBYTE", TOK_LOBYTE },
231 { ".LOBYTES", TOK_LOBYTES },
232 { ".LOCAL", TOK_LOCAL },
233 { ".LOCALCHAR", TOK_LOCALCHAR },
234 { ".LOWORD", TOK_LOWORD },
235 { ".MAC", TOK_MACRO },
236 { ".MACPACK", TOK_MACPACK },
237 { ".MACRO", TOK_MACRO },
238 { ".MATCH", TOK_MATCH },
243 { ".NOT", TOK_BOOLNOT },
244 { ".NULL", TOK_NULL },
245 { ".OR", TOK_BOOLOR },
249 { ".P816", TOK_P816 },
250 { ".PAGELEN", TOK_PAGELENGTH },
251 { ".PAGELENGTH", TOK_PAGELENGTH },
252 { ".PARAMCOUNT", TOK_PARAMCOUNT },
253 { ".PC02", TOK_PC02 },
254 { ".POPCPU", TOK_POPCPU },
255 { ".POPSEG", TOK_POPSEG },
256 { ".PROC", TOK_PROC },
257 { ".PSC02", TOK_PSC02 },
258 { ".PUSHCPU", TOK_PUSHCPU },
259 { ".PUSHSEG", TOK_PUSHSEG },
260 { ".REF", TOK_REFERENCED },
261 { ".REFERENCED", TOK_REFERENCED },
262 { ".RELOC", TOK_RELOC },
263 { ".REPEAT", TOK_REPEAT },
265 { ".RIGHT", TOK_RIGHT },
266 { ".RODATA", TOK_RODATA },
267 { ".SCOPE", TOK_SCOPE },
268 { ".SEGMENT", TOK_SEGMENT },
270 { ".SETCPU", TOK_SETCPU },
273 { ".SIZEOF", TOK_SIZEOF },
274 { ".SMART", TOK_SMART },
275 { ".SPRINTF", TOK_SPRINTF },
276 { ".STRAT", TOK_STRAT },
277 { ".STRING", TOK_STRING },
278 { ".STRLEN", TOK_STRLEN },
279 { ".STRUCT", TOK_STRUCT },
280 { ".SUNPLUS", TOK_SUNPLUS },
282 { ".TCOUNT", TOK_TCOUNT },
283 { ".TIME", TOK_TIME },
284 { ".UNION", TOK_UNION },
285 { ".VERSION", TOK_VERSION },
286 { ".WARNING", TOK_WARNING },
287 { ".WORD", TOK_WORD },
288 { ".XMATCH", TOK_XMATCH },
289 { ".XOR", TOK_BOOLXOR },
290 { ".ZEROPAGE", TOK_ZEROPAGE },
295 /*****************************************************************************/
296 /* CharSource functions */
297 /*****************************************************************************/
301 static void UseCharSource (CharSource* S)
302 /* Initialize a new input source and start to use it. */
304 /* Remember the current input char and token */
308 /* Use the new input source */
312 /* Read the first character from the new file */
313 S->Func->NextChar (S);
315 /* Setup the next token so it will be skipped on the next call to
323 static void DoneCharSource (void)
324 /* Close the top level character source */
328 /* First, call the type specific function */
329 Source->Func->Done (Source);
331 /* Restore the old token */
335 /* Remember the last stacked input source */
338 /* Delete the top level one ... */
341 /* ... and use the one before */
347 /*****************************************************************************/
348 /* InputFile functions */
349 /*****************************************************************************/
353 static void IFMarkStart (CharSource* S)
354 /* Mark the start of the next token */
356 CurPos = S->V.File.Pos;
361 static void IFNextChar (CharSource* S)
362 /* Read the next character from the input file */
364 /* Check for end of line, read the next line if needed */
365 while (S->V.File.Line [S->V.File.Pos.Col] == '\0') {
367 unsigned Len, Removed;
369 /* End of current line reached, read next line */
370 if (fgets (S->V.File.Line, sizeof (S->V.File.Line), S->V.File.F) == 0) {
371 /* End of file. Add an empty line to the listing. This is a
372 * small hack needed to keep the PC output in sync.
374 NewListingLine ("", S->V.File.Pos.Name, FCount);
379 /* For better handling of files with unusual line endings (DOS
380 * files that are accidently translated on Unix for example),
381 * first remove all whitespace at the end, then add a single
384 Len = strlen (S->V.File.Line);
386 while (Len > 0 && IsSpace (S->V.File.Line[Len-1])) {
391 S->V.File.Line[Len+0] = '\n';
392 S->V.File.Line[Len+1] = '\0';
396 S->V.File.Pos.Line++;
397 S->V.File.Pos.Col = 0;
399 /* Remember the new line for the listing */
400 NewListingLine (S->V.File.Line, S->V.File.Pos.Name, FCount);
404 /* Return the next character from the file */
405 C = S->V.File.Line [S->V.File.Pos.Col++];
410 void IFDone (CharSource* S)
411 /* Close the current input file */
413 /* We're at the end of an include file. Check if we have any
414 * open .IFs, or any open token lists in this file. This
415 * enforcement is artificial, using conditionals that start
416 * in one file and end in another are uncommon, and don't
417 * allowing these things will help finding errors.
421 /* Close the input file and decrement the file count. We will ignore
422 * errors here, since we were just reading from the file.
424 (void) fclose (S->V.File.F);
430 /* Set of input file handling functions */
431 static const CharSourceFunctions IFFunc = {
439 int NewInputFile (const char* Name)
440 /* Open a new input file. Returns true if the file could be successfully opened
441 * and false otherwise.
444 int RetCode = 0; /* Return code. Assume an error. */
447 /* First try to open the file */
448 FILE* F = fopen (Name, "r");
451 /* Error (fatal error if this is the main file) */
453 Fatal ("Cannot open input file `%s': %s", Name, strerror (errno));
456 /* We are on include level. Search for the file in the include
459 PathName = FindInclude (Name, INC_STD);
460 if (PathName == 0 || (F = fopen (PathName, "r")) == 0) {
461 /* Not found or cannot open, print an error and bail out */
462 Error ("Cannot open include file `%s': %s", Name, strerror (errno));
466 /* Use the path name from now on */
470 /* check again if we do now have an open file */
477 /* Stat the file and remember the values. There a race condition here,
478 * since we cannot use fileno() (non standard identifier in standard
479 * header file), and therefore not fstat. When using stat with the
480 * file name, there's a risk that the file was deleted and recreated
481 * while it was open. Since mtime and size are only used to check
482 * if a file has changed in the debugger, we will ignore this problem
486 if (stat (Name, &Buf) != 0) {
487 Fatal ("Cannot stat input file `%s': %s", Name, strerror (errno));
490 /* Add the file to the input file table and remember the index */
491 FileIdx = AddFile (SB_InitFromString (&NameBuf, Name),
492 (FCount == 0)? FT_MAIN : FT_INCLUDE,
493 Buf.st_size, Buf.st_mtime);
495 /* Create a new input source variable and initialize it */
496 S = xmalloc (sizeof (*S));
499 S->V.File.Pos.Line = 0;
500 S->V.File.Pos.Col = 0;
501 S->V.File.Pos.Name = FileIdx;
502 S->V.File.Line[0] = '\0';
504 /* Count active input files */
507 /* Use this input source */
511 /* File successfully opened */
515 /* Free an allocated name buffer */
518 /* Return the success code */
524 /*****************************************************************************/
525 /* InputData functions */
526 /*****************************************************************************/
530 static void IDMarkStart (CharSource* S attribute ((unused)))
531 /* Mark the start of the next token */
533 /* Nothing to do here */
538 static void IDNextChar (CharSource* S)
539 /* Read the next character from the input text */
541 C = *S->V.Data.Pos++;
543 /* End of input data */
551 void IDDone (CharSource* S)
552 /* Close the current input data */
554 /* Cleanup the current stuff */
555 if (S->V.Data.Malloced) {
556 xfree (S->V.Data.Text);
562 /* Set of input data handling functions */
563 static const CharSourceFunctions IDFunc = {
571 void NewInputData (char* Text, int Malloced)
572 /* Add a chunk of input data to the input stream */
576 /* Create a new input source variable and initialize it */
577 S = xmalloc (sizeof (*S));
579 S->V.Data.Text = Text;
580 S->V.Data.Pos = Text;
581 S->V.Data.Malloced = Malloced;
583 /* Use this input source */
589 /*****************************************************************************/
590 /* Character classification functions */
591 /*****************************************************************************/
596 /* Return true if the character is a valid character for an identifier */
598 return IsAlNum (C) ||
600 (C == '@' && AtInIdents) ||
601 (C == '$' && DollarInIdents);
606 int IsIdStart (int C)
607 /* Return true if the character may start an identifier */
609 return IsAlpha (C) || C == '_';
614 /*****************************************************************************/
616 /*****************************************************************************/
620 static unsigned DigitVal (unsigned char C)
621 /* Convert a digit into it's numerical representation */
626 return toupper (C) - 'A' + 10;
632 static void NextChar (void)
633 /* Read the next character from the input file */
635 Source->Func->NextChar (Source);
640 void LocaseSVal (void)
641 /* Make SVal lower case */
648 void UpcaseSVal (void)
649 /* Make SVal upper case */
656 static int CmpDotKeyword (const void* K1, const void* K2)
657 /* Compare function for the dot keyword search */
659 return strcmp (((struct DotKeyword*)K1)->Key, ((struct DotKeyword*)K2)->Key);
664 static unsigned char FindDotKeyword (void)
665 /* Find the dot keyword in SVal. Return the corresponding token if found,
666 * return TOK_NONE if not found.
670 struct DotKeyword* R;
673 K.Key = SB_GetConstBuf (&SVal);
676 /* If we aren't in ignore case mode, we have to uppercase the keyword */
681 /* Search for the keyword */
682 R = bsearch (&K, DotKeywords, sizeof (DotKeywords) / sizeof (DotKeywords [0]),
683 sizeof (DotKeywords [0]), CmpDotKeyword);
693 static void ReadIdent (void)
694 /* Read an identifier from the current input position into Ident. Filling SVal
695 * starts at the current position with the next character in C. It is assumed
696 * that any characters already filled in are ok, and the character in C is
700 /* Read the identifier */
702 SB_AppendChar (&SVal, C);
704 } while (IsIdChar (C));
705 SB_Terminate (&SVal);
707 /* If we should ignore case, convert the identifier to upper case */
715 static void ReadStringConst (int StringTerm)
716 /* Read a string constant into SVal. */
718 /* Skip the leading string terminator */
721 /* Read the string */
723 if (C == StringTerm) {
726 if (C == '\n' || C == EOF) {
727 Error ("Newline in string constant");
731 /* Append the char to the string */
732 SB_AppendChar (&SVal, C);
734 /* Skip the character */
738 /* Skip the trailing terminator */
741 /* Terminate the string */
742 SB_Terminate (&SVal);
747 static int Sweet16Reg (const StrBuf* Id)
748 /* Check if the given identifier is a sweet16 register. Return -1 if this is
749 * not the case, return the register number otherwise.
755 if (SB_GetLen (Id) < 2) {
758 if (toupper (SB_AtUnchecked (Id, 0)) != 'R') {
761 if (!IsDigit (SB_AtUnchecked (Id, 1))) {
765 if (sscanf (SB_GetConstBuf (Id)+1, "%u%c", &RegNum, &Check) != 1 || RegNum > 15) {
766 /* Invalid register */
770 /* The register number is valid */
776 void NextRawTok (void)
777 /* Read the next raw token from the input stream */
779 /* If we've a forced end of assembly, don't read further */
786 /* Check if we have tokens from another input source */
787 if (InputFromStack ()) {
792 /* Skip whitespace, remember if we had some */
793 if ((WS = IsBlank (C)) != 0) {
796 } while (IsBlank (C));
799 /* Mark the file position of the next token */
800 Source->Func->MarkStart (Source);
802 /* Clear the string attribute */
805 /* Hex number or PC symbol? */
809 /* Hex digit must follow or DollarIsPC must be enabled */
815 Error ("Hexadecimal digit expected");
819 /* Read the number */
821 while (IsXDigit (C)) {
822 if (IVal & 0xF0000000) {
823 Error ("Overflow in hexadecimal number");
826 IVal = (IVal << 4) + DigitVal (C);
830 /* This is an integer constant */
839 /* 0 or 1 must follow */
841 Error ("Binary digit expected");
844 /* Read the number */
846 while (IsBDigit (C)) {
847 if (IVal & 0x80000000) {
848 Error ("Overflow in binary number");
851 IVal = (IVal << 1) + DigitVal (C);
855 /* This is an integer constant */
870 /* Ignore leading zeros */
875 /* Read the number into Buf counting the digits */
877 while (IsXDigit (C)) {
879 /* Buf is big enough to allow any decimal and hex number to
880 * overflow, so ignore excess digits here, they will be detected
881 * when we convert the value.
883 if (Digits < sizeof (Buf)) {
890 /* Allow zilog/intel style hex numbers with a 'h' suffix */
891 if (C == 'h' || C == 'H') {
894 Max = 0xFFFFFFFFUL / 16;
897 Max = 0xFFFFFFFFUL / 10;
900 /* Convert the number using the given base */
902 for (I = 0; I < Digits; ++I) {
904 Error ("Number out of range");
908 DVal = DigitVal (Buf[I]);
910 Error ("Invalid digits in number");
914 IVal = (IVal * Base) + DVal;
917 /* This is an integer constant */
922 /* Control command? */
925 /* Remember and skip the dot */
928 /* Check if it's just a dot */
929 if (!IsIdStart (C)) {
936 /* Read the remainder of the identifier */
937 SB_AppendChar (&SVal, '.');
940 /* Dot keyword, search for it */
941 Tok = FindDotKeyword ();
942 if (Tok == TOK_NONE) {
945 if (!LeadingDotInIdents) {
946 /* Invalid pseudo instruction */
947 Error ("`%m%p' is not a recognized control command", &SVal);
951 /* An identifier with a dot. Check if it's a define style
954 if (IsDefine (&SVal)) {
955 /* This is a define style macro - expand it */
960 /* Just an identifier with a dot */
968 /* Indirect op for sweet16 cpu. Must check this before checking for local
969 * symbols, because these may also use the '@' symbol.
971 if (CPU == CPU_SWEET16 && C == '@') {
978 if (C == LocalStart) {
980 /* Read the identifier. */
983 /* Start character alone is not enough */
984 if (SB_GetLen (&SVal) == 1) {
985 Error ("Invalid cheap local symbol");
989 /* A local identifier */
990 Tok = TOK_LOCAL_IDENT;
995 /* Identifier or keyword? */
998 /* Read the identifier */
1001 /* Check for special names. Bail out if we have identified the type of
1002 * the token. Go on if the token is an identifier.
1004 if (SB_GetLen (&SVal) == 1) {
1005 switch (toupper (SB_AtUnchecked (&SVal, 0))) {
1010 Tok = TOK_OVERRIDE_ABS;
1019 Tok = TOK_OVERRIDE_FAR;
1025 if (CPU == CPU_65816) {
1042 Tok = TOK_OVERRIDE_ZP;
1051 } else if (CPU == CPU_SWEET16 && (IVal = Sweet16Reg (&SVal)) >= 0) {
1053 /* A sweet16 register number in sweet16 mode */
1059 /* Check for define style macro */
1060 if (IsDefine (&SVal)) {
1061 /* Macro - expand it */
1071 /* Ok, let's do the switch */
1089 } else if (CComments) {
1090 /* Remember the position, then skip the '*' */
1091 FilePos Pos = CurPos;
1096 PError (&Pos, "Unterminated comment");
1144 Tok = TOK_NAMESPACE;
1183 while (C != '\n' && C != EOF) {
1228 } else if (C == '<') {
1231 } else if (C == '>') {
1254 } else if (C == '>') {
1268 /* Hack: If we allow ' as terminating character for strings, read
1269 * the following stuff as a string, and check for a one character
1272 if (LooseStringTerm) {
1273 ReadStringConst ('\'');
1274 if (SB_GetLen (&SVal) == 1) {
1275 IVal = SB_AtUnchecked (&SVal, 0);
1281 /* Always a character constant */
1283 if (C == EOF || IsControl (C)) {
1284 Error ("Illegal character constant");
1291 if (!MissingCharTerm) {
1292 Error ("Illegal character constant");
1301 ReadStringConst ('\"');
1306 /* Line continuation? */
1310 /* Handle as white space */
1325 /* In case of the main file, do not close it, but return EOF. */
1326 if (Source && Source->Next) {
1335 /* If we go here, we could not identify the current character. Skip it
1338 Error ("Invalid input character: 0x%02X", C & 0xFF);
1345 int GetSubKey (const char** Keys, unsigned Count)
1346 /* Search for a subkey in a table of keywords. The current token must be an
1347 * identifier and all keys must be in upper case. The identifier will be
1348 * uppercased in the process. The function returns the index of the keyword,
1349 * or -1 if the keyword was not found.
1354 /* Must have an identifier */
1355 PRECONDITION (Tok == TOK_IDENT);
1357 /* If we aren't in ignore case mode, we have to uppercase the identifier */
1362 /* Do a linear search (a binary search is not worth the effort) */
1363 for (I = 0; I < Count; ++I) {
1364 if (SB_CompareStr (&SVal, Keys [I]) == 0) {
1376 unsigned char ParseAddrSize (void)
1377 /* Check if the next token is a keyword that denotes an address size specifier.
1378 * If so, return the corresponding address size constant, otherwise output an
1379 * error message and return ADDR_SIZE_DEFAULT.
1382 unsigned char AddrSize;
1384 /* Check for an identifier */
1385 if (Tok != TOK_IDENT) {
1386 Error ("Address size specifier expected");
1387 return ADDR_SIZE_DEFAULT;
1390 /* Convert the attribute */
1391 AddrSize = AddrSizeFromStr (SB_GetConstBuf (&SVal));
1392 if (AddrSize == ADDR_SIZE_INVALID) {
1393 Error ("Address size specifier expected");
1394 AddrSize = ADDR_SIZE_DEFAULT;
1403 void InitScanner (const char* InFile)
1404 /* Initialize the scanner, open the given input file */
1406 /* Open the input file */
1407 NewInputFile (InFile);
1412 void DoneScanner (void)
1413 /* Release scanner resources */