| 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 |
|
|
© copyright 1999-2026
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.
|