* Makefile.am (ALL_EMULATIONS): Remove ehppaelf.o.
[deliverable/binutils-gdb.git] / ld / ldlex.l
index e8214942f70baa48aa2611a8214800bf0c31116a..2eef80f1fe2b259cc40f56004b41f3c3a48e3fb0 100644 (file)
@@ -1,6 +1,7 @@
 %{
 
-/* Copyright (C) 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 1999
+   Free Software Foundation, Inc.
 
 This file is part of GLD, the Gnu Linker.
 
@@ -15,8 +16,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with GLD; see the file COPYING.  If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+along with GLD; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.  */
 
 /*
 This was written by steve chamberlain
@@ -48,9 +50,6 @@ This was written by steve chamberlain
    yylex and yyparse (indirectly) both check this.  */
 input_type parser_input;
 
-/* Radix to use for bfd_scan_vma -- 0 (default to base 10) or 16.  */
-int hex_mode;
-
 /* Line number in the current input file.
    (FIXME Actually, it doesn't appear to get reset for each file?)  */
 unsigned int lineno = 1;
@@ -75,6 +74,7 @@ static YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
 static const char *file_name_stack[MAX_INCLUDE_DEPTH];
 static unsigned int lineno_stack[MAX_INCLUDE_DEPTH];
 static unsigned int include_stack_ptr = 0;
+static int vers_node_nesting = 0;
 
 static YY_BUFFER_STATE yy_create_string_buffer PARAMS ((const char *string,
                                                        size_t size));
@@ -115,7 +115,7 @@ WHITE               [ \t\n\r]+
 NOCFILENAMECHAR        [_a-zA-Z0-9\/\.\-\_\+\$\:\[\]\\\~]
 
 V_TAG [.$_a-zA-Z][._a-zA-Z0-9]*
-V_IDENTIFIER [*?$_a-zA-Z][*?_a-zA-Z0-9]*
+V_IDENTIFIER [*?.$_a-zA-Z][*?.$_a-zA-Z0-9]*
 
 %s SCRIPT
 %s EXPRESSION
@@ -179,17 +179,18 @@ V_IDENTIFIER [*?$_a-zA-Z][*?_a-zA-Z0-9]*
                                                                  ibase);
                                   return INT;
                                 }
-<SCRIPT,DEFSYMEXP,MRI,BOTH,EXPRESSION>"$"?"0x"?([0-9A-Fa-f])+(M|K|m|k)? {
-                                 yylval.integer = bfd_scan_vma (yytext, 0,
-                                                                hex_mode);
-                                 if (yytext[yyleng-1]=='M'
-                                       || yytext[yyleng-1] == 'm') {
-                                     yylval.integer *= 1024*1024;
-                                   }   
-                                 if (yytext[yyleng-1]=='K' 
-                               || yytext[yyleng-1]=='k') {
-                                     yylval.integer *= 1024;
-                                   }           
+<SCRIPT,DEFSYMEXP,MRI,BOTH,EXPRESSION>((("$"|"0x")([0-9A-Fa-f])+)|(([0-9])+))(M|K|m|k)? {
+                                 char *s = yytext;
+
+                                 if (*s == '$')
+                                   ++s;
+                                 yylval.integer = bfd_scan_vma (s, 0, 0);
+                                 if (yytext[yyleng-1] == 'M'
+                                     || yytext[yyleng-1] == 'm')
+                                   yylval.integer *= 1024 * 1024;
+                                 if (yytext[yyleng-1] == 'K' 
+                                     || yytext[yyleng-1]=='k')
+                                   yylval.integer *= 1024;
                                  return INT;
                                }
 <BOTH,SCRIPT,EXPRESSION,MRI>"]"                { RTOKEN(']');}
@@ -232,16 +233,18 @@ V_IDENTIFIER [*?$_a-zA-Z][*?_a-zA-Z0-9]*
 <BOTH,SCRIPT,EXPRESSION,MRI>";"                { RTOKEN(';');}
 <BOTH,SCRIPT>"MEMORY"          { RTOKEN(MEMORY);}
 <BOTH,SCRIPT>"ORIGIN"          { RTOKEN(ORIGIN);}
-<BOTH,SCRIPT>"VERSION"         { RTOKEN(VERSION);}
+<BOTH,SCRIPT>"VERSION"         { RTOKEN(VERSIONK);}
 <EXPRESSION,BOTH,SCRIPT>"BLOCK"                { RTOKEN(BLOCK);}
 <EXPRESSION,BOTH,SCRIPT>"BIND"         { RTOKEN(BIND);}
 <BOTH,SCRIPT>"LENGTH"          { RTOKEN(LENGTH);}
 <EXPRESSION,BOTH,SCRIPT>"ALIGN"                        { RTOKEN(ALIGN_K);}
 <EXPRESSION,BOTH,SCRIPT>"ADDR"                 { RTOKEN(ADDR);}
 <EXPRESSION,BOTH,SCRIPT>"LOADADDR"             { RTOKEN(LOADADDR);}
-<EXPRESSION,BOTH>"MAX"                 { RTOKEN(MAX); }
-<EXPRESSION,BOTH>"MIN"                 { RTOKEN(MIN); }
+<EXPRESSION,BOTH>"MAX"                 { RTOKEN(MAX_K); }
+<EXPRESSION,BOTH>"MIN"                 { RTOKEN(MIN_K); }
+<EXPRESSION,BOTH>"ASSERT"              { RTOKEN(ASSERT_K); }
 <BOTH,SCRIPT>"ENTRY"                   { RTOKEN(ENTRY);}
+<BOTH,SCRIPT,MRI>"EXTERN"              { RTOKEN(EXTERN);}
 <EXPRESSION,BOTH,SCRIPT>"NEXT"                 { RTOKEN(NEXT);}
 <EXPRESSION,BOTH,SCRIPT>"sizeof_headers"       { RTOKEN(SIZEOF_HEADERS);}
 <EXPRESSION,BOTH,SCRIPT>"SIZEOF_HEADERS"       { RTOKEN(SIZEOF_HEADERS);}
@@ -272,6 +275,7 @@ V_IDENTIFIER [*?$_a-zA-Z][*?_a-zA-Z0-9]*
 <BOTH,SCRIPT>"NOFLOAT"         { RTOKEN(NOFLOAT);}
 <EXPRESSION,BOTH,SCRIPT>"NOCROSSREFS"  { RTOKEN(NOCROSSREFS);}
 <BOTH,SCRIPT>"OVERLAY"                 { RTOKEN(OVERLAY); }
+<BOTH,SCRIPT>"SORT"                    { RTOKEN(SORT); }
 <EXPRESSION,BOTH,SCRIPT>"NOLOAD"       { RTOKEN(NOLOAD);}
 <EXPRESSION,BOTH,SCRIPT>"DSECT"                { RTOKEN(DSECT);}
 <EXPRESSION,BOTH,SCRIPT>"COPY"         { RTOKEN(COPY);}
@@ -285,9 +289,10 @@ V_IDENTIFIER [*?$_a-zA-Z][*?_a-zA-Z0-9]*
 <BOTH,SCRIPT>"PHDRS"                   { RTOKEN (PHDRS); }
 <EXPRESSION,BOTH,SCRIPT>"AT"                   { RTOKEN(AT);}
 <EXPRESSION,BOTH,SCRIPT>"PROVIDE"              { RTOKEN(PROVIDE); }
-<MRI>"#".*\n?\r?               { ++ lineno; }
+<EXPRESSION,BOTH,SCRIPT>"KEEP"         { RTOKEN(KEEP); }
+<EXPRESSION,BOTH,SCRIPT>"EXCLUDE_FILE"        { RTOKEN(EXCLUDE_FILE); }
+<MRI>"#".*\n?                  { ++ lineno; }
 <MRI>"\n"                      { ++ lineno;  RTOKEN(NEWLINE); }
-<MRI>"\r"                      { ++ lineno;  RTOKEN(NEWLINE); }
 <MRI>"*".*                     { /* Mri comment line */ }
 <MRI>";".*                     { /* Mri comment line */ }
 <MRI>"END"                      { RTOKEN(ENDWORD); }
@@ -303,7 +308,6 @@ V_IDENTIFIER [*?$_a-zA-Z][*?_a-zA-Z0-9]*
 <MRI>"NAME"                     { RTOKEN(NAMEWORD); }
 <MRI>"FORMAT"                   { RTOKEN(FORMAT); }
 <MRI>"CASE"                     { RTOKEN(CASE); }
-<MRI>"EXTERN"                   { RTOKEN(EXTERN); }
 <MRI>"START"                    { RTOKEN(START); }
 <MRI>"LIST".*                   { RTOKEN(LIST); /* LIST and ignore to end of line */ }
 <MRI>"SECT"                    { RTOKEN(SECT); }
@@ -342,9 +346,24 @@ V_IDENTIFIER [*?$_a-zA-Z][*?_a-zA-Z0-9]*
                                  yylval.name = buystring (yytext + 2);
                                  return LNAME;
                                }
-<SCRIPT>{WILDCHAR}* { yylval.name = buystring(yytext); return NAME; }
+<SCRIPT>{WILDCHAR}* {
+               /* Annoyingly, this pattern can match comments, and we have
+                  longest match issues to consider.  So if the first two
+                  characters are a comment opening, put the input back and
+                  try again.  */
+               if (yytext[0] == '/' && yytext[1] == '*')
+                 {
+                   yyless(2);
+                   comment ();
+                 }
+               else
+                 {
+                   yylval.name = buystring(yytext);
+                   return NAME;
+                 }
+       }
 
-<EXPRESSION,BOTH,SCRIPT>"\""[^\"]*"\"" {
+<EXPRESSION,BOTH,SCRIPT,VERS_NODE>"\""[^\"]*"\"" {
                                        /* No matter the state, quotes
                                           give what's inside */
                                        yylval.name = buystring(yytext+1);
@@ -352,8 +371,7 @@ V_IDENTIFIER [*?$_a-zA-Z][*?_a-zA-Z0-9]*
                                        return NAME;
                                }
 <BOTH,SCRIPT,EXPRESSION>"\n"           { lineno++;}
-<BOTH,SCRIPT,EXPRESSION>"\r"           { lineno++;}
-<MRI,BOTH,SCRIPT,EXPRESSION>[ \t]
+<MRI,BOTH,SCRIPT,EXPRESSION>[ \t\r]+   { }
 
 <VERS_NODE,VERS_SCRIPT>[:,;]   { return *yytext; }
 
@@ -361,6 +379,8 @@ V_IDENTIFIER [*?$_a-zA-Z][*?_a-zA-Z0-9]*
 
 <VERS_NODE>local               { RTOKEN(LOCAL); }
 
+<VERS_NODE>extern              { RTOKEN(EXTERN); }
+
 <VERS_NODE>{V_IDENTIFIER}      { yylval.name = buystring (yytext);
                                  return VERS_IDENTIFIER; }
 
@@ -369,14 +389,22 @@ V_IDENTIFIER [*?$_a-zA-Z][*?_a-zA-Z0-9]*
 
 <VERS_START>"{"                        { BEGIN(VERS_SCRIPT); return *yytext; }
 
-<VERS_SCRIPT>"{"               { BEGIN(VERS_NODE); return *yytext; }
-<VERS_SCRIPT,VERS_NODE>"}"     { BEGIN(VERS_SCRIPT); return *yytext; }
+<VERS_SCRIPT>"{"               { BEGIN(VERS_NODE); 
+                                 vers_node_nesting = 0;
+                                 return *yytext;
+                               }
+<VERS_SCRIPT>"}"               { return *yytext; }
+<VERS_NODE>"{"                 { vers_node_nesting++; return *yytext; }
+<VERS_NODE>"}"                 { if (--vers_node_nesting < 0)
+                                   BEGIN(VERS_SCRIPT);
+                                 return *yytext;
+                               }
 
-<VERS_START,VERS_NODE,VERS_SCRIPT>[\n\r]       { lineno++; }
+<VERS_START,VERS_NODE,VERS_SCRIPT>[\n]         { lineno++; }
 
 <VERS_START,VERS_NODE,VERS_SCRIPT>#.*          { /* Eat up comments */ }
 
-<VERS_START,VERS_NODE,VERS_SCRIPT>[ \t]+       { /* Eat up whitespace */ }
+<VERS_START,VERS_NODE,VERS_SCRIPT>[ \t\r]+     { /* Eat up whitespace */ }
 
 <<EOF>> {
   include_stack_ptr--;
@@ -580,7 +608,7 @@ comment ()
     c = input();
     while (c != '*' && c != EOF) 
     {
-      if (c == '\n' || c == '\r')
+      if (c == '\n')
        lineno++;
       c = input();
     }
@@ -594,7 +622,7 @@ comment ()
        break;                  /* found the end */
     }
 
-    if (c == '\n' || c == '\r')
+    if (c == '\n')
       lineno++;
 
     if (c == EOF)
This page took 0.026761 seconds and 4 git commands to generate.