1 /*****************************************************************************/
5 /* The scanner for the ca65 macroassembler */
9 /* (C) 1998-2008 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 },
241 { ".NOT", TOK_BOOLNOT },
242 { ".NULL", TOK_NULL },
243 { ".OR", TOK_BOOLOR },
247 { ".P816", TOK_P816 },
248 { ".PAGELEN", TOK_PAGELENGTH },
249 { ".PAGELENGTH", TOK_PAGELENGTH },
250 { ".PARAMCOUNT", TOK_PARAMCOUNT },
251 { ".PC02", TOK_PC02 },
252 { ".POPSEG", TOK_POPSEG },
253 { ".PROC", TOK_PROC },
254 { ".PSC02", TOK_PSC02 },
255 { ".PUSHSEG", TOK_PUSHSEG },
256 { ".REF", TOK_REFERENCED },
257 { ".REFERENCED", TOK_REFERENCED },
258 { ".RELOC", TOK_RELOC },
259 { ".REPEAT", TOK_REPEAT },
261 { ".RIGHT", TOK_RIGHT },
262 { ".RODATA", TOK_RODATA },
263 { ".SCOPE", TOK_SCOPE },
264 { ".SEGMENT", TOK_SEGMENT },
266 { ".SETCPU", TOK_SETCPU },
269 { ".SIZEOF", TOK_SIZEOF },
270 { ".SMART", TOK_SMART },
271 { ".SPRINTF", TOK_SPRINTF },
272 { ".STRAT", TOK_STRAT },
273 { ".STRING", TOK_STRING },
274 { ".STRLEN", TOK_STRLEN },
275 { ".STRUCT", TOK_STRUCT },
276 { ".SUNPLUS", TOK_SUNPLUS },
278 { ".TCOUNT", TOK_TCOUNT },
279 { ".TIME", TOK_TIME },
280 { ".UNION", TOK_UNION },
281 { ".VERSION", TOK_VERSION },
282 { ".WARNING", TOK_WARNING },
283 { ".WORD", TOK_WORD },
284 { ".XMATCH", TOK_XMATCH },
285 { ".XOR", TOK_BOOLXOR },
286 { ".ZEROPAGE", TOK_ZEROPAGE },
291 /*****************************************************************************/
292 /* CharSource functions */
293 /*****************************************************************************/
297 static void UseCharSource (CharSource* S)
298 /* Initialize a new input source and start to use it. */
300 /* Remember the current input char and token */
304 /* Use the new input source */
308 /* Read the first character from the new file */
309 S->Func->NextChar (S);
311 /* Setup the next token so it will be skipped on the next call to
319 static void DoneCharSource (void)
320 /* Close the top level character source */
324 /* First, call the type specific function */
325 Source->Func->Done (Source);
327 /* Restore the old token */
331 /* Remember the last stacked input source */
334 /* Delete the top level one ... */
337 /* ... and use the one before */
343 /*****************************************************************************/
344 /* InputFile functions */
345 /*****************************************************************************/
349 static void IFMarkStart (CharSource* S)
350 /* Mark the start of the next token */
352 CurPos = S->V.File.Pos;
357 static void IFNextChar (CharSource* S)
358 /* Read the next character from the input file */
360 /* Check for end of line, read the next line if needed */
361 while (S->V.File.Line [S->V.File.Pos.Col] == '\0') {
363 unsigned Len, Removed;
365 /* End of current line reached, read next line */
366 if (fgets (S->V.File.Line, sizeof (S->V.File.Line), S->V.File.F) == 0) {
367 /* End of file. Add an empty line to the listing. This is a
368 * small hack needed to keep the PC output in sync.
370 NewListingLine ("", S->V.File.Pos.Name, FCount);
375 /* For better handling of files with unusual line endings (DOS
376 * files that are accidently translated on Unix for example),
377 * first remove all whitespace at the end, then add a single
380 Len = strlen (S->V.File.Line);
382 while (Len > 0 && IsSpace (S->V.File.Line[Len-1])) {
387 S->V.File.Line[Len+0] = '\n';
388 S->V.File.Line[Len+1] = '\0';
392 S->V.File.Pos.Line++;
393 S->V.File.Pos.Col = 0;
395 /* Remember the new line for the listing */
396 NewListingLine (S->V.File.Line, S->V.File.Pos.Name, FCount);
400 /* Return the next character from the file */
401 C = S->V.File.Line [S->V.File.Pos.Col++];
406 void IFDone (CharSource* S)
407 /* Close the current input file */
409 /* We're at the end of an include file. Check if we have any
410 * open .IFs, or any open token lists in this file. This
411 * enforcement is artificial, using conditionals that start
412 * in one file and end in another are uncommon, and don't
413 * allowing these things will help finding errors.
417 /* Close the input file and decrement the file count. We will ignore
418 * errors here, since we were just reading from the file.
420 (void) fclose (S->V.File.F);
426 /* Set of input file handling functions */
427 static const CharSourceFunctions IFFunc = {
435 int NewInputFile (const char* Name)
436 /* Open a new input file. Returns true if the file could be successfully opened
437 * and false otherwise.
440 int RetCode = 0; /* Return code. Assume an error. */
443 /* First try to open the file */
444 FILE* F = fopen (Name, "r");
447 /* Error (fatal error if this is the main file) */
449 Fatal ("Cannot open input file `%s': %s", Name, strerror (errno));
452 /* We are on include level. Search for the file in the include
455 PathName = FindInclude (Name);
456 if (PathName == 0 || (F = fopen (PathName, "r")) == 0) {
457 /* Not found or cannot open, print an error and bail out */
458 Error ("Cannot open include file `%s': %s", Name, strerror (errno));
462 /* Use the path name from now on */
466 /* check again if we do now have an open file */
473 /* Stat the file and remember the values. There a race condition here,
474 * since we cannot use fileno() (non standard identifier in standard
475 * header file), and therefore not fstat. When using stat with the
476 * file name, there's a risk that the file was deleted and recreated
477 * while it was open. Since mtime and size are only used to check
478 * if a file has changed in the debugger, we will ignore this problem
482 if (stat (Name, &Buf) != 0) {
483 Fatal ("Cannot stat input file `%s': %s", Name, strerror (errno));
486 /* Add the file to the input file table and remember the index */
487 FileIdx = AddFile (SB_InitFromString (&NameBuf, Name), Buf.st_size, Buf.st_mtime);
489 /* Create a new input source variable and initialize it */
490 S = xmalloc (sizeof (*S));
493 S->V.File.Pos.Line = 0;
494 S->V.File.Pos.Col = 0;
495 S->V.File.Pos.Name = FileIdx;
496 S->V.File.Line[0] = '\0';
498 /* Count active input files */
501 /* Use this input source */
505 /* File successfully opened */
509 /* Free an allocated name buffer */
512 /* Return the success code */
518 /*****************************************************************************/
519 /* InputData functions */
520 /*****************************************************************************/
524 static void IDMarkStart (CharSource* S attribute ((unused)))
525 /* Mark the start of the next token */
527 /* Nothing to do here */
532 static void IDNextChar (CharSource* S)
533 /* Read the next character from the input text */
535 C = *S->V.Data.Pos++;
537 /* End of input data */
545 void IDDone (CharSource* S)
546 /* Close the current input data */
548 /* Cleanup the current stuff */
549 if (S->V.Data.Malloced) {
550 xfree (S->V.Data.Text);
556 /* Set of input data handling functions */
557 static const CharSourceFunctions IDFunc = {
565 void NewInputData (char* Text, int Malloced)
566 /* Add a chunk of input data to the input stream */
570 /* Create a new input source variable and initialize it */
571 S = xmalloc (sizeof (*S));
573 S->V.Data.Text = Text;
574 S->V.Data.Pos = Text;
575 S->V.Data.Malloced = Malloced;
577 /* Use this input source */
583 /*****************************************************************************/
584 /* Character classification functions */
585 /*****************************************************************************/
590 /* Return true if the character is a valid character for an identifier */
592 return IsAlNum (C) ||
594 (C == '@' && AtInIdents) ||
595 (C == '$' && DollarInIdents);
600 int IsIdStart (int C)
601 /* Return true if the character may start an identifier */
603 return IsAlpha (C) || C == '_';
608 /*****************************************************************************/
610 /*****************************************************************************/
614 static unsigned DigitVal (unsigned char C)
615 /* Convert a digit into it's numerical representation */
620 return toupper (C) - 'A' + 10;
626 static void NextChar (void)
627 /* Read the next character from the input file */
629 Source->Func->NextChar (Source);
634 void LocaseSVal (void)
635 /* Make SVal lower case */
642 void UpcaseSVal (void)
643 /* Make SVal upper case */
650 static int CmpDotKeyword (const void* K1, const void* K2)
651 /* Compare function for the dot keyword search */
653 return strcmp (((struct DotKeyword*)K1)->Key, ((struct DotKeyword*)K2)->Key);
658 static unsigned char FindDotKeyword (void)
659 /* Find the dot keyword in SVal. Return the corresponding token if found,
660 * return TOK_NONE if not found.
664 struct DotKeyword* R;
667 K.Key = SB_GetConstBuf (&SVal);
670 /* If we aren't in ignore case mode, we have to uppercase the keyword */
675 /* Search for the keyword */
676 R = bsearch (&K, DotKeywords, sizeof (DotKeywords) / sizeof (DotKeywords [0]),
677 sizeof (DotKeywords [0]), CmpDotKeyword);
687 static void ReadIdent (void)
688 /* Read an identifier from the current input position into Ident. Filling SVal
689 * starts at the current position with the next character in C. It is assumed
690 * that any characters already filled in are ok, and the character in C is
694 /* Read the identifier */
696 SB_AppendChar (&SVal, C);
698 } while (IsIdChar (C));
699 SB_Terminate (&SVal);
701 /* If we should ignore case, convert the identifier to upper case */
709 static void ReadStringConst (int StringTerm)
710 /* Read a string constant into SVal. */
712 /* Skip the leading string terminator */
715 /* Read the string */
717 if (C == StringTerm) {
720 if (C == '\n' || C == EOF) {
721 Error ("Newline in string constant");
725 /* Append the char to the string */
726 SB_AppendChar (&SVal, C);
728 /* Skip the character */
732 /* Skip the trailing terminator */
735 /* Terminate the string */
736 SB_Terminate (&SVal);
741 static int Sweet16Reg (const StrBuf* Id)
742 /* Check if the given identifier is a sweet16 register. Return -1 if this is
743 * not the case, return the register number otherwise.
749 if (SB_GetLen (Id) < 2) {
752 if (toupper (SB_AtUnchecked (Id, 0)) != 'R') {
755 if (!IsDigit (SB_AtUnchecked (Id, 1))) {
759 if (sscanf (SB_GetConstBuf (Id)+1, "%u%c", &RegNum, &Check) != 1 || RegNum > 15) {
760 /* Invalid register */
764 /* The register number is valid */
770 void NextRawTok (void)
771 /* Read the next raw token from the input stream */
773 /* If we've a forced end of assembly, don't read further */
780 /* Check if we have tokens from another input source */
781 if (InputFromStack ()) {
786 /* Skip whitespace, remember if we had some */
787 if ((WS = IsBlank (C)) != 0) {
790 } while (IsBlank (C));
793 /* Mark the file position of the next token */
794 Source->Func->MarkStart (Source);
796 /* Clear the string attribute */
799 /* Hex number or PC symbol? */
803 /* Hex digit must follow or DollarIsPC must be enabled */
809 Error ("Hexadecimal digit expected");
813 /* Read the number */
815 while (IsXDigit (C)) {
816 if (IVal & 0xF0000000) {
817 Error ("Overflow in hexadecimal number");
820 IVal = (IVal << 4) + DigitVal (C);
824 /* This is an integer constant */
833 /* 0 or 1 must follow */
835 Error ("Binary digit expected");
838 /* Read the number */
840 while (IsBDigit (C)) {
841 if (IVal & 0x80000000) {
842 Error ("Overflow in binary number");
845 IVal = (IVal << 1) + DigitVal (C);
849 /* This is an integer constant */
864 /* Ignore leading zeros */
869 /* Read the number into Buf counting the digits */
871 while (IsXDigit (C)) {
873 /* Buf is big enough to allow any decimal and hex number to
874 * overflow, so ignore excess digits here, they will be detected
875 * when we convert the value.
877 if (Digits < sizeof (Buf)) {
884 /* Allow zilog/intel style hex numbers with a 'h' suffix */
885 if (C == 'h' || C == 'H') {
888 Max = 0xFFFFFFFFUL / 16;
891 Max = 0xFFFFFFFFUL / 10;
894 /* Convert the number using the given base */
896 for (I = 0; I < Digits; ++I) {
898 Error ("Number out of range");
902 DVal = DigitVal (Buf[I]);
904 Error ("Invalid digits in number");
908 IVal = (IVal * Base) + DVal;
911 /* This is an integer constant */
916 /* Control command? */
919 /* Remember and skip the dot */
922 /* Check if it's just a dot */
923 if (!IsIdStart (C)) {
930 /* Read the remainder of the identifier */
931 SB_AppendChar (&SVal, '.');
934 /* Dot keyword, search for it */
935 Tok = FindDotKeyword ();
936 if (Tok == TOK_NONE) {
939 if (!LeadingDotInIdents) {
940 /* Invalid pseudo instruction */
941 Error ("`%m%p' is not a recognized control command", &SVal);
945 /* An identifier with a dot. Check if it's a define style
948 if (IsDefine (&SVal)) {
949 /* This is a define style macro - expand it */
954 /* Just an identifier with a dot */
962 /* Indirect op for sweet16 cpu. Must check this before checking for local
963 * symbols, because these may also use the '@' symbol.
965 if (CPU == CPU_SWEET16 && C == '@') {
972 if (C == LocalStart) {
974 /* Read the identifier. */
977 /* Start character alone is not enough */
978 if (SB_GetLen (&SVal) == 1) {
979 Error ("Invalid cheap local symbol");
983 /* A local identifier */
984 Tok = TOK_LOCAL_IDENT;
989 /* Identifier or keyword? */
992 /* Read the identifier */
995 /* Check for special names. Bail out if we have identified the type of
996 * the token. Go on if the token is an identifier.
998 if (SB_GetLen (&SVal) == 1) {
999 switch (toupper (SB_AtUnchecked (&SVal, 0))) {
1004 Tok = TOK_OVERRIDE_ABS;
1013 Tok = TOK_OVERRIDE_FAR;
1019 if (CPU == CPU_65816) {
1036 Tok = TOK_OVERRIDE_ZP;
1045 } else if (CPU == CPU_SWEET16 && (IVal = Sweet16Reg (&SVal)) >= 0) {
1047 /* A sweet16 register number in sweet16 mode */
1053 /* Check for define style macro */
1054 if (IsDefine (&SVal)) {
1055 /* Macro - expand it */
1065 /* Ok, let's do the switch */
1083 } else if (CComments) {
1084 /* Remember the position, then skip the '*' */
1085 FilePos Pos = CurPos;
1090 PError (&Pos, "Unterminated comment");
1138 Tok = TOK_NAMESPACE;
1177 while (C != '\n' && C != EOF) {
1222 } else if (C == '<') {
1225 } else if (C == '>') {
1248 } else if (C == '>') {
1262 /* Hack: If we allow ' as terminating character for strings, read
1263 * the following stuff as a string, and check for a one character
1266 if (LooseStringTerm) {
1267 ReadStringConst ('\'');
1268 if (SB_GetLen (&SVal) == 1) {
1269 IVal = SB_AtUnchecked (&SVal, 0);
1275 /* Always a character constant */
1277 if (C == EOF || IsControl (C)) {
1278 Error ("Illegal character constant");
1285 if (!MissingCharTerm) {
1286 Error ("Illegal character constant");
1295 ReadStringConst ('\"');
1300 /* Line continuation? */
1304 /* Handle as white space */
1319 /* In case of the main file, do not close it, but return EOF. */
1320 if (Source && Source->Next) {
1329 /* If we go here, we could not identify the current character. Skip it
1332 Error ("Invalid input character: 0x%02X", C & 0xFF);
1339 int GetSubKey (const char** Keys, unsigned Count)
1340 /* Search for a subkey in a table of keywords. The current token must be an
1341 * identifier and all keys must be in upper case. The identifier will be
1342 * uppercased in the process. The function returns the index of the keyword,
1343 * or -1 if the keyword was not found.
1348 /* Must have an identifier */
1349 PRECONDITION (Tok == TOK_IDENT);
1351 /* If we aren't in ignore case mode, we have to uppercase the identifier */
1356 /* Do a linear search (a binary search is not worth the effort) */
1357 for (I = 0; I < Count; ++I) {
1358 if (SB_CompareStr (&SVal, Keys [I]) == 0) {
1370 unsigned char ParseAddrSize (void)
1371 /* Check if the next token is a keyword that denotes an address size specifier.
1372 * If so, return the corresponding address size constant, otherwise output an
1373 * error message and return ADDR_SIZE_DEFAULT.
1376 unsigned char AddrSize;
1378 /* Check for an identifier */
1379 if (Tok != TOK_IDENT) {
1380 Error ("Address size specifier expected");
1381 return ADDR_SIZE_DEFAULT;
1384 /* Convert the attribute */
1385 AddrSize = AddrSizeFromStr (SB_GetConstBuf (&SVal));
1386 if (AddrSize == ADDR_SIZE_INVALID) {
1387 Error ("Address size specifier expected");
1388 AddrSize = ADDR_SIZE_DEFAULT;
1397 void InitScanner (const char* InFile)
1398 /* Initialize the scanner, open the given input file */
1400 /* Open the input file */
1401 NewInputFile (InFile);
1406 void DoneScanner (void)
1407 /* Release scanner resources */