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

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [gnu/] [binutils/] [ld/] [ldlex.l] - Blame information for rev 203

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

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




powered by: WebSVN 2.1.0

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