]> git.sur5r.net Git - cc65/blob - src/cc65/scanner.c
Fixed a bug
[cc65] / src / cc65 / scanner.c
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                 scanner.c                                 */
4 /*                                                                           */
5 /*                      Source file line info structure                      */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 1998-2003 Ullrich von Bassewitz                                       */
10 /*               Römerstrasse 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 #include <stdio.h>
37 #include <stdlib.h>
38 #include <string.h>
39 #include <errno.h>
40 #include <ctype.h>
41
42 /* common */
43 #include "chartype.h"
44 #include "tgttrans.h"
45
46 /* cc65 */
47 #include "datatype.h"
48 #include "error.h"
49 #include "function.h"
50 #include "global.h"
51 #include "hexval.h"
52 #include "ident.h"
53 #include "input.h"
54 #include "litpool.h"
55 #include "preproc.h"
56 #include "symtab.h"
57 #include "util.h"
58 #include "scanner.h"
59
60
61
62 /*****************************************************************************/
63 /*                                   data                                    */
64 /*****************************************************************************/
65
66
67
68 Token CurTok;           /* The current token */
69 Token NextTok;          /* The next token */
70
71
72
73 /* Token types */
74 #define TT_C    0               /* ANSI C token */
75 #define TT_EXT  1               /* cc65 extension */
76
77 /* Token table */
78 static const struct Keyword {
79     char*           Key;        /* Keyword name */
80     unsigned char   Tok;        /* The token */
81     unsigned char   Type;       /* Token type */
82 } Keywords [] = {
83     { "_Pragma",        TOK_PRAGMA,     TT_C    },
84     { "__AX__",         TOK_AX,         TT_C    },
85     { "__A__",          TOK_A,          TT_C    },
86     { "__EAX__",        TOK_EAX,        TT_C    },
87     { "__X__",          TOK_X,          TT_C    },
88     { "__Y__",          TOK_Y,          TT_C    },
89     { "__asm__",        TOK_ASM,        TT_C    },
90     { "__attribute__",  TOK_ATTRIBUTE,  TT_C    },
91     { "__far__",        TOK_FAR,        TT_C    },
92     { "__fastcall__",   TOK_FASTCALL,   TT_C    },
93     { "__near__",       TOK_NEAR,       TT_C    },
94     { "asm",            TOK_ASM,        TT_EXT  },
95     { "auto",           TOK_AUTO,       TT_C    },
96     { "break",          TOK_BREAK,      TT_C    },
97     { "case",           TOK_CASE,       TT_C    },
98     { "char",           TOK_CHAR,       TT_C    },
99     { "const",          TOK_CONST,      TT_C    },
100     { "continue",       TOK_CONTINUE,   TT_C    },
101     { "default",        TOK_DEFAULT,    TT_C    },
102     { "do",             TOK_DO,         TT_C    },
103     { "double",         TOK_DOUBLE,     TT_C    },
104     { "else",           TOK_ELSE,       TT_C    },
105     { "enum",           TOK_ENUM,       TT_C    },
106     { "extern",         TOK_EXTERN,     TT_C    },
107     { "far",            TOK_FAR,        TT_EXT  },
108     { "fastcall",       TOK_FASTCALL,   TT_EXT  },
109     { "float",          TOK_FLOAT,      TT_C    },
110     { "for",            TOK_FOR,        TT_C    },
111     { "goto",           TOK_GOTO,       TT_C    },
112     { "if",             TOK_IF,         TT_C    },
113     { "int",            TOK_INT,        TT_C    },
114     { "long",           TOK_LONG,       TT_C    },
115     { "near",           TOK_NEAR,       TT_EXT  },
116     { "register",       TOK_REGISTER,   TT_C    },
117     { "restrict",       TOK_RESTRICT,   TT_C    },
118     { "return",         TOK_RETURN,     TT_C    },
119     { "short",          TOK_SHORT,      TT_C    },
120     { "signed",         TOK_SIGNED,     TT_C    },
121     { "sizeof",         TOK_SIZEOF,     TT_C    },
122     { "static",         TOK_STATIC,     TT_C    },
123     { "struct",         TOK_STRUCT,     TT_C    },
124     { "switch",         TOK_SWITCH,     TT_C    },
125     { "typedef",        TOK_TYPEDEF,    TT_C    },
126     { "union",          TOK_UNION,      TT_C    },
127     { "unsigned",       TOK_UNSIGNED,   TT_C    },
128     { "void",           TOK_VOID,       TT_C    },
129     { "volatile",       TOK_VOLATILE,   TT_C    },
130     { "while",          TOK_WHILE,      TT_C    },
131 };
132 #define KEY_COUNT       (sizeof (Keywords) / sizeof (Keywords [0]))
133
134
135
136 /* Stuff for determining the type of an integer constant */
137 #define IT_INT          0x01
138 #define IT_UINT         0x02
139 #define IT_LONG         0x04
140 #define IT_ULONG        0x08
141
142
143
144 /*****************************************************************************/
145 /*                                   code                                    */
146 /*****************************************************************************/
147
148
149
150 static int CmpKey (const void* Key, const void* Elem)
151 /* Compare function for bsearch */
152 {
153     return strcmp ((const char*) Key, ((const struct Keyword*) Elem)->Key);
154 }
155
156
157
158 static int FindKey (const char* Key)
159 /* Find a keyword and return the token. Return IDENT if the token is not a
160  * keyword.
161  */
162 {
163     struct Keyword* K;
164     K = bsearch (Key, Keywords, KEY_COUNT, sizeof (Keywords [0]), CmpKey);
165     if (K && (K->Type != TT_EXT || ANSI == 0)) {
166         return K->Tok;
167     } else {
168         return TOK_IDENT;
169     }
170 }
171
172
173
174 static int SkipWhite (void)
175 /* Skip white space in the input stream, reading and preprocessing new lines
176  * if necessary. Return 0 if end of file is reached, return 1 otherwise.
177  */
178 {
179     while (1) {
180         while (CurC == 0) {
181             if (NextLine () == 0) {
182                 return 0;
183             }
184             Preprocess ();
185         }
186         if (IsSpace (CurC)) {
187             NextChar ();
188         } else {
189             return 1;
190         }
191     }
192 }
193
194
195
196 void SymName (char* s)
197 /* Get symbol from input stream */
198 {
199     unsigned k = 0;
200     do {
201         if (k != MAX_IDENTLEN) {
202             ++k;
203             *s++ = CurC;
204         }
205         NextChar ();
206     } while (IsIdent (CurC) || IsDigit (CurC));
207     *s = '\0';
208 }
209
210
211
212 int IsSym (char *s)
213 /* Get symbol from input stream or return 0 if not a symbol. */
214 {
215     if (IsIdent (CurC)) {
216         SymName (s);
217         return 1;
218     } else {
219         return 0;
220     }
221 }
222
223
224
225 static void UnknownChar (char C)
226 /* Error message for unknown character */
227 {
228     Error ("Invalid input character with code %02X", C & 0xFF);
229     NextChar ();                        /* Skip */
230 }
231
232
233
234 static void SetTok (int tok)
235 /* Set NextTok.Tok and bump line ptr */
236 {
237     NextTok.Tok = tok;
238     NextChar ();
239 }
240
241
242
243 static int ParseChar (void)
244 /* Parse a character. Converts \n into EOL, etc. */
245 {
246     int I;
247     unsigned Val;
248     int C;
249
250     /* Check for escape chars */
251     if (CurC == '\\') {
252         NextChar ();
253         switch (CurC) {
254             case 'b':
255                 C = '\b';
256                 break;
257             case 'f':
258                 C = '\f';
259                 break;
260             case 'r':
261                 C = '\r';
262                 break;
263             case 'n':
264                 C = '\n';
265                 break;
266             case 't':
267                 C = '\t';
268                 break;
269             case 'v':
270                 C = '\v';
271                 break;
272             case '\"':
273                 C = '\"';
274                 break;
275             case '\'':
276                 C = '\'';
277                 break;
278             case '\\':
279                 C = '\\';
280                 break;
281             case 'x':
282             case 'X':
283                 /* Hex character constant */
284                 NextChar ();
285                 Val = HexVal (CurC) << 4;
286                 NextChar ();
287                 C = Val | HexVal (CurC);        /* Do not translate */
288                 break;
289             case '0':
290             case '1':
291             case '2':
292             case '3':
293             case '4':
294             case '5':
295             case '6':
296             case '7':
297                 /* Octal constant */
298                 I = 0;
299                 Val = CurC - '0';
300                 while (NextC >= '0' && NextC <= '7' && ++I <= 3) {
301                     NextChar ();
302                     Val = (Val << 3) | (CurC - '0');
303                 }
304                 C = (int) Val;
305                 if (Val >= 256) {
306                     Error ("Character constant out of range");
307                     C = ' ';
308                 }
309                 break;
310             default:
311                 Error ("Illegal character constant");
312                 C = ' ';
313                 /* Try to do error recovery, otherwise the compiler will spit
314                  * out thousands of errors in this place and abort.
315                  */
316                 if (CurC != '\'' && CurC != '\0') {
317                     while (NextC != '\'' && NextC != '\"' && NextC != '\0') {
318                         NextChar ();
319                     }
320                 }
321                 break;
322         }
323     } else {
324         C = CurC;
325     }
326
327     /* Skip the character read */
328     NextChar ();
329
330     /* Do correct sign extension */
331     return SignExtendChar (C);
332 }
333
334
335
336 static void CharConst (void)
337 /* Parse a character constant. */
338 {
339     int C;
340
341     /* Skip the quote */
342     NextChar ();
343
344     /* Get character */
345     C = ParseChar ();
346
347     /* Check for closing quote */
348     if (CurC != '\'') {
349         Error ("`\'' expected");
350     } else {
351         /* Skip the quote */
352         NextChar ();
353     }
354
355     /* Setup values and attributes */
356     NextTok.Tok  = TOK_CCONST;
357
358     /* Translate into target charset */
359     NextTok.IVal = SignExtendChar (TgtTranslateChar (C));
360
361     /* Character constants have type int */
362     NextTok.Type = type_int;
363 }
364
365
366
367 static void StringConst (void)
368 /* Parse a quoted string */
369 {
370     NextTok.IVal = GetLiteralPoolOffs ();
371     NextTok.Tok  = TOK_SCONST;
372
373     /* Be sure to concatenate strings */
374     while (CurC == '\"') {
375
376         /* Skip the quote char */
377         NextChar ();
378
379         while (CurC != '\"') {
380             if (CurC == '\0') {
381                 Error ("Unexpected newline");
382                 break;
383             }
384             AddLiteralChar (ParseChar ());
385         }
386
387         /* Skip closing quote char if there was one */
388         NextChar ();
389
390         /* Skip white space, read new input */
391         SkipWhite ();
392
393     }
394
395     /* Terminate the string */
396     AddLiteralChar ('\0');
397 }
398
399
400
401 void NextToken (void)
402 /* Get next token from input stream */
403 {
404     ident token;
405
406     /* We have to skip white space here before shifting tokens, since the
407      * tokens and the current line info is invalid at startup and will get
408      * initialized by reading the first time from the file. Remember if
409      * we were at end of input and handle that later.
410      */
411     int GotEOF = (SkipWhite() == 0);
412
413     /* Current token is the lookahead token */
414     if (CurTok.LI) {
415         ReleaseLineInfo (CurTok.LI);
416     }
417     CurTok = NextTok;
418
419     /* When reading the first time from the file, the line info in NextTok,
420      * which was copied to CurTok is invalid. Since the information from
421      * the token is used for error messages, we must make it valid.
422      */
423     if (CurTok.LI == 0) {
424         CurTok.LI = UseLineInfo (GetCurLineInfo ());
425     }
426
427     /* Remember the starting position of the next token */
428     NextTok.LI = UseLineInfo (GetCurLineInfo ());
429
430     /* Now handle end of input. */
431     if (GotEOF) {
432         /* End of file reached */
433         NextTok.Tok = TOK_CEOF;
434         return;
435     }
436
437     /* Determine the next token from the lookahead */
438     if (IsDigit (CurC)) {
439
440         /* A number */
441         int HaveSuffix;         /* True if we have a type suffix */
442         unsigned types;         /* Possible types */
443         unsigned Base;
444         unsigned DigitVal;
445         unsigned long k;        /* Value */
446
447         k     = 0;
448         Base  = 10;
449         types = IT_INT | IT_LONG | IT_ULONG;
450
451         if (CurC == '0') {
452             /* Octal or hex constants may also be of type unsigned int */
453             types = IT_INT | IT_UINT | IT_LONG | IT_ULONG;
454             /* gobble 0 and examin next char */
455             NextChar ();
456             if (toupper (CurC) == 'X') {
457                 Base = 16;
458                 NextTok.Type = type_uint;
459                 NextChar ();    /* gobble "x" */
460             } else {
461                 Base = 8;
462             }
463         }
464         while (IsXDigit (CurC) && (DigitVal = HexVal (CurC)) < Base) {
465             k = k * Base + DigitVal;
466             NextChar ();
467         }
468         /* Check for errorneous digits */
469         if (Base == 8 && IsDigit (CurC)) {
470             Error ("Numeric constant contains digits beyond the radix");
471             /* Do error recovery */
472             do {
473                 NextChar ();
474             } while (IsDigit (CurC));
475         } else if (Base != 16 && IsXDigit (CurC)) {
476             Error ("Nondigits in number and not hexadecimal");
477             do {
478                 NextChar ();
479             } while (IsXDigit (CurC));
480         }
481
482         /* Check for a suffix */
483         HaveSuffix = 1;
484         if (CurC == 'u' || CurC == 'U') {
485             /* Unsigned type */
486             NextChar ();
487             if (toupper (CurC) != 'L') {
488                 types = IT_UINT | IT_ULONG;
489             } else {
490                 NextChar ();
491                 types = IT_ULONG;
492             }
493         } else if (CurC == 'l' || CurC == 'L') {
494             /* Long type */
495             NextChar ();
496             if (toupper (CurC) != 'U') {
497                 types = IT_LONG | IT_ULONG;
498             } else {
499                 NextChar ();
500                 types = IT_ULONG;
501             }
502         } else {
503             HaveSuffix = 0;
504         }
505
506         /* Check the range to determine the type */
507         if (k > 0x7FFF) {
508             /* Out of range for int */
509             types &= ~IT_INT;
510             /* If the value is in the range 0x8000..0xFFFF, unsigned int is not
511              * allowed, and we don't have a type specifying suffix, emit a
512              * warning.
513              */
514             if (k <= 0xFFFF && (types & IT_UINT) == 0 && !HaveSuffix) {
515                 Warning ("Constant is long");
516             }
517         }
518         if (k > 0xFFFF) {
519             /* Out of range for unsigned int */
520             types &= ~IT_UINT;
521         }
522         if (k > 0x7FFFFFFF) {
523             /* Out of range for long int */
524             types &= ~IT_LONG;
525         }
526
527         /* Now set the type string to the smallest type in types */
528         if (types & IT_INT) {
529             NextTok.Type = type_int;
530         } else if (types & IT_UINT) {
531             NextTok.Type = type_uint;
532         } else if (types & IT_LONG) {
533             NextTok.Type = type_long;
534         } else {
535             NextTok.Type = type_ulong;
536         }
537
538         /* Set the value and the token */
539         NextTok.IVal = k;
540         NextTok.Tok  = TOK_ICONST;
541         return;
542     }
543
544     if (IsSym (token)) {
545
546         /* Check for a keyword */
547         if ((NextTok.Tok = FindKey (token)) != TOK_IDENT) {
548             /* Reserved word found */
549             return;
550         }
551         /* No reserved word, check for special symbols */
552         if (token [0] == '_') {
553             /* Special symbols */
554             if (strcmp (token, "__FILE__") == 0) {
555                 NextTok.IVal = AddLiteral (GetCurrentFile());
556                 NextTok.Tok  = TOK_SCONST;
557                 return;
558             } else if (strcmp (token, "__LINE__") == 0) {
559                 NextTok.Tok  = TOK_ICONST;
560                 NextTok.IVal = GetCurrentLine();
561                 NextTok.Type = type_int;
562                 return;
563             } else if (strcmp (token, "__func__") == 0) {
564                 /* __func__ is only defined in functions */
565                 if (CurrentFunc) {
566                     NextTok.IVal = AddLiteral (F_GetFuncName (CurrentFunc));
567                     NextTok.Tok  = TOK_SCONST;
568                     return;
569                 }
570             }
571         }
572
573         /* No reserved word but identifier */
574         strcpy (NextTok.Ident, token);
575         NextTok.Tok = TOK_IDENT;
576         return;
577     }
578
579     /* Monstrous switch statement ahead... */
580     switch (CurC) {
581
582         case '!':
583             NextChar ();
584             if (CurC == '=') {
585                 SetTok (TOK_NE);
586             } else {
587                 NextTok.Tok = TOK_BOOL_NOT;
588             }
589             break;
590
591         case '\"':
592             StringConst ();
593             break;
594
595         case '%':
596             NextChar ();
597             if (CurC == '=') {
598                 SetTok (TOK_MOD_ASSIGN);
599             } else {
600                 NextTok.Tok = TOK_MOD;
601             }
602             break;
603
604         case '&':
605             NextChar ();
606             switch (CurC) {
607                 case '&':
608                     SetTok (TOK_BOOL_AND);
609                     break;
610                 case '=':
611                     SetTok (TOK_AND_ASSIGN);
612                     break;
613                 default:
614                     NextTok.Tok = TOK_AND;
615             }
616             break;
617
618         case '\'':
619             CharConst ();
620             break;
621
622         case '(':
623             SetTok (TOK_LPAREN);
624             break;
625
626         case ')':
627             SetTok (TOK_RPAREN);
628             break;
629
630         case '*':
631             NextChar ();
632             if (CurC == '=') {
633                 SetTok (TOK_MUL_ASSIGN);
634             } else {
635                 NextTok.Tok = TOK_STAR;
636             }
637             break;
638
639         case '+':
640             NextChar ();
641             switch (CurC) {
642                 case '+':
643                     SetTok (TOK_INC);
644                     break;
645                 case '=':
646                     SetTok (TOK_PLUS_ASSIGN);
647                     break;
648                 default:
649                     NextTok.Tok = TOK_PLUS;
650             }
651             break;
652
653         case ',':
654             SetTok (TOK_COMMA);
655             break;
656
657         case '-':
658             NextChar ();
659             switch (CurC) {
660                 case '-':
661                     SetTok (TOK_DEC);
662                     break;
663                 case '=':
664                     SetTok (TOK_MINUS_ASSIGN);
665                     break;
666                 case '>':
667                     SetTok (TOK_PTR_REF);
668                     break;
669                 default:
670                     NextTok.Tok = TOK_MINUS;
671             }
672             break;
673
674         case '.':
675             NextChar ();
676             if (CurC == '.') {
677                 NextChar ();
678                 if (CurC == '.') {
679                     SetTok (TOK_ELLIPSIS);
680                 } else {
681                     UnknownChar (CurC);
682                 }
683             } else {
684                 NextTok.Tok = TOK_DOT;
685             }
686             break;
687
688         case '/':
689             NextChar ();
690             if (CurC == '=') {
691                 SetTok (TOK_DIV_ASSIGN);
692             } else {
693                 NextTok.Tok = TOK_DIV;
694             }
695             break;
696
697         case ':':
698             SetTok (TOK_COLON);
699             break;
700
701         case ';':
702             SetTok (TOK_SEMI);
703             break;
704
705         case '<':
706             NextChar ();
707             switch (CurC) {
708                 case '=':
709                     SetTok (TOK_LE);
710                     break;
711                 case '<':
712                     NextChar ();
713                     if (CurC == '=') {
714                         SetTok (TOK_SHL_ASSIGN);
715                     } else {
716                         NextTok.Tok = TOK_SHL;
717                     }
718                     break;
719                 default:
720                     NextTok.Tok = TOK_LT;
721             }
722             break;
723
724         case '=':
725             NextChar ();
726             if (CurC == '=') {
727                 SetTok (TOK_EQ);
728             } else {
729                 NextTok.Tok = TOK_ASSIGN;
730             }
731             break;
732
733         case '>':
734             NextChar ();
735             switch (CurC) {
736                 case '=':
737                     SetTok (TOK_GE);
738                     break;
739                 case '>':
740                     NextChar ();
741                     if (CurC == '=') {
742                         SetTok (TOK_SHR_ASSIGN);
743                     } else {
744                         NextTok.Tok = TOK_SHR;
745                     }
746                     break;
747                 default:
748                     NextTok.Tok = TOK_GT;
749             }
750             break;
751
752         case '?':
753             SetTok (TOK_QUEST);
754             break;
755
756         case '[':
757             SetTok (TOK_LBRACK);
758             break;
759
760         case ']':
761             SetTok (TOK_RBRACK);
762             break;
763
764         case '^':
765             NextChar ();
766             if (CurC == '=') {
767                 SetTok (TOK_XOR_ASSIGN);
768             } else {
769                 NextTok.Tok = TOK_XOR;
770             }
771             break;
772
773         case '{':
774             SetTok (TOK_LCURLY);
775             break;
776
777         case '|':
778             NextChar ();
779             switch (CurC) {
780                 case '|':
781                     SetTok (TOK_BOOL_OR);
782                     break;
783                 case '=':
784                     SetTok (TOK_OR_ASSIGN);
785                     break;
786                 default:
787                     NextTok.Tok = TOK_OR;
788             }
789             break;
790
791         case '}':
792             SetTok (TOK_RCURLY);
793             break;
794
795         case '~':
796             SetTok (TOK_COMP);
797             break;
798
799         default:
800             UnknownChar (CurC);
801
802     }
803
804 }
805
806
807
808 void SkipTokens (const token_t* TokenList, unsigned TokenCount)
809 /* Skip tokens until we reach TOK_CEOF or a token in the given token list.
810  * This routine is used for error recovery.
811  */
812 {
813     while (CurTok.Tok != TOK_CEOF) {
814
815         /* Check if the current token is in the token list */
816         unsigned I;
817         for (I = 0; I < TokenCount; ++I) {
818             if (CurTok.Tok == TokenList[I]) {
819                 /* Found a token in the list */
820                 return;
821             }
822         }
823
824         /* Not in the list: Skip it */
825         NextToken ();
826
827     }
828 }
829
830
831
832 int Consume (token_t Token, const char* ErrorMsg)
833 /* Eat token if it is the next in the input stream, otherwise print an error
834  * message. Returns true if the token was found and false otherwise.
835  */
836 {
837     if (CurTok.Tok == Token) {
838         NextToken ();
839         return 1;
840     } else {
841         Error (ErrorMsg);
842         return 0;
843     }
844 }
845
846
847
848 int ConsumeColon (void)
849 /* Check for a colon and skip it. */
850 {
851     return Consume (TOK_COLON, "`:' expected");
852 }
853
854
855
856 int ConsumeSemi (void)
857 /* Check for a semicolon and skip it. */
858 {
859     /* Try do be smart about typos... */
860     if (CurTok.Tok == TOK_SEMI) {
861         NextToken ();
862         return 1;
863     } else {
864         Error ("`;' expected");
865         if (CurTok.Tok == TOK_COLON || CurTok.Tok == TOK_COMMA) {
866             NextToken ();
867         }
868         return 0;
869     }
870 }
871
872
873
874 int ConsumeComma (void)
875 /* Check for a comma and skip it. */
876 {
877     /* Try do be smart about typos... */
878     if (CurTok.Tok == TOK_COMMA) {
879         NextToken ();
880         return 1;
881     } else {
882         Error ("`,' expected");
883         if (CurTok.Tok == TOK_SEMI) {
884             NextToken ();
885         }
886         return 0;
887     }
888 }
889
890
891
892 int ConsumeLParen (void)
893 /* Check for a left parenthesis and skip it */
894 {
895     return Consume (TOK_LPAREN, "`(' expected");
896 }
897
898
899
900 int ConsumeRParen (void)
901 /* Check for a right parenthesis and skip it */
902 {
903     return Consume (TOK_RPAREN, "`)' expected");
904 }
905
906
907
908 int ConsumeLBrack (void)
909 /* Check for a left bracket and skip it */
910 {
911     return Consume (TOK_LBRACK, "`[' expected");
912 }
913
914
915
916 int ConsumeRBrack (void)
917 /* Check for a right bracket and skip it */
918 {
919     return Consume (TOK_RBRACK, "`]' expected");
920 }
921
922
923
924 int ConsumeLCurly (void)
925 /* Check for a left curly brace and skip it */
926 {
927     return Consume (TOK_LCURLY, "`{' expected");
928 }
929
930
931
932 int ConsumeRCurly (void)
933 /* Check for a right curly brace and skip it */
934 {
935     return Consume (TOK_RCURLY, "`}' expected");
936 }
937
938
939