OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

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

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

Line No. Rev Author Line
1 38 julius
%{
2
 
3
/* Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4
   2000, 2001, 2002, 2003, 2004, 2005, 2007
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 "sysdep.h"
26
#include "bfd.h"
27
#include "safe-ctype.h"
28
#include "bfdlink.h"
29
#include "ld.h"
30
#include "ldmisc.h"
31
#include "ldexp.h"
32
#include "ldlang.h"
33
#include 
34
#include "ldfile.h"
35
#include "ldlex.h"
36
#include "ldmain.h"
37
#include "libiberty.h"
38
 
39
/* The type of top-level parser input.
40
   yylex and yyparse (indirectly) both check this.  */
41
input_type parser_input;
42
 
43
/* Line number in the current input file.
44
   (FIXME Actually, it doesn't appear to get reset for each file?)  */
45
unsigned int lineno = 1;
46
 
47
/* The string we are currently lexing, or NULL if we are reading a
48
   file.  */
49
const char *lex_string = NULL;
50
 
51
/* Support for flex reading from more than one input file (stream).
52
   `include_stack' is flex's input state for each open file;
53
   `file_name_stack' is the file names.  `lineno_stack' is the current
54
   line numbers.
55
 
56
   If `include_stack_ptr' is 0, we haven't started reading anything yet.
57
   Otherwise, stack elements 0 through `include_stack_ptr - 1' are valid.  */
58
 
59
#undef YY_INPUT
60
#define YY_INPUT(buf,result,max_size) yy_input (buf, &result, max_size)
61
 
62
#define YY_NO_UNPUT
63
 
64
#define MAX_INCLUDE_DEPTH 10
65
static YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
66
static const char *file_name_stack[MAX_INCLUDE_DEPTH];
67
static unsigned int lineno_stack[MAX_INCLUDE_DEPTH];
68
static unsigned int include_stack_ptr = 0;
69
static int vers_node_nesting = 0;
70
 
71
static void yy_input (char *, int *, int);
72
static void comment (void);
73
static void lex_warn_invalid (char *where, char *what);
74
 
75
/* STATES
76
        EXPRESSION      definitely in an expression
77
        SCRIPT          definitely in a script
78
        BOTH            either EXPRESSION or SCRIPT
79
        DEFSYMEXP       in an argument to -defsym
80
        MRI             in an MRI script
81
        VERS_START      starting a Sun style mapfile
82
        VERS_SCRIPT     a Sun style mapfile
83
        VERS_NODE       a node within a Sun style mapfile
84
*/
85
#define RTOKEN(x)  {  yylval.token = x; return x; }
86
 
87
/* Some versions of flex want this.  */
88
#ifndef yywrap
89
int yywrap (void) { return 1; }
90
#endif
91
%}
92
 
93
%a 4000
94
%o 5000
95
 
96
CMDFILENAMECHAR   [_a-zA-Z0-9\/\.\\_\+\$\:\[\]\\\,\=\&\!\<\>\-\~]
97
CMDFILENAMECHAR1  [_a-zA-Z0-9\/\.\\_\+\$\:\[\]\\\,\=\&\!\<\>\~]
98
FILENAMECHAR1   [_a-zA-Z\/\.\\\$\_\~]
99
SYMBOLCHARN     [_a-zA-Z\/\.\\\$\_\~0-9]
100
FILENAMECHAR    [_a-zA-Z0-9\/\.\-\_\+\=\$\:\[\]\\\,\~]
101
WILDCHAR        [_a-zA-Z0-9\/\.\-\_\+\=\$\:\[\]\\\,\~\?\*]
102
WHITE           [ \t\n\r]+
103
 
104
NOCFILENAMECHAR [_a-zA-Z0-9\/\.\-\_\+\$\:\[\]\\\~]
105
 
106
V_TAG [.$_a-zA-Z][._a-zA-Z0-9]*
107
V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)*
108
 
109
%s SCRIPT
110
%s EXPRESSION
111
%s BOTH
112
%s DEFSYMEXP
113
%s MRI
114
%s VERS_START
115
%s VERS_SCRIPT
116
%s VERS_NODE
117
%%
118
 
119
  if (parser_input != input_selected)
120
    {
121
      /* The first token of the input determines the initial parser state.  */
122
      input_type t = parser_input;
123
      parser_input = input_selected;
124
      switch (t)
125
        {
126
        case input_script: return INPUT_SCRIPT; break;
127
        case input_mri_script: return INPUT_MRI_SCRIPT; break;
128
        case input_version_script: return INPUT_VERSION_SCRIPT; break;
129
        case input_dynamic_list: return INPUT_DYNAMIC_LIST; break;
130
        case input_defsym: return INPUT_DEFSYM; break;
131
        default: abort ();
132
        }
133
    }
134
 
135
"/*"    { comment (); }
136
 
137
 
138
"-"                  { RTOKEN('-');}
139
"+"                  { RTOKEN('+');}
140
{FILENAMECHAR1}{SYMBOLCHARN}*   { yylval.name = xstrdup (yytext); return NAME; }
141
"="                  { RTOKEN('='); }
142
 
143
"$"([0-9A-Fa-f])+ {
144
                                yylval.integer = bfd_scan_vma (yytext + 1, 0, 16);
145
                                yylval.bigint.str = NULL;
146
                                return INT;
147
                        }
148
 
149
([0-9A-Fa-f])+(H|h|X|x|B|b|O|o|D|d) {
150
                                   int ibase ;
151
                                   switch (yytext[yyleng - 1]) {
152
                                    case 'X':
153
                                    case 'x':
154
                                    case 'H':
155
                                    case 'h':
156
                                     ibase = 16;
157
                                     break;
158
                                    case 'O':
159
                                    case 'o':
160
                                     ibase = 8;
161
                                     break;
162
                                    case 'B':
163
                                    case 'b':
164
                                     ibase = 2;
165
                                     break;
166
                                    default:
167
                                     ibase = 10;
168
                                   }
169
                                   yylval.integer = bfd_scan_vma (yytext, 0,
170
                                                                  ibase);
171
                                   yylval.bigint.str = NULL;
172
                                   return INT;
173
                                 }
174
((("$"|0[xX])([0-9A-Fa-f])+)|(([0-9])+))(M|K|m|k)? {
175
                                  char *s = yytext;
176
                                  int ibase = 0;
177
 
178
                                  if (*s == '$')
179
                                    {
180
                                      ++s;
181
                                      ibase = 16;
182
                                    }
183
                                  yylval.integer = bfd_scan_vma (s, 0, ibase);
184
                                  yylval.bigint.str = NULL;
185
                                  if (yytext[yyleng - 1] == 'M'
186
                                      || yytext[yyleng - 1] == 'm')
187
                                    {
188
                                      yylval.integer *= 1024 * 1024;
189
                                    }
190
                                  else if (yytext[yyleng - 1] == 'K'
191
                                      || yytext[yyleng - 1]=='k')
192
                                    {
193
                                      yylval.integer *= 1024;
194
                                    }
195
                                  else if (yytext[0] == '0'
196
                                           && (yytext[1] == 'x'
197
                                               || yytext[1] == 'X'))
198
                                    {
199
                                      yylval.bigint.str = xstrdup (yytext + 2);
200
                                    }
201
                                  return INT;
202
                                }
203
"]"             { RTOKEN(']');}
204
"["             { RTOKEN('[');}
205
"<<="   { RTOKEN(LSHIFTEQ);}
206
">>="   { RTOKEN(RSHIFTEQ);}
207
"||"    { RTOKEN(OROR);}
208
"=="    { RTOKEN(EQ);}
209
"!="    { RTOKEN(NE);}
210
">="    { RTOKEN(GE);}
211
"<="    { RTOKEN(LE);}
212
"<<"    { RTOKEN(LSHIFT);}
213
">>"    { RTOKEN(RSHIFT);}
214
"+="    { RTOKEN(PLUSEQ);}
215
"-="    { RTOKEN(MINUSEQ);}
216
"*="    { RTOKEN(MULTEQ);}
217
"/="    { RTOKEN(DIVEQ);}
218
"&="	{ RTOKEN(ANDEQ);}
219
"|="    { RTOKEN(OREQ);}
220
"&&"	{ RTOKEN(ANDAND);}
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
";"             { RTOKEN(';');}
241
"MEMORY"                        { RTOKEN(MEMORY);}
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.