OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [binutils-2.20.1/] [ld/] [ldlex.l] - Blame information for rev 328

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 205 julius
%{
2
 
3
/* Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4
   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
5
   Free Software Foundation, Inc.
6
   Written by Steve Chamberlain of Cygnus Support.
7
 
8
   This file is part of the GNU Binutils.
9
 
10
   This program is free software; you can redistribute it and/or modify
11
   it under the terms of the GNU General Public License as published by
12
   the Free Software Foundation; either version 3 of the License, or
13
   (at your option) any later version.
14
 
15
   This program is distributed in the hope that it will be useful,
16
   but WITHOUT ANY WARRANTY; without even the implied warranty of
17
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
   GNU General Public License for more details.
19
 
20
   You should have received a copy of the GNU General Public License
21
   along with this program; if not, write to the Free Software
22
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
23
   MA 02110-1301, USA.  */
24
 
25
#include "bfd.h"
26
#include "safe-ctype.h"
27
#include "bfdlink.h"
28
#include "ld.h"
29
#include "ldmisc.h"
30
#include "ldexp.h"
31
#include "ldlang.h"
32
#include 
33
#include "ldfile.h"
34
#include "ldlex.h"
35
#include "ldmain.h"
36
#include "libiberty.h"
37
 
38
/* The type of top-level parser input.
39
   yylex and yyparse (indirectly) both check this.  */
40
input_type parser_input;
41
 
42
/* Line number in the current input file.
43
   (FIXME Actually, it doesn't appear to get reset for each file?)  */
44
unsigned int lineno = 1;
45
 
46
/* The string we are currently lexing, or NULL if we are reading a
47
   file.  */
48
const char *lex_string = NULL;
49
 
50
/* Support for flex reading from more than one input file (stream).
51
   `include_stack' is flex's input state for each open file;
52
   `file_name_stack' is the file names.  `lineno_stack' is the current
53
   line numbers.
54
 
55
   If `include_stack_ptr' is 0, we haven't started reading anything yet.
56
   Otherwise, stack elements 0 through `include_stack_ptr - 1' are valid.  */
57
 
58
#undef YY_INPUT
59
#define YY_INPUT(buf,result,max_size) result = yy_input (buf, max_size)
60
 
61
#define YY_NO_UNPUT
62
 
63
#define MAX_INCLUDE_DEPTH 10
64
static YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
65
static const char *file_name_stack[MAX_INCLUDE_DEPTH];
66
static unsigned int lineno_stack[MAX_INCLUDE_DEPTH];
67
static unsigned int include_stack_ptr = 0;
68
static int vers_node_nesting = 0;
69
 
70
static int yy_input (char *, int);
71
static void comment (void);
72
static void lex_warn_invalid (char *where, char *what);
73
 
74
/* STATES
75
        EXPRESSION      definitely in an expression
76
        SCRIPT          definitely in a script
77
        BOTH            either EXPRESSION or SCRIPT
78
        DEFSYMEXP       in an argument to -defsym
79
        MRI             in an MRI script
80
        VERS_START      starting a Sun style mapfile
81
        VERS_SCRIPT     a Sun style mapfile
82
        VERS_NODE       a node within a Sun style mapfile
83
*/
84
#define RTOKEN(x)  {  yylval.token = x; return x; }
85
 
86
/* Some versions of flex want this.  */
87
#ifndef yywrap
88
int yywrap (void) { return 1; }
89
#endif
90
%}
91
 
92
%a 4000
93
%o 5000
94
 
95
CMDFILENAMECHAR   [_a-zA-Z0-9\/\.\\_\+\$\:\[\]\\\,\=\&\!\<\>\-\~]
96
CMDFILENAMECHAR1  [_a-zA-Z0-9\/\.\\_\+\$\:\[\]\\\,\=\&\!\<\>\~]
97
FILENAMECHAR1   [_a-zA-Z\/\.\\\$\_\~]
98
SYMBOLCHARN     [_a-zA-Z\/\.\\\$\_\~0-9]
99
FILENAMECHAR    [_a-zA-Z0-9\/\.\-\_\+\=\$\:\[\]\\\,\~]
100
WILDCHAR        [_a-zA-Z0-9\/\.\-\_\+\=\$\:\[\]\\\,\~\?\*]
101
WHITE           [ \t\n\r]+
102
 
103
NOCFILENAMECHAR [_a-zA-Z0-9\/\.\-\_\+\$\:\[\]\\\~]
104
 
105
V_TAG [.$_a-zA-Z][._a-zA-Z0-9]*
106
V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)*
107
 
108
%s SCRIPT
109
%s EXPRESSION
110
%s BOTH
111
%s DEFSYMEXP
112
%s MRI
113
%s VERS_START
114
%s VERS_SCRIPT
115
%s VERS_NODE
116
%%
117
 
118
  if (parser_input != input_selected)
119
    {
120
      /* The first token of the input determines the initial parser state.  */
121
      input_type t = parser_input;
122
      parser_input = input_selected;
123
      switch (t)
124
        {
125
        case input_script: return INPUT_SCRIPT; break;
126
        case input_mri_script: return INPUT_MRI_SCRIPT; break;
127
        case input_version_script: return INPUT_VERSION_SCRIPT; break;
128
        case input_dynamic_list: return INPUT_DYNAMIC_LIST; break;
129
        case input_defsym: return INPUT_DEFSYM; break;
130
        default: abort ();
131
        }
132
    }
133
 
134
"/*"    { comment (); }
135
 
136
 
137
"-"                  { RTOKEN('-');}
138
"+"                  { RTOKEN('+');}
139
{FILENAMECHAR1}{SYMBOLCHARN}*   { yylval.name = xstrdup (yytext); return NAME; }
140
"="                  { RTOKEN('='); }
141
 
142
"$"([0-9A-Fa-f])+ {
143
                                yylval.integer = bfd_scan_vma (yytext + 1, 0, 16);
144
                                yylval.bigint.str = NULL;
145
                                return INT;
146
                        }
147
 
148
([0-9A-Fa-f])+(H|h|X|x|B|b|O|o|D|d) {
149
                                   int ibase ;
150
                                   switch (yytext[yyleng - 1]) {
151
                                    case 'X':
152
                                    case 'x':
153
                                    case 'H':
154
                                    case 'h':
155
                                     ibase = 16;
156
                                     break;
157
                                    case 'O':
158
                                    case 'o':
159
                                     ibase = 8;
160
                                     break;
161
                                    case 'B':
162
                                    case 'b':
163
                                     ibase = 2;
164
                                     break;
165
                                    default:
166
                                     ibase = 10;
167
                                   }
168
                                   yylval.integer = bfd_scan_vma (yytext, 0,
169
                                                                  ibase);
170
                                   yylval.bigint.str = NULL;
171
                                   return INT;
172
                                 }
173
((("$"|0[xX])([0-9A-Fa-f])+)|(([0-9])+))(M|K|m|k)? {
174
                                  char *s = yytext;
175
                                  int ibase = 0;
176
 
177
                                  if (*s == '$')
178
                                    {
179
                                      ++s;
180
                                      ibase = 16;
181
                                    }
182
                                  yylval.integer = bfd_scan_vma (s, 0, ibase);
183
                                  yylval.bigint.str = NULL;
184
                                  if (yytext[yyleng - 1] == 'M'
185
                                      || yytext[yyleng - 1] == 'm')
186
                                    {
187
                                      yylval.integer *= 1024 * 1024;
188
                                    }
189
                                  else if (yytext[yyleng - 1] == 'K'
190
                                      || yytext[yyleng - 1]=='k')
191
                                    {
192
                                      yylval.integer *= 1024;
193
                                    }
194
                                  else if (yytext[0] == '0'
195
                                           && (yytext[1] == 'x'
196
                                               || yytext[1] == 'X'))
197
                                    {
198
                                      yylval.bigint.str = xstrdup (yytext + 2);
199
                                    }
200
                                  return INT;
201
                                }
202
"]"             { RTOKEN(']');}
203
"["             { RTOKEN('[');}
204
"<<="   { RTOKEN(LSHIFTEQ);}
205
">>="   { RTOKEN(RSHIFTEQ);}
206
"||"    { RTOKEN(OROR);}
207
"=="    { RTOKEN(EQ);}
208
"!="    { RTOKEN(NE);}
209
">="    { RTOKEN(GE);}
210
"<="    { RTOKEN(LE);}
211
"<<"    { RTOKEN(LSHIFT);}
212
">>"    { RTOKEN(RSHIFT);}
213
"+="    { RTOKEN(PLUSEQ);}
214
"-="    { RTOKEN(MINUSEQ);}
215
"*="    { RTOKEN(MULTEQ);}
216
"/="    { RTOKEN(DIVEQ);}
217
"&="	{ RTOKEN(ANDEQ);}
218
"|="    { RTOKEN(OREQ);}
219
"&&"	{ RTOKEN(ANDAND);}
220
">"             { RTOKEN('>');}
221
","             { RTOKEN(',');}
222
"&"		{ RTOKEN('&');}
223
"|"             { RTOKEN('|');}
224
"~"             { RTOKEN('~');}
225
"!"             { RTOKEN('!');}
226
"?"             { RTOKEN('?');}
227
"*"             { RTOKEN('*');}
228
"+"             { RTOKEN('+');}
229
"-"             { RTOKEN('-');}
230
"/"             { RTOKEN('/');}
231
"%"             { RTOKEN('%');}
232
"<"             { RTOKEN('<');}
233
"="         { RTOKEN('=');}
234
"}"             { RTOKEN('}') ; }
235
"{"             { RTOKEN('{'); }
236
")"             { RTOKEN(')');}
237
"("             { RTOKEN('(');}
238
":"             { RTOKEN(':'); }
239
";"             { RTOKEN(';');}
240
"MEMORY"                        { RTOKEN(MEMORY);}
241
"REGION_ALIAS"          { RTOKEN(REGION_ALIAS);}
242
"ORIGIN"        { RTOKEN(ORIGIN);}
243
"VERSION"                       { RTOKEN(VERSIONK);}
244
"BLOCK"         { RTOKEN(BLOCK);}
245
"BIND"          { RTOKEN(BIND);}
246
"LENGTH"        { RTOKEN(LENGTH);}
247
"ALIGN"         { RTOKEN(ALIGN_K);}
248
"DATA_SEGMENT_ALIGN"    { RTOKEN(DATA_SEGMENT_ALIGN);}
249
"DATA_SEGMENT_RELRO_END"        { RTOKEN(DATA_SEGMENT_RELRO_END);}
250
"DATA_SEGMENT_END"      { RTOKEN(DATA_SEGMENT_END);}
251
"ADDR"          { RTOKEN(ADDR);}
252
"LOADADDR"      { RTOKEN(LOADADDR);}
253
"ALIGNOF"       { RTOKEN(ALIGNOF); }
254
"MAX"                   { RTOKEN(MAX_K); }
255
"MIN"                   { RTOKEN(MIN_K); }
256
"ASSERT"        { RTOKEN(ASSERT_K); }
257
"ENTRY"                 { RTOKEN(ENTRY);}
258
"EXTERN"                { RTOKEN(EXTERN);}
259
"NEXT"          { RTOKEN(NEXT);}
260
"sizeof_headers"        { RTOKEN(SIZEOF_HEADERS);}
261
"SIZEOF_HEADERS"        { RTOKEN(SIZEOF_HEADERS);}
262
"SEGMENT_START" { RTOKEN(SEGMENT_START);}
263
"MAP"                   { RTOKEN(MAP);}
264
"SIZEOF"        { RTOKEN(SIZEOF);}
265
"TARGET"                        { RTOKEN(TARGET_K);}
266
"SEARCH_DIR"            { RTOKEN(SEARCH_DIR);}
267
"OUTPUT"                        { RTOKEN(OUTPUT);}
268
"INPUT"                 { RTOKEN(INPUT);}
269
"GROUP"         { RTOKEN(GROUP);}
270
"AS_NEEDED"     { RTOKEN(AS_NEEDED);}
271
"DEFINED"       { RTOKEN(DEFINED);}
272
"CREATE_OBJECT_SYMBOLS" { RTOKEN(CREATE_OBJECT_SYMBOLS);}
273
"CONSTRUCTORS"          { RTOKEN( CONSTRUCTORS);}
274
"FORCE_COMMON_ALLOCATION"       { RTOKEN(FORCE_COMMON_ALLOCATION);}
275
"INHIBIT_COMMON_ALLOCATION" { RTOKEN(INHIBIT_COMMON_ALLOCATION);}
276
"SECTIONS"                      { RTOKEN(SECTIONS);}
277
"INSERT"                        { RTOKEN(INSERT_K);}
278
"AFTER"                 { RTOKEN(AFTER);}
279
"BEFORE"                        { RTOKEN(BEFORE);}
280
"FILL"                  { RTOKEN(FILL);}
281
"STARTUP"                       { RTOKEN(STARTUP);}
282
"OUTPUT_FORMAT"         { RTOKEN(OUTPUT_FORMAT);}
283
"OUTPUT_ARCH"           { RTOKEN( OUTPUT_ARCH);}
284
"HLL"                   { RTOKEN(HLL);}
285
"SYSLIB"                        { RTOKEN(SYSLIB);}
286
"FLOAT"                 { RTOKEN(FLOAT);}
287
"QUAD"                  { RTOKEN( QUAD);}
288
"SQUAD"                 { RTOKEN( SQUAD);}
289
"LONG"                  { RTOKEN( LONG);}
290
"SHORT"                 { RTOKEN( SHORT);}
291
"BYTE"                  { RTOKEN( BYTE);}
292
"NOFLOAT"                       { RTOKEN(NOFLOAT);}
293
"NOCROSSREFS"   { RTOKEN(NOCROSSREFS);}
294
"OVERLAY"                       { RTOKEN(OVERLAY); }
295
"SORT_BY_NAME"          { RTOKEN(SORT_BY_NAME); }
296
"SORT_BY_ALIGNMENT"     { RTOKEN(SORT_BY_ALIGNMENT); }
297
"SORT"                  { RTOKEN(SORT_BY_NAME); }
298
"NOLOAD"        { RTOKEN(NOLOAD);}
299
"DSECT"         { RTOKEN(DSECT);}
300
"COPY"          { RTOKEN(COPY);}
301
"INFO"          { RTOKEN(INFO);}
302
"OVERLAY"       { RTOKEN(OVERLAY);}
303
"ONLY_IF_RO"    { RTOKEN(ONLY_IF_RO); }
304
"ONLY_IF_RW"    { RTOKEN(ONLY_IF_RW); }
305
"SPECIAL"       { RTOKEN(SPECIAL); }
306
"o"                     { RTOKEN(ORIGIN);}
307
"org"                   { RTOKEN(ORIGIN);}
308
"l"                     { RTOKEN( LENGTH);}
309
"len"                   { RTOKEN( LENGTH);}
310
"INCLUDE"       { RTOKEN(INCLUDE);}
311
"PHDRS"                 { RTOKEN (PHDRS); }
312
"AT"            { RTOKEN(AT);}
313
"SUBALIGN"      { RTOKEN(SUBALIGN);}
314
"PROVIDE"       { RTOKEN(PROVIDE); }
315
"PROVIDE_HIDDEN" { RTOKEN(PROVIDE_HIDDEN); }
316
"KEEP"          { RTOKEN(KEEP); }
317
"EXCLUDE_FILE"  { RTOKEN(EXCLUDE_FILE); }
318
"CONSTANT"      { RTOKEN(CONSTANT);}
319
"#".*\n?                        { ++ lineno; }
320
"\n"                    { ++ lineno;  RTOKEN(NEWLINE); }
321
"*".*                   { /* Mri comment line */ }
322
";".*                   { /* Mri comment line */ }
323
"END"                      { RTOKEN(ENDWORD); }
324
"ALIGNMOD"                      { RTOKEN(ALIGNMOD);}
325
"ALIGN"                 { RTOKEN(ALIGN_K);}
326
"CHIP"                     { RTOKEN(CHIP); }
327
"BASE"                     { RTOKEN(BASE); }
328
"ALIAS"                    { RTOKEN(ALIAS); }
329
"TRUNCATE"                 { RTOKEN(TRUNCATE); }
330
"LOAD"                     { RTOKEN(LOAD); }
331
"PUBLIC"                   { RTOKEN(PUBLIC); }
332
"ORDER"                    { RTOKEN(ORDER); }
333
"NAME"                     { RTOKEN(NAMEWORD); }
334
"FORMAT"                   { RTOKEN(FORMAT); }
335
"CASE"                     { RTOKEN(CASE); }
336
"START"                    { RTOKEN(START); }
337
"LIST".*                   { RTOKEN(LIST); /* LIST and ignore to end of line */ }
338
"SECT"                  { RTOKEN(SECT); }
339
"ABSOLUTE"                      { RTOKEN(ABSOLUTE); }
340
"end"                      { RTOKEN(ENDWORD); }
341
"alignmod"                      { RTOKEN(ALIGNMOD);}
342
"align"                 { RTOKEN(ALIGN_K);}
343
"chip"                     { RTOKEN(CHIP); }
344
"base"                     { RTOKEN(BASE); }
345
"alias"                    { RTOKEN(ALIAS); }
346
"truncate"                 { RTOKEN(TRUNCATE); }
347
"load"                     { RTOKEN(LOAD); }
348
"public"                   { RTOKEN(PUBLIC); }
349
"order"                    { RTOKEN(ORDER); }
350
"name"                     { RTOKEN(NAMEWORD); }
351
"format"                   { RTOKEN(FORMAT); }
352
"case"                     { RTOKEN(CASE); }
353
"extern"                   { RTOKEN(EXTERN); }
354
"start"                    { RTOKEN(START); }
355
"list".*                   { RTOKEN(LIST); /* LIST and ignore to end of line */ }
356
"sect"                  { RTOKEN(SECT); }
357
"absolute"                      { RTOKEN(ABSOLUTE); }
358
 
359
{FILENAMECHAR1}{NOCFILENAMECHAR}*       {
360
/* Filename without commas, needed to parse mri stuff */
361
                                 yylval.name = xstrdup (yytext);
362
                                  return NAME;
363
                                }
364
 
365
 
366
{FILENAMECHAR1}{FILENAMECHAR}*  {
367
                                 yylval.name = xstrdup (yytext);
368
                                  return NAME;
369
                                }
370
"-l"{FILENAMECHAR}+ {
371
                                  yylval.name = xstrdup (yytext + 2);
372
                                  return LNAME;
373
                                }
374
{FILENAMECHAR1}{NOCFILENAMECHAR}*       {
375
                                 yylval.name = xstrdup (yytext);
376
                                  return NAME;
377
                                }
378
"-l"{NOCFILENAMECHAR}+ {
379
                                  yylval.name = xstrdup (yytext + 2);
380
                                  return LNAME;
381
                                }
382




powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.