xref: /linux/scripts/genksyms/lex.l (revision dc53324060f324e8af6867f57bf4891c13c6ef18)
11da177e4SLinus Torvalds /* Lexical analysis for genksyms.
21da177e4SLinus Torvalds    Copyright 1996, 1997 Linux International.
31da177e4SLinus Torvalds 
41da177e4SLinus Torvalds    New implementation contributed by Richard Henderson <rth@tamu.edu>
51da177e4SLinus Torvalds    Based on original work by Bjorn Ekwall <bj0rn@blox.se>
61da177e4SLinus Torvalds 
71da177e4SLinus Torvalds    Taken from Linux modutils 2.4.22.
81da177e4SLinus Torvalds 
91da177e4SLinus Torvalds    This program is free software; you can redistribute it and/or modify it
101da177e4SLinus Torvalds    under the terms of the GNU General Public License as published by the
111da177e4SLinus Torvalds    Free Software Foundation; either version 2 of the License, or (at your
121da177e4SLinus Torvalds    option) any later version.
131da177e4SLinus Torvalds 
141da177e4SLinus Torvalds    This program is distributed in the hope that it will be useful, but
151da177e4SLinus Torvalds    WITHOUT ANY WARRANTY; without even the implied warranty of
161da177e4SLinus Torvalds    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
171da177e4SLinus Torvalds    General Public License for more details.
181da177e4SLinus Torvalds 
191da177e4SLinus Torvalds    You should have received a copy of the GNU General Public License
201da177e4SLinus Torvalds    along with this program; if not, write to the Free Software Foundation,
211da177e4SLinus Torvalds    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
221da177e4SLinus Torvalds 
231da177e4SLinus Torvalds 
241da177e4SLinus Torvalds %{
251da177e4SLinus Torvalds 
261da177e4SLinus Torvalds #include <limits.h>
271da177e4SLinus Torvalds #include <stdlib.h>
281da177e4SLinus Torvalds #include <string.h>
291da177e4SLinus Torvalds #include <ctype.h>
301da177e4SLinus Torvalds 
311da177e4SLinus Torvalds #include "genksyms.h"
32880f4499SArnaud Lacombe #include "parse.tab.h"
331da177e4SLinus Torvalds 
341da177e4SLinus Torvalds /* We've got a two-level lexer here.  We let flex do basic tokenization
351da177e4SLinus Torvalds    and then we categorize those basic tokens in the second stage.  */
361da177e4SLinus Torvalds #define YY_DECL		static int yylex1(void)
371da177e4SLinus Torvalds 
381da177e4SLinus Torvalds %}
391da177e4SLinus Torvalds 
401da177e4SLinus Torvalds IDENT			[A-Za-z_\$][A-Za-z0-9_\$]*
411da177e4SLinus Torvalds 
421da177e4SLinus Torvalds O_INT			0[0-7]*
431da177e4SLinus Torvalds D_INT			[1-9][0-9]*
441da177e4SLinus Torvalds X_INT			0[Xx][0-9A-Fa-f]+
451da177e4SLinus Torvalds I_SUF			[Uu]|[Ll]|[Uu][Ll]|[Ll][Uu]
461da177e4SLinus Torvalds INT			({O_INT}|{D_INT}|{X_INT}){I_SUF}?
471da177e4SLinus Torvalds 
481da177e4SLinus Torvalds FRAC			([0-9]*\.[0-9]+)|([0-9]+\.)
491da177e4SLinus Torvalds EXP			[Ee][+-]?[0-9]+
501da177e4SLinus Torvalds F_SUF			[FfLl]
511da177e4SLinus Torvalds REAL			({FRAC}{EXP}?{F_SUF}?)|([0-9]+{EXP}{F_SUF}?)
521da177e4SLinus Torvalds 
531da177e4SLinus Torvalds STRING			L?\"([^\\\"]*\\.)*[^\\\"]*\"
541da177e4SLinus Torvalds CHAR			L?\'([^\\\']*\\.)*[^\\\']*\'
551da177e4SLinus Torvalds 
561da177e4SLinus Torvalds MC_TOKEN		([~%^&*+=|<>/-]=)|(&&)|("||")|(->)|(<<)|(>>)
571da177e4SLinus Torvalds 
581da177e4SLinus Torvalds /* We don't do multiple input files.  */
591da177e4SLinus Torvalds %option noyywrap
601da177e4SLinus Torvalds 
6111ddad39SAdrian Bunk %option noinput
6211ddad39SAdrian Bunk 
631da177e4SLinus Torvalds %%
641da177e4SLinus Torvalds 
651da177e4SLinus Torvalds 
661da177e4SLinus Torvalds  /* Keep track of our location in the original source files.  */
671da177e4SLinus Torvalds ^#[ \t]+{INT}[ \t]+\"[^\"\n]+\".*\n	return FILENAME;
681da177e4SLinus Torvalds ^#.*\n					cur_line++;
691da177e4SLinus Torvalds \n					cur_line++;
701da177e4SLinus Torvalds 
711da177e4SLinus Torvalds  /* Ignore all other whitespace.  */
721da177e4SLinus Torvalds [ \t\f\v\r]+				;
731da177e4SLinus Torvalds 
741da177e4SLinus Torvalds 
751da177e4SLinus Torvalds {STRING}				return STRING;
761da177e4SLinus Torvalds {CHAR}					return CHAR;
771da177e4SLinus Torvalds {IDENT}					return IDENT;
781da177e4SLinus Torvalds 
791da177e4SLinus Torvalds  /* The Pedant requires that the other C multi-character tokens be
801da177e4SLinus Torvalds     recognized as tokens.  We don't actually use them since we don't
811da177e4SLinus Torvalds     parse expressions, but we do want whitespace to be arranged
821da177e4SLinus Torvalds     around them properly.  */
8395f1d639SMichal Marek {MC_TOKEN}				return OTHER;
8495f1d639SMichal Marek {INT}					return INT;
8595f1d639SMichal Marek {REAL}					return REAL;
861da177e4SLinus Torvalds 
871da177e4SLinus Torvalds "..."					return DOTS;
881da177e4SLinus Torvalds 
891da177e4SLinus Torvalds  /* All other tokens are single characters.  */
901da177e4SLinus Torvalds .					return yytext[0];
911da177e4SLinus Torvalds 
921da177e4SLinus Torvalds 
931da177e4SLinus Torvalds %%
941da177e4SLinus Torvalds 
951da177e4SLinus Torvalds /* Bring in the keyword recognizer.  */
961da177e4SLinus Torvalds 
97880f4499SArnaud Lacombe #include "keywords.hash.c"
981da177e4SLinus Torvalds 
991da177e4SLinus Torvalds 
1001da177e4SLinus Torvalds /* Macros to append to our phrase collection list.  */
1011da177e4SLinus Torvalds 
102e37ddb82SMichal Marek /*
103e37ddb82SMichal Marek  * We mark any token, that that equals to a known enumerator, as
104e37ddb82SMichal Marek  * SYM_ENUM_CONST. The parser will change this for struct and union tags later,
105e37ddb82SMichal Marek  * the only problem is struct and union members:
106e37ddb82SMichal Marek  *    enum e { a, b }; struct s { int a, b; }
107e37ddb82SMichal Marek  * but in this case, the only effect will be, that the ABI checksums become
108e37ddb82SMichal Marek  * more volatile, which is acceptable. Also, such collisions are quite rare,
109e37ddb82SMichal Marek  * so far it was only observed in include/linux/telephony.h.
110e37ddb82SMichal Marek  */
1111da177e4SLinus Torvalds #define _APP(T,L)	do {						   \
1121da177e4SLinus Torvalds 			  cur_node = next_node;				   \
1131da177e4SLinus Torvalds 			  next_node = xmalloc(sizeof(*next_node));	   \
1141da177e4SLinus Torvalds 			  next_node->next = cur_node;			   \
1151da177e4SLinus Torvalds 			  cur_node->string = memcpy(xmalloc(L+1), T, L+1); \
116e37ddb82SMichal Marek 			  cur_node->tag =				   \
117e37ddb82SMichal Marek 			    find_symbol(cur_node->string, SYM_ENUM_CONST, 1)?\
118e37ddb82SMichal Marek 			    SYM_ENUM_CONST : SYM_NORMAL ;		   \
1192c5925d6SMichal Marek 			  cur_node->in_source_file = in_source_file;       \
1201da177e4SLinus Torvalds 			} while (0)
1211da177e4SLinus Torvalds 
1221da177e4SLinus Torvalds #define APP		_APP(yytext, yyleng)
1231da177e4SLinus Torvalds 
1241da177e4SLinus Torvalds 
1251da177e4SLinus Torvalds /* The second stage lexer.  Here we incorporate knowledge of the state
1261da177e4SLinus Torvalds    of the parser to tailor the tokens that are returned.  */
1271da177e4SLinus Torvalds 
1281da177e4SLinus Torvalds int
1291da177e4SLinus Torvalds yylex(void)
1301da177e4SLinus Torvalds {
1311da177e4SLinus Torvalds   static enum {
132*dc533240SJan Beulich     ST_NOTSTARTED, ST_NORMAL, ST_ATTRIBUTE, ST_ASM, ST_TYPEOF, ST_TYPEOF_1,
133*dc533240SJan Beulich     ST_BRACKET, ST_BRACE, ST_EXPRESSION,
134*dc533240SJan Beulich     ST_TABLE_1, ST_TABLE_2, ST_TABLE_3, ST_TABLE_4,
1351da177e4SLinus Torvalds     ST_TABLE_5, ST_TABLE_6
1361da177e4SLinus Torvalds   } lexstate = ST_NOTSTARTED;
1371da177e4SLinus Torvalds 
1381da177e4SLinus Torvalds   static int suppress_type_lookup, dont_want_brace_phrase;
1391da177e4SLinus Torvalds   static struct string_list *next_node;
1401da177e4SLinus Torvalds 
1411da177e4SLinus Torvalds   int token, count = 0;
1421da177e4SLinus Torvalds   struct string_list *cur_node;
1431da177e4SLinus Torvalds 
1441da177e4SLinus Torvalds   if (lexstate == ST_NOTSTARTED)
1451da177e4SLinus Torvalds     {
1461da177e4SLinus Torvalds       next_node = xmalloc(sizeof(*next_node));
1471da177e4SLinus Torvalds       next_node->next = NULL;
1481da177e4SLinus Torvalds       lexstate = ST_NORMAL;
1491da177e4SLinus Torvalds     }
1501da177e4SLinus Torvalds 
1511da177e4SLinus Torvalds repeat:
1521da177e4SLinus Torvalds   token = yylex1();
1531da177e4SLinus Torvalds 
1541da177e4SLinus Torvalds   if (token == 0)
1551da177e4SLinus Torvalds     return 0;
1561da177e4SLinus Torvalds   else if (token == FILENAME)
1571da177e4SLinus Torvalds     {
1581da177e4SLinus Torvalds       char *file, *e;
1591da177e4SLinus Torvalds 
1601da177e4SLinus Torvalds       /* Save the filename and line number for later error messages.  */
1611da177e4SLinus Torvalds 
1621da177e4SLinus Torvalds       if (cur_filename)
1631da177e4SLinus Torvalds 	free(cur_filename);
1641da177e4SLinus Torvalds 
1651da177e4SLinus Torvalds       file = strchr(yytext, '\"')+1;
1661da177e4SLinus Torvalds       e = strchr(file, '\"');
1671da177e4SLinus Torvalds       *e = '\0';
1681da177e4SLinus Torvalds       cur_filename = memcpy(xmalloc(e-file+1), file, e-file+1);
1691da177e4SLinus Torvalds       cur_line = atoi(yytext+2);
1701da177e4SLinus Torvalds 
1712c5925d6SMichal Marek       if (!source_file) {
1722c5925d6SMichal Marek         source_file = xstrdup(cur_filename);
1732c5925d6SMichal Marek         in_source_file = 1;
1742c5925d6SMichal Marek       } else {
1752c5925d6SMichal Marek         in_source_file = (strcmp(cur_filename, source_file) == 0);
1762c5925d6SMichal Marek       }
1772c5925d6SMichal Marek 
1781da177e4SLinus Torvalds       goto repeat;
1791da177e4SLinus Torvalds     }
1801da177e4SLinus Torvalds 
1811da177e4SLinus Torvalds   switch (lexstate)
1821da177e4SLinus Torvalds     {
1831da177e4SLinus Torvalds     case ST_NORMAL:
1841da177e4SLinus Torvalds       switch (token)
1851da177e4SLinus Torvalds 	{
1861da177e4SLinus Torvalds 	case IDENT:
1871da177e4SLinus Torvalds 	  APP;
1881da177e4SLinus Torvalds 	  {
1891da177e4SLinus Torvalds 	    const struct resword *r = is_reserved_word(yytext, yyleng);
1901da177e4SLinus Torvalds 	    if (r)
1911da177e4SLinus Torvalds 	      {
1921da177e4SLinus Torvalds 		switch (token = r->token)
1931da177e4SLinus Torvalds 		  {
1941da177e4SLinus Torvalds 		  case ATTRIBUTE_KEYW:
1951da177e4SLinus Torvalds 		    lexstate = ST_ATTRIBUTE;
1961da177e4SLinus Torvalds 		    count = 0;
1971da177e4SLinus Torvalds 		    goto repeat;
1981da177e4SLinus Torvalds 		  case ASM_KEYW:
1991da177e4SLinus Torvalds 		    lexstate = ST_ASM;
2001da177e4SLinus Torvalds 		    count = 0;
2011da177e4SLinus Torvalds 		    goto repeat;
202*dc533240SJan Beulich 		  case TYPEOF_KEYW:
203*dc533240SJan Beulich 		    lexstate = ST_TYPEOF;
204*dc533240SJan Beulich 		    count = 0;
205*dc533240SJan Beulich 		    goto repeat;
2061da177e4SLinus Torvalds 
2071da177e4SLinus Torvalds 		  case STRUCT_KEYW:
2081da177e4SLinus Torvalds 		  case UNION_KEYW:
2091da177e4SLinus Torvalds 		  case ENUM_KEYW:
210e37ddb82SMichal Marek 		    dont_want_brace_phrase = 3;
2111da177e4SLinus Torvalds 		    suppress_type_lookup = 2;
2121da177e4SLinus Torvalds 		    goto fini;
2131da177e4SLinus Torvalds 
2141da177e4SLinus Torvalds 		  case EXPORT_SYMBOL_KEYW:
2151da177e4SLinus Torvalds 		      goto fini;
2161da177e4SLinus Torvalds 		  }
2171da177e4SLinus Torvalds 	      }
2181da177e4SLinus Torvalds 	    if (!suppress_type_lookup)
2191da177e4SLinus Torvalds 	      {
22001762c4eSMichal Marek 		if (find_symbol(yytext, SYM_TYPEDEF, 1))
2211da177e4SLinus Torvalds 		  token = TYPE;
2221da177e4SLinus Torvalds 	      }
2231da177e4SLinus Torvalds 	  }
2241da177e4SLinus Torvalds 	  break;
2251da177e4SLinus Torvalds 
2261da177e4SLinus Torvalds 	case '[':
2271da177e4SLinus Torvalds 	  APP;
2281da177e4SLinus Torvalds 	  lexstate = ST_BRACKET;
2291da177e4SLinus Torvalds 	  count = 1;
2301da177e4SLinus Torvalds 	  goto repeat;
2311da177e4SLinus Torvalds 
2321da177e4SLinus Torvalds 	case '{':
2331da177e4SLinus Torvalds 	  APP;
2341da177e4SLinus Torvalds 	  if (dont_want_brace_phrase)
2351da177e4SLinus Torvalds 	    break;
2361da177e4SLinus Torvalds 	  lexstate = ST_BRACE;
2371da177e4SLinus Torvalds 	  count = 1;
2381da177e4SLinus Torvalds 	  goto repeat;
2391da177e4SLinus Torvalds 
2401da177e4SLinus Torvalds 	case '=': case ':':
2411da177e4SLinus Torvalds 	  APP;
2421da177e4SLinus Torvalds 	  lexstate = ST_EXPRESSION;
2431da177e4SLinus Torvalds 	  break;
2441da177e4SLinus Torvalds 
2451da177e4SLinus Torvalds 	case DOTS:
2461da177e4SLinus Torvalds 	default:
2471da177e4SLinus Torvalds 	  APP;
2481da177e4SLinus Torvalds 	  break;
2491da177e4SLinus Torvalds 	}
2501da177e4SLinus Torvalds       break;
2511da177e4SLinus Torvalds 
2521da177e4SLinus Torvalds     case ST_ATTRIBUTE:
2531da177e4SLinus Torvalds       APP;
2541da177e4SLinus Torvalds       switch (token)
2551da177e4SLinus Torvalds 	{
2561da177e4SLinus Torvalds 	case '(':
2571da177e4SLinus Torvalds 	  ++count;
2581da177e4SLinus Torvalds 	  goto repeat;
2591da177e4SLinus Torvalds 	case ')':
2601da177e4SLinus Torvalds 	  if (--count == 0)
2611da177e4SLinus Torvalds 	    {
2621da177e4SLinus Torvalds 	      lexstate = ST_NORMAL;
2631da177e4SLinus Torvalds 	      token = ATTRIBUTE_PHRASE;
2641da177e4SLinus Torvalds 	      break;
2651da177e4SLinus Torvalds 	    }
2661da177e4SLinus Torvalds 	  goto repeat;
2671da177e4SLinus Torvalds 	default:
2681da177e4SLinus Torvalds 	  goto repeat;
2691da177e4SLinus Torvalds 	}
2701da177e4SLinus Torvalds       break;
2711da177e4SLinus Torvalds 
2721da177e4SLinus Torvalds     case ST_ASM:
2731da177e4SLinus Torvalds       APP;
2741da177e4SLinus Torvalds       switch (token)
2751da177e4SLinus Torvalds 	{
2761da177e4SLinus Torvalds 	case '(':
2771da177e4SLinus Torvalds 	  ++count;
2781da177e4SLinus Torvalds 	  goto repeat;
2791da177e4SLinus Torvalds 	case ')':
2801da177e4SLinus Torvalds 	  if (--count == 0)
2811da177e4SLinus Torvalds 	    {
2821da177e4SLinus Torvalds 	      lexstate = ST_NORMAL;
2831da177e4SLinus Torvalds 	      token = ASM_PHRASE;
2841da177e4SLinus Torvalds 	      break;
2851da177e4SLinus Torvalds 	    }
2861da177e4SLinus Torvalds 	  goto repeat;
2871da177e4SLinus Torvalds 	default:
2881da177e4SLinus Torvalds 	  goto repeat;
2891da177e4SLinus Torvalds 	}
2901da177e4SLinus Torvalds       break;
2911da177e4SLinus Torvalds 
292*dc533240SJan Beulich     case ST_TYPEOF:
293*dc533240SJan Beulich       switch (token)
294*dc533240SJan Beulich 	{
295*dc533240SJan Beulich 	case '(':
296*dc533240SJan Beulich 	  if ( ++count == 1 )
297*dc533240SJan Beulich 	    lexstate = ST_TYPEOF_1;
298*dc533240SJan Beulich 	  else
299*dc533240SJan Beulich 	    APP;
300*dc533240SJan Beulich 	  goto repeat;
301*dc533240SJan Beulich 	case ')':
302*dc533240SJan Beulich 	  APP;
303*dc533240SJan Beulich 	  if (--count == 0)
304*dc533240SJan Beulich 	    {
305*dc533240SJan Beulich 	      lexstate = ST_NORMAL;
306*dc533240SJan Beulich 	      token = TYPEOF_PHRASE;
307*dc533240SJan Beulich 	      break;
308*dc533240SJan Beulich 	    }
309*dc533240SJan Beulich 	  goto repeat;
310*dc533240SJan Beulich 	default:
311*dc533240SJan Beulich 	  APP;
312*dc533240SJan Beulich 	  goto repeat;
313*dc533240SJan Beulich 	}
314*dc533240SJan Beulich       break;
315*dc533240SJan Beulich 
316*dc533240SJan Beulich     case ST_TYPEOF_1:
317*dc533240SJan Beulich       if (token == IDENT)
318*dc533240SJan Beulich 	{
319*dc533240SJan Beulich 	  if (is_reserved_word(yytext, yyleng)
320*dc533240SJan Beulich 	      || find_symbol(yytext, SYM_TYPEDEF, 1))
321*dc533240SJan Beulich 	    {
322*dc533240SJan Beulich 	      yyless(0);
323*dc533240SJan Beulich 	      unput('(');
324*dc533240SJan Beulich 	      lexstate = ST_NORMAL;
325*dc533240SJan Beulich 	      token = TYPEOF_KEYW;
326*dc533240SJan Beulich 	      break;
327*dc533240SJan Beulich 	    }
328*dc533240SJan Beulich 	  _APP("(", 1);
329*dc533240SJan Beulich 	}
330*dc533240SJan Beulich 	APP;
331*dc533240SJan Beulich 	lexstate = ST_TYPEOF;
332*dc533240SJan Beulich 	goto repeat;
333*dc533240SJan Beulich 
3341da177e4SLinus Torvalds     case ST_BRACKET:
3351da177e4SLinus Torvalds       APP;
3361da177e4SLinus Torvalds       switch (token)
3371da177e4SLinus Torvalds 	{
3381da177e4SLinus Torvalds 	case '[':
3391da177e4SLinus Torvalds 	  ++count;
3401da177e4SLinus Torvalds 	  goto repeat;
3411da177e4SLinus Torvalds 	case ']':
3421da177e4SLinus Torvalds 	  if (--count == 0)
3431da177e4SLinus Torvalds 	    {
3441da177e4SLinus Torvalds 	      lexstate = ST_NORMAL;
3451da177e4SLinus Torvalds 	      token = BRACKET_PHRASE;
3461da177e4SLinus Torvalds 	      break;
3471da177e4SLinus Torvalds 	    }
3481da177e4SLinus Torvalds 	  goto repeat;
3491da177e4SLinus Torvalds 	default:
3501da177e4SLinus Torvalds 	  goto repeat;
3511da177e4SLinus Torvalds 	}
3521da177e4SLinus Torvalds       break;
3531da177e4SLinus Torvalds 
3541da177e4SLinus Torvalds     case ST_BRACE:
3551da177e4SLinus Torvalds       APP;
3561da177e4SLinus Torvalds       switch (token)
3571da177e4SLinus Torvalds 	{
3581da177e4SLinus Torvalds 	case '{':
3591da177e4SLinus Torvalds 	  ++count;
3601da177e4SLinus Torvalds 	  goto repeat;
3611da177e4SLinus Torvalds 	case '}':
3621da177e4SLinus Torvalds 	  if (--count == 0)
3631da177e4SLinus Torvalds 	    {
3641da177e4SLinus Torvalds 	      lexstate = ST_NORMAL;
3651da177e4SLinus Torvalds 	      token = BRACE_PHRASE;
3661da177e4SLinus Torvalds 	      break;
3671da177e4SLinus Torvalds 	    }
3681da177e4SLinus Torvalds 	  goto repeat;
3691da177e4SLinus Torvalds 	default:
3701da177e4SLinus Torvalds 	  goto repeat;
3711da177e4SLinus Torvalds 	}
3721da177e4SLinus Torvalds       break;
3731da177e4SLinus Torvalds 
3741da177e4SLinus Torvalds     case ST_EXPRESSION:
3751da177e4SLinus Torvalds       switch (token)
3761da177e4SLinus Torvalds 	{
3771da177e4SLinus Torvalds 	case '(': case '[': case '{':
3781da177e4SLinus Torvalds 	  ++count;
3791da177e4SLinus Torvalds 	  APP;
3801da177e4SLinus Torvalds 	  goto repeat;
381e37ddb82SMichal Marek 	case '}':
382e37ddb82SMichal Marek 	  /* is this the last line of an enum declaration? */
383e37ddb82SMichal Marek 	  if (count == 0)
384e37ddb82SMichal Marek 	    {
385e37ddb82SMichal Marek 	      /* Put back the token we just read so's we can find it again
386e37ddb82SMichal Marek 		 after registering the expression.  */
387e37ddb82SMichal Marek 	      unput(token);
388e37ddb82SMichal Marek 
389e37ddb82SMichal Marek 	      lexstate = ST_NORMAL;
390e37ddb82SMichal Marek 	      token = EXPRESSION_PHRASE;
391e37ddb82SMichal Marek 	      break;
392e37ddb82SMichal Marek 	    }
393e37ddb82SMichal Marek 	  /* FALLTHRU */
394e37ddb82SMichal Marek 	case ')': case ']':
3951da177e4SLinus Torvalds 	  --count;
3961da177e4SLinus Torvalds 	  APP;
3971da177e4SLinus Torvalds 	  goto repeat;
3981da177e4SLinus Torvalds 	case ',': case ';':
3991da177e4SLinus Torvalds 	  if (count == 0)
4001da177e4SLinus Torvalds 	    {
4011da177e4SLinus Torvalds 	      /* Put back the token we just read so's we can find it again
4021da177e4SLinus Torvalds 		 after registering the expression.  */
4031da177e4SLinus Torvalds 	      unput(token);
4041da177e4SLinus Torvalds 
4051da177e4SLinus Torvalds 	      lexstate = ST_NORMAL;
4061da177e4SLinus Torvalds 	      token = EXPRESSION_PHRASE;
4071da177e4SLinus Torvalds 	      break;
4081da177e4SLinus Torvalds 	    }
4091da177e4SLinus Torvalds 	  APP;
4101da177e4SLinus Torvalds 	  goto repeat;
4111da177e4SLinus Torvalds 	default:
4121da177e4SLinus Torvalds 	  APP;
4131da177e4SLinus Torvalds 	  goto repeat;
4141da177e4SLinus Torvalds 	}
4151da177e4SLinus Torvalds       break;
4161da177e4SLinus Torvalds 
4171da177e4SLinus Torvalds     case ST_TABLE_1:
4181da177e4SLinus Torvalds       goto repeat;
4191da177e4SLinus Torvalds 
4201da177e4SLinus Torvalds     case ST_TABLE_2:
4211da177e4SLinus Torvalds       if (token == IDENT && yyleng == 1 && yytext[0] == 'X')
4221da177e4SLinus Torvalds 	{
4231da177e4SLinus Torvalds 	  token = EXPORT_SYMBOL_KEYW;
4241da177e4SLinus Torvalds 	  lexstate = ST_TABLE_5;
4251da177e4SLinus Torvalds 	  APP;
4261da177e4SLinus Torvalds 	  break;
4271da177e4SLinus Torvalds 	}
4281da177e4SLinus Torvalds       lexstate = ST_TABLE_6;
4291da177e4SLinus Torvalds       /* FALLTHRU */
4301da177e4SLinus Torvalds 
4311da177e4SLinus Torvalds     case ST_TABLE_6:
4321da177e4SLinus Torvalds       switch (token)
4331da177e4SLinus Torvalds 	{
4341da177e4SLinus Torvalds 	case '{': case '[': case '(':
4351da177e4SLinus Torvalds 	  ++count;
4361da177e4SLinus Torvalds 	  break;
4371da177e4SLinus Torvalds 	case '}': case ']': case ')':
4381da177e4SLinus Torvalds 	  --count;
4391da177e4SLinus Torvalds 	  break;
4401da177e4SLinus Torvalds 	case ',':
4411da177e4SLinus Torvalds 	  if (count == 0)
4421da177e4SLinus Torvalds 	    lexstate = ST_TABLE_2;
4431da177e4SLinus Torvalds 	  break;
4441da177e4SLinus Torvalds 	};
4451da177e4SLinus Torvalds       goto repeat;
4461da177e4SLinus Torvalds 
4471da177e4SLinus Torvalds     case ST_TABLE_3:
4481da177e4SLinus Torvalds       goto repeat;
4491da177e4SLinus Torvalds 
4501da177e4SLinus Torvalds     case ST_TABLE_4:
4511da177e4SLinus Torvalds       if (token == ';')
4521da177e4SLinus Torvalds 	lexstate = ST_NORMAL;
4531da177e4SLinus Torvalds       goto repeat;
4541da177e4SLinus Torvalds 
4551da177e4SLinus Torvalds     case ST_TABLE_5:
4561da177e4SLinus Torvalds       switch (token)
4571da177e4SLinus Torvalds 	{
4581da177e4SLinus Torvalds 	case ',':
4591da177e4SLinus Torvalds 	  token = ';';
4601da177e4SLinus Torvalds 	  lexstate = ST_TABLE_2;
4611da177e4SLinus Torvalds 	  APP;
4621da177e4SLinus Torvalds 	  break;
4631da177e4SLinus Torvalds 	default:
4641da177e4SLinus Torvalds 	  APP;
4651da177e4SLinus Torvalds 	  break;
4661da177e4SLinus Torvalds 	}
4671da177e4SLinus Torvalds       break;
4681da177e4SLinus Torvalds 
4691da177e4SLinus Torvalds     default:
4706803dc0eSSam Ravnborg       exit(1);
4711da177e4SLinus Torvalds     }
4721da177e4SLinus Torvalds fini:
4731da177e4SLinus Torvalds 
4741da177e4SLinus Torvalds   if (suppress_type_lookup > 0)
4751da177e4SLinus Torvalds     --suppress_type_lookup;
4761da177e4SLinus Torvalds   if (dont_want_brace_phrase > 0)
4771da177e4SLinus Torvalds     --dont_want_brace_phrase;
4781da177e4SLinus Torvalds 
4791da177e4SLinus Torvalds   yylval = &next_node->next;
4801da177e4SLinus Torvalds 
4811da177e4SLinus Torvalds   return token;
4821da177e4SLinus Torvalds }
483