~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to scripts/genksyms/lex.l

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
 
56
56
MC_TOKEN                ([~%^&*+=|<>/-]=)|(&&)|("||")|(->)|(<<)|(>>)
57
57
 
58
 
/* Version 2 checksumming does proper tokenization; version 1 wasn't
59
 
   quite so pedantic.  */
60
 
%s V2_TOKENS
61
 
 
62
58
/* We don't do multiple input files.  */
63
59
%option noyywrap
64
60
 
84
80
    recognized as tokens.  We don't actually use them since we don't
85
81
    parse expressions, but we do want whitespace to be arranged
86
82
    around them properly.  */
87
 
<V2_TOKENS>{MC_TOKEN}                   return OTHER;
88
 
<V2_TOKENS>{INT}                        return INT;
89
 
<V2_TOKENS>{REAL}                       return REAL;
 
83
{MC_TOKEN}                              return OTHER;
 
84
{INT}                                   return INT;
 
85
{REAL}                                  return REAL;
90
86
 
91
87
"..."                                   return DOTS;
92
88
 
103
99
 
104
100
/* Macros to append to our phrase collection list.  */
105
101
 
 
102
/*
 
103
 * We mark any token, that that equals to a known enumerator, as
 
104
 * SYM_ENUM_CONST. The parser will change this for struct and union tags later,
 
105
 * the only problem is struct and union members:
 
106
 *    enum e { a, b }; struct s { int a, b; }
 
107
 * but in this case, the only effect will be, that the ABI checksums become
 
108
 * more volatile, which is acceptable. Also, such collisions are quite rare,
 
109
 * so far it was only observed in include/linux/telephony.h.
 
110
 */
106
111
#define _APP(T,L)       do {                                               \
107
112
                          cur_node = next_node;                            \
108
113
                          next_node = xmalloc(sizeof(*next_node));         \
109
114
                          next_node->next = cur_node;                      \
110
115
                          cur_node->string = memcpy(xmalloc(L+1), T, L+1); \
111
 
                          cur_node->tag = SYM_NORMAL;                      \
 
116
                          cur_node->tag =                                  \
 
117
                            find_symbol(cur_node->string, SYM_ENUM_CONST, 1)?\
 
118
                            SYM_ENUM_CONST : SYM_NORMAL ;                  \
112
119
                        } while (0)
113
120
 
114
121
#define APP             _APP(yytext, yyleng)
134
141
 
135
142
  if (lexstate == ST_NOTSTARTED)
136
143
    {
137
 
      BEGIN(V2_TOKENS);
138
144
      next_node = xmalloc(sizeof(*next_node));
139
145
      next_node->next = NULL;
140
146
      lexstate = ST_NORMAL;
187
193
 
188
194
                  case STRUCT_KEYW:
189
195
                  case UNION_KEYW:
 
196
                  case ENUM_KEYW:
190
197
                    dont_want_brace_phrase = 3;
191
 
                  case ENUM_KEYW:
192
198
                    suppress_type_lookup = 2;
193
199
                    goto fini;
194
200
 
198
204
              }
199
205
            if (!suppress_type_lookup)
200
206
              {
201
 
                struct symbol *sym = find_symbol(yytext, SYM_TYPEDEF);
202
 
                if (sym && sym->type == SYM_TYPEDEF)
 
207
                if (find_symbol(yytext, SYM_TYPEDEF, 1))
203
208
                  token = TYPE;
204
209
              }
205
210
          }
318
323
          ++count;
319
324
          APP;
320
325
          goto repeat;
321
 
        case ')': case ']': case '}':
 
326
        case '}':
 
327
          /* is this the last line of an enum declaration? */
 
328
          if (count == 0)
 
329
            {
 
330
              /* Put back the token we just read so's we can find it again
 
331
                 after registering the expression.  */
 
332
              unput(token);
 
333
 
 
334
              lexstate = ST_NORMAL;
 
335
              token = EXPRESSION_PHRASE;
 
336
              break;
 
337
            }
 
338
          /* FALLTHRU */
 
339
        case ')': case ']':
322
340
          --count;
323
341
          APP;
324
342
          goto repeat;