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), Buf.st_size, Buf.st_mtime);
493 /* Create a new input source variable and initialize it */
494 S = xmalloc (sizeof (*S));
497 S->V.File.Pos.Line = 0;
498 S->V.File.Pos.Col = 0;
499 S->V.File.Pos.Name = FileIdx;
500 S->V.File.Line[0] = '\0';
502 /* Count active input files */
505 /* Use this input source */
509 /* File successfully opened */
513 /* Free an allocated name buffer */
516 /* Return the success code */
522 /*****************************************************************************/
523 /* InputData functions */
524 /*****************************************************************************/
528 static void IDMarkStart (CharSource* S attribute ((unused)))
529 /* Mark the start of the next token */
531 /* Nothing to do here */
536 static void IDNextChar (CharSource* S)
537 /* Read the next character from the input text */
539 C = *S->V.Data.Pos++;
541 /* End of input data */
549 void IDDone (CharSource* S)
550 /* Close the current input data */
552 /* Cleanup the current stuff */
553 if (S->V.Data.Malloced) {
554 xfree (S->V.Data.Text);
560 /* Set of input data handling functions */
561 static const CharSourceFunctions IDFunc = {
569 void NewInputData (char* Text, int Malloced)
570 /* Add a chunk of input data to the input stream */
574 /* Create a new input source variable and initialize it */
575 S = xmalloc (sizeof (*S));
577 S->V.Data.Text = Text;
578 S->V.Data.Pos = Text;
579 S->V.Data.Malloced = Malloced;
581 /* Use this input source */
587 /*****************************************************************************/
588 /* Character classification functions */
589 /*****************************************************************************/
594 /* Return true if the character is a valid character for an identifier */
596 return IsAlNum (C) ||
598 (C == '@' && AtInIdents) ||
599 (C == '$' && DollarInIdents);
604 int IsIdStart (int C)
605 /* Return true if the character may start an identifier */
607 return IsAlpha (C) || C == '_';
612 /*****************************************************************************/
614 /*****************************************************************************/
618 static unsigned DigitVal (unsigned char C)
619 /* Convert a digit into it's numerical representation */
624 return toupper (C) - 'A' + 10;
630 static void NextChar (void)
631 /* Read the next character from the input file */
633 Source->Func->NextChar (Source);
638 void LocaseSVal (void)
639 /* Make SVal lower case */
646 void UpcaseSVal (void)
647 /* Make SVal upper case */
654 static int CmpDotKeyword (const void* K1, const void* K2)
655 /* Compare function for the dot keyword search */
657 return strcmp (((struct DotKeyword*)K1)->Key, ((struct DotKeyword*)K2)->Key);
662 static unsigned char FindDotKeyword (void)
663 /* Find the dot keyword in SVal. Return the corresponding token if found,
664 * return TOK_NONE if not found.
668 struct DotKeyword* R;
671 K.Key = SB_GetConstBuf (&SVal);
674 /* If we aren't in ignore case mode, we have to uppercase the keyword */
679 /* Search for the keyword */
680 R = bsearch (&K, DotKeywords, sizeof (DotKeywords) / sizeof (DotKeywords [0]),
681 sizeof (DotKeywords [0]), CmpDotKeyword);
691 static void ReadIdent (void)
692 /* Read an identifier from the current input position into Ident. Filling SVal
693 * starts at the current position with the next character in C. It is assumed
694 * that any characters already filled in are ok, and the character in C is
698 /* Read the identifier */
700 SB_AppendChar (&SVal, C);
702 } while (IsIdChar (C));
703 SB_Terminate (&SVal);
705 /* If we should ignore case, convert the identifier to upper case */
713 static void ReadStringConst (int StringTerm)
714 /* Read a string constant into SVal. */
716 /* Skip the leading string terminator */
719 /* Read the string */
721 if (C == StringTerm) {
724 if (C == '\n' || C == EOF) {
725 Error ("Newline in string constant");
729 /* Append the char to the string */
730 SB_AppendChar (&SVal, C);
732 /* Skip the character */
736 /* Skip the trailing terminator */
739 /* Terminate the string */
740 SB_Terminate (&SVal);
745 static int Sweet16Reg (const StrBuf* Id)
746 /* Check if the given identifier is a sweet16 register. Return -1 if this is
747 * not the case, return the register number otherwise.
753 if (SB_GetLen (Id) < 2) {
756 if (toupper (SB_AtUnchecked (Id, 0)) != 'R') {
759 if (!IsDigit (SB_AtUnchecked (Id, 1))) {
763 if (sscanf (SB_GetConstBuf (Id)+1, "%u%c", &RegNum, &Check) != 1 || RegNum > 15) {
764 /* Invalid register */
768 /* The register number is valid */
774 void NextRawTok (void)
775 /* Read the next raw token from the input stream */
777 /* If we've a forced end of assembly, don't read further */
784 /* Check if we have tokens from another input source */
785 if (InputFromStack ()) {
790 /* Skip whitespace, remember if we had some */
791 if ((WS = IsBlank (C)) != 0) {
794 } while (IsBlank (C));
797 /* Mark the file position of the next token */
798 Source->Func->MarkStart (Source);
800 /* Clear the string attribute */
803 /* Hex number or PC symbol? */
807 /* Hex digit must follow or DollarIsPC must be enabled */
813 Error ("Hexadecimal digit expected");
817 /* Read the number */
819 while (IsXDigit (C)) {
820 if (IVal & 0xF0000000) {
821 Error ("Overflow in hexadecimal number");
824 IVal = (IVal << 4) + DigitVal (C);
828 /* This is an integer constant */
837 /* 0 or 1 must follow */
839 Error ("Binary digit expected");
842 /* Read the number */
844 while (IsBDigit (C)) {
845 if (IVal & 0x80000000) {
846 Error ("Overflow in binary number");
849 IVal = (IVal << 1) + DigitVal (C);
853 /* This is an integer constant */
868 /* Ignore leading zeros */
873 /* Read the number into Buf counting the digits */
875 while (IsXDigit (C)) {
877 /* Buf is big enough to allow any decimal and hex number to
878 * overflow, so ignore excess digits here, they will be detected
879 * when we convert the value.
881 if (Digits < sizeof (Buf)) {
888 /* Allow zilog/intel style hex numbers with a 'h' suffix */
889 if (C == 'h' || C == 'H') {
892 Max = 0xFFFFFFFFUL / 16;
895 Max = 0xFFFFFFFFUL / 10;
898 /* Convert the number using the given base */
900 for (I = 0; I < Digits; ++I) {
902 Error ("Number out of range");
906 DVal = DigitVal (Buf[I]);
908 Error ("Invalid digits in number");
912 IVal = (IVal * Base) + DVal;
915 /* This is an integer constant */
920 /* Control command? */
923 /* Remember and skip the dot */
926 /* Check if it's just a dot */
927 if (!IsIdStart (C)) {
934 /* Read the remainder of the identifier */
935 SB_AppendChar (&SVal, '.');
938 /* Dot keyword, search for it */
939 Tok = FindDotKeyword ();
940 if (Tok == TOK_NONE) {
943 if (!LeadingDotInIdents) {
944 /* Invalid pseudo instruction */
945 Error ("`%m%p' is not a recognized control command", &SVal);
949 /* An identifier with a dot. Check if it's a define style
952 if (IsDefine (&SVal)) {
953 /* This is a define style macro - expand it */
958 /* Just an identifier with a dot */
966 /* Indirect op for sweet16 cpu. Must check this before checking for local
967 * symbols, because these may also use the '@' symbol.
969 if (CPU == CPU_SWEET16 && C == '@') {
976 if (C == LocalStart) {
978 /* Read the identifier. */
981 /* Start character alone is not enough */
982 if (SB_GetLen (&SVal) == 1) {
983 Error ("Invalid cheap local symbol");
987 /* A local identifier */
988 Tok = TOK_LOCAL_IDENT;
993 /* Identifier or keyword? */
996 /* Read the identifier */
999 /* Check for special names. Bail out if we have identified the type of
1000 * the token. Go on if the token is an identifier.
1002 if (SB_GetLen (&SVal) == 1) {
1003 switch (toupper (SB_AtUnchecked (&SVal, 0))) {
1008 Tok = TOK_OVERRIDE_ABS;
1017 Tok = TOK_OVERRIDE_FAR;
1023 if (CPU == CPU_65816) {
1040 Tok = TOK_OVERRIDE_ZP;
1049 } else if (CPU == CPU_SWEET16 && (IVal = Sweet16Reg (&SVal)) >= 0) {
1051 /* A sweet16 register number in sweet16 mode */
1057 /* Check for define style macro */
1058 if (IsDefine (&SVal)) {
1059 /* Macro - expand it */
1069 /* Ok, let's do the switch */
1087 } else if (CComments) {
1088 /* Remember the position, then skip the '*' */
1089 FilePos Pos = CurPos;
1094 PError (&Pos, "Unterminated comment");
1142 Tok = TOK_NAMESPACE;
1181 while (C != '\n' && C != EOF) {
1226 } else if (C == '<') {
1229 } else if (C == '>') {
1252 } else if (C == '>') {
1266 /* Hack: If we allow ' as terminating character for strings, read
1267 * the following stuff as a string, and check for a one character
1270 if (LooseStringTerm) {
1271 ReadStringConst ('\'');
1272 if (SB_GetLen (&SVal) == 1) {
1273 IVal = SB_AtUnchecked (&SVal, 0);
1279 /* Always a character constant */
1281 if (C == EOF || IsControl (C)) {
1282 Error ("Illegal character constant");
1289 if (!MissingCharTerm) {
1290 Error ("Illegal character constant");
1299 ReadStringConst ('\"');
1304 /* Line continuation? */
1308 /* Handle as white space */
1323 /* In case of the main file, do not close it, but return EOF. */
1324 if (Source && Source->Next) {
1333 /* If we go here, we could not identify the current character. Skip it
1336 Error ("Invalid input character: 0x%02X", C & 0xFF);
1343 int GetSubKey (const char** Keys, unsigned Count)
1344 /* Search for a subkey in a table of keywords. The current token must be an
1345 * identifier and all keys must be in upper case. The identifier will be
1346 * uppercased in the process. The function returns the index of the keyword,
1347 * or -1 if the keyword was not found.
1352 /* Must have an identifier */
1353 PRECONDITION (Tok == TOK_IDENT);
1355 /* If we aren't in ignore case mode, we have to uppercase the identifier */
1360 /* Do a linear search (a binary search is not worth the effort) */
1361 for (I = 0; I < Count; ++I) {
1362 if (SB_CompareStr (&SVal, Keys [I]) == 0) {
1374 unsigned char ParseAddrSize (void)
1375 /* Check if the next token is a keyword that denotes an address size specifier.
1376 * If so, return the corresponding address size constant, otherwise output an
1377 * error message and return ADDR_SIZE_DEFAULT.
1380 unsigned char AddrSize;
1382 /* Check for an identifier */
1383 if (Tok != TOK_IDENT) {
1384 Error ("Address size specifier expected");
1385 return ADDR_SIZE_DEFAULT;
1388 /* Convert the attribute */
1389 AddrSize = AddrSizeFromStr (SB_GetConstBuf (&SVal));
1390 if (AddrSize == ADDR_SIZE_INVALID) {
1391 Error ("Address size specifier expected");
1392 AddrSize = ADDR_SIZE_DEFAULT;
1401 void InitScanner (const char* InFile)
1402 /* Initialize the scanner, open the given input file */
1404 /* Open the input file */
1405 NewInputFile (InFile);
1410 void DoneScanner (void)
1411 /* Release scanner resources */