Ignore:
Timestamp:
Aug 16, 2003, 6:59:22 PM (22 years ago)
Author:
bird
Message:

binutils v2.14 - offical sources.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/binutils/gas/app.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* This is the Assembler Pre-Processor
    22   Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
    3    1999, 2000
     3   1999, 2000, 2002, 2003
    44   Free Software Foundation, Inc.
    55
     
    2121   02111-1307, USA.  */
    2222
    23 /* Modified by Allen Wirfs-Brock, Instantiations Inc 2/90 */
     23/* Modified by Allen Wirfs-Brock, Instantiations Inc 2/90. */
    2424/* App, the assembler pre-processor.  This pre-processor strips out excess
    2525   spaces, turns single-quoted characters into a decimal constant, and turns
     
    2828
    2929#include <stdio.h>
    30 #include "as.h"                 /* For BAD_CASE() only */
     30#include "as.h"                 /* For BAD_CASE() only. */
    3131
    3232#if (__STDC__ != 1)
     
    4141   pseudo-op at different times.  */
    4242static int scrub_m68k_mri;
    43 #else
    44 #define scrub_m68k_mri 0
    45 #endif
    4643
    4744/* The pseudo-op which switches in and out of MRI mode.  See the
    4845   comment in do_scrub_chars.  */
    4946static const char mri_pseudo[] = ".mri 0";
     47#else
     48#define scrub_m68k_mri 0
     49#endif
    5050
    5151#if defined TC_ARM && defined OBJ_ELF
     
    7979#define LEX_IS_DOUBLEBAR_1ST            13
    8080#endif
     81#define LEX_IS_PARALLEL_SEPARATOR       14
    8182#define IS_SYMBOL_COMPONENT(c)          (lex[c] == LEX_IS_SYMBOL_COMPONENT)
    8283#define IS_WHITESPACE(c)                (lex[c] == LEX_IS_WHITESPACE)
    8384#define IS_LINE_SEPARATOR(c)            (lex[c] == LEX_IS_LINE_SEPARATOR)
     85#define IS_PARALLEL_SEPARATOR(c)        (lex[c] == LEX_IS_PARALLEL_SEPARATOR)
    8486#define IS_COMMENT(c)                   (lex[c] == LEX_IS_COMMENT_START)
    8587#define IS_LINE_COMMENT(c)              (lex[c] == LEX_IS_LINE_COMMENT_START)
     
    114116
    115117#if ! defined (TC_HPPA) && ! defined (TC_I370)
    116       /* I370 uses single-quotes to delimit integer, float constants */
     118      /* I370 uses single-quotes to delimit integer, float constants. */
    117119      lex['\''] = LEX_IS_ONECHAR_QUOTE;
    118120#endif
     
    129131     comment char, then it isn't a line separator.  */
    130132  for (p = symbol_chars; *p; ++p)
    131     {
    132       lex[(unsigned char) *p] = LEX_IS_SYMBOL_COMPONENT;
    133     }                           /* declare symbol characters */
     133    lex[(unsigned char) *p] = LEX_IS_SYMBOL_COMPONENT;
    134134
    135135  for (c = 128; c < 256; ++c)
     
    151151#endif
    152152  for (p = tc_comment_chars; *p; p++)
    153     {
    154       lex[(unsigned char) *p] = LEX_IS_COMMENT_START;
    155     }                           /* declare comment chars */
     153    lex[(unsigned char) *p] = LEX_IS_COMMENT_START;
    156154
    157155  for (p = line_comment_chars; *p; p++)
    158     {
    159       lex[(unsigned char) *p] = LEX_IS_LINE_COMMENT_START;
    160     }                           /* declare line comment chars */
     156    lex[(unsigned char) *p] = LEX_IS_LINE_COMMENT_START;
    161157
    162158  for (p = line_separator_chars; *p; p++)
    163     {
    164       lex[(unsigned char) *p] = LEX_IS_LINE_SEPARATOR;
    165     }                           /* declare line separators */
     159    lex[(unsigned char) *p] = LEX_IS_LINE_SEPARATOR;
     160
     161#ifdef tc_parallel_separator_chars
     162  /* This macro permits the processor to specify all characters which
     163     separate parallel insns on the same line.  */
     164  for (p = tc_parallel_separator_chars; *p; p++)
     165    lex[(unsigned char) *p] = LEX_IS_PARALLEL_SEPARATOR;
     166#endif
    166167
    167168  /* Only allow slash-star comments if slash is not in use.
    168169     FIXME: This isn't right.  We should always permit them.  */
    169170  if (lex['/'] == 0)
    170     {
    171       lex['/'] = LEX_IS_TWOCHAR_COMMENT_1ST;
    172     }
     171    lex['/'] = LEX_IS_TWOCHAR_COMMENT_1ST;
    173172
    174173#ifdef TC_M68K
     
    179178      lex['*'] = LEX_IS_LINE_COMMENT_START;
    180179      /* The MRI documentation says '!' is LEX_IS_COMMENT_START, but
    181         then it can't be used in an expression.  */
     180        then it can't be used in an expression.  */
    182181      lex['!'] = LEX_IS_LINE_COMMENT_START;
    183182    }
     
    191190#endif
    192191#ifdef TC_D30V
    193   /* must do this is we want VLIW instruction with "->" or "<-" */
     192  /* Must do this is we want VLIW instruction with "->" or "<-". */
    194193  lex['-'] = LEX_IS_SYMBOL_COMPONENT;
    195194#endif
    196 }                               /* do_scrub_begin() */
    197 
    198 /* Saved state of the scrubber */
     195}
     196
     197/* Saved state of the scrubber. */
    199198static int state;
    200199static int old_state;
     
    213212   That's why we have to save it all.  */
    214213
    215 struct app_save {
     214struct app_save
     215{
    216216  int          state;
    217217  int          old_state;
     
    299299
    300300  free (arg);
    301 }                               /* app_pop() */
     301}
    302302
    303303/* @@ This assumes that \n &c are the same on host and target.  This is not
    304304   necessarily true.  */
     305
    305306static int
    306307process_escape (ch)
     
    367368         -2: flush text until a '*' '/' is seen, then go to state old_state
    368369#ifdef TC_V850
    369          12: After seeing a dash, looking for a second dash as a start of comment.
     370         12: After seeing a dash, looking for a second dash as a start
     371             of comment.
    370372#endif
    371373#ifdef DOUBLEBAR_PARALLEL
    372          13: After seeing a vertical bar, looking for a second vertical bar as a parallel expression seperator.
     374         13: After seeing a vertical bar, looking for a second
     375             vertical bar as a parallel expression separator.
    373376#endif
    374377          */
     
    377380     constructs like ``.loc 1 20''.  This was turning into ``.loc
    378381     120''.  States 9 and 10 ensure that a space is never dropped in
    379      between characters which could appear in a identifier.  Ian
     382     between characters which could appear in an identifier.  Ian
    380383     Taylor, ian@cygnus.com.
    381384
     
    414417     memory usage.  */
    415418
    416 #define PUT(pch)                        \
    417   do                                    \
    418     {                                   \
    419       *to++ = (pch);                    \
    420       if (to >= toend)                  \
    421         goto tofull;                    \
    422     }                                   \
     419#define PUT(pch)                                \
     420  do                                            \
     421    {                                           \
     422      *to++ = (pch);                            \
     423      if (to >= toend)                          \
     424        goto tofull;                            \
     425    }                                           \
    423426  while (0)
    424427
     
    440443    {
    441444      /* The cases in this switch end with continue, in order to
    442         branch back to the top of this while loop and generate the
    443         next output character in the appropriate state.  */
     445        branch back to the top of this while loop and generate the
     446        next output character in the appropriate state.  */
    444447      switch (state)
    445448        {
     
    524527        case 5:
    525528          /* We are going to copy everything up to a quote character,
    526              with special handling for a backslash.  We try to
    527              optimize the copying in the simple case without using the
    528              GET and PUT macros.  */
     529             with special handling for a backslash.  We try to
     530             optimize the copying in the simple case without using the
     531             GET and PUT macros.  */
    529532          {
    530533            char *s;
     
    535538                ch = *s;
    536539                /* This condition must be changed if the type of any
    537                    other character can be LEX_IS_STRINGQUOTE.  */
     540                   other character can be LEX_IS_STRINGQUOTE.  */
    538541                if (ch == '\\'
    539542                    || ch == '"'
     
    556559          if (ch == EOF)
    557560            {
    558               as_warn (_("end of file in string: inserted '\"'"));
     561              as_warn (_("end of file in string; inserted '\"'"));
    559562              state = old_state;
    560563              UNGET ('\n');
     
    576579            {
    577580              /* Just quietly terminate the string.  This permits lines like
    578                    bne  label   loop if we haven't reach end yet
    579                  */
     581                   bne  label   loop if we haven't reach end yet.  */
    580582              state = old_state;
    581583              UNGET (ch);
     
    599601              add_newlines++;
    600602              PUT ('\\');
     603              continue;
     604
     605            case EOF:
     606              as_warn (_("end of file in string; '\"' inserted"));
     607              PUT ('"');
    601608              continue;
    602609
     
    620627            case '7':
    621628              break;
    622 #if defined(IGNORE_NONSTANDARD_ESCAPES) | defined(ONLY_STANDARD_ESCAPES)
     629
    623630            default:
    624               as_warn (_("Unknown escape '\\%c' in string: Ignored"), ch);
     631#ifdef ONLY_STANDARD_ESCAPES
     632              as_warn (_("unknown escape '\\%c' in string; ignored"), ch);
     633#endif
    625634              break;
    626 #else  /* ONLY_STANDARD_ESCAPES */
    627             default:
    628               /* Accept \x as x for any x */
    629               break;
    630 #endif /* ONLY_STANDARD_ESCAPES */
    631 
    632             case EOF:
    633               as_warn (_("End of file in string: '\"' inserted"));
    634               PUT ('"');
    635               continue;
    636635            }
    637636          PUT (ch);
     
    656655          PUT (ch);
    657656          continue;
     657
     658#ifdef DOUBLEBAR_PARALLEL
     659        case 13:
     660          ch = GET ();
     661          if (ch != '|')
     662            abort ();
     663
     664          /* Reset back to state 1 and pretend that we are parsing a
     665             line from just after the first white space.  */
     666          state = 1;
     667          PUT ('|');
     668          continue;
     669#endif
    658670        }
    659671
    660       /* OK, we are somewhere in states 0 through 4 or 9 through 11 */
     672      /* OK, we are somewhere in states 0 through 4 or 9 through 11. */
    661673
    662674      /* flushchar: */
     
    696708#ifdef TC_M68K
    697709      /* We want to have pseudo-ops which control whether we are in
    698         MRI mode or not.  Unfortunately, since m68k MRI mode affects
    699         the scrubber, that means that we need a special purpose
    700         recognizer here.  */
     710        MRI mode or not.  Unfortunately, since m68k MRI mode affects
     711        the scrubber, that means that we need a special purpose
     712        recognizer here.  */
    701713      if (mri_state == NULL)
    702714        {
     
    735747            {
    736748              /* We've read the entire pseudo-op.  mips_last_ch is
    737                 either '0' or '1' indicating whether to enter or
    738                 leave MRI mode.  */
     749                either '0' or '1' indicating whether to enter or
     750                leave MRI mode.  */
    739751              do_scrub_begin (mri_last_ch == '1');
    740752              mri_state = NULL;
    741753
    742754              /* We continue handling the character as usual.  The
    743                 main gas reader must also handle the .mri pseudo-op
    744                 to control expression parsing and the like.  */
     755                main gas reader must also handle the .mri pseudo-op
     756                to control expression parsing and the like.  */
    745757            }
    746758        }
     
    783795            {
    784796              /* Only keep this white if there's no white *after* the
    785                 colon.  */
     797                colon.  */
    786798              ch2 = GET ();
    787799              UNGET (ch2);
     
    797809          if (IS_COMMENT (ch)
    798810              || ch == '/'
    799               || IS_LINE_SEPARATOR (ch))
     811              || IS_LINE_SEPARATOR (ch)
     812              || IS_PARALLEL_SEPARATOR (ch))
    800813            {
    801814              if (scrub_m68k_mri)
     
    870883                {
    871884                  /* We know that ch is not ':', since we tested that
    872                      case above.  Therefore this is not a label, so it
    873                      must be the opcode, and we've just seen the
    874                      whitespace after it.  */
     885                     case above.  Therefore this is not a label, so it
     886                     must be the opcode, and we've just seen the
     887                     whitespace after it.  */
    875888                  state = 3;
    876889                }
     
    904917
    905918                  /* This UNGET will ensure that we count newlines
    906                      correctly.  */
     919                     correctly.  */
    907920                  UNGET (ch2);
    908921                }
     
    942955          if (state == 10)
    943956            {
    944               /* Preserve the whitespace in foo "bar" */
     957              /* Preserve the whitespace in foo "bar". */
    945958              UNGET (ch);
    946959              state = 3;
     
    948961
    949962              /* PUT didn't jump out.  We could just break, but we
    950                 know what will happen, so optimize a bit.  */
     963                know what will happen, so optimize a bit.  */
    951964              ch = GET ();
    952965              old_state = 3;
     
    964977          if (state == 10)
    965978            {
    966               /* Preserve the whitespace in foo 'b' */
     979              /* Preserve the whitespace in foo 'b'. */
    967980              UNGET (ch);
    968981              state = 3;
     
    9931006            {
    9941007#ifdef REQUIRE_CHAR_CLOSE_QUOTE
    995               as_warn (_("Missing close quote: (assumed)"));
     1008              as_warn (_("missing close quote; (assumed)"));
    9961009#else
    9971010              if (ch != EOF)
     
    10401053          break;
    10411054
     1055        case LEX_IS_PARALLEL_SEPARATOR:
     1056          state = 1;
     1057          PUT (ch);
     1058          break;
     1059
    10421060#ifdef TC_V850
    10431061        case LEX_IS_DOUBLEDASH_1ST:
     
    10541072            }
    10551073          while (ch != EOF && ch != '\n');
     1074
    10561075          if (ch == EOF)
    1057             {
    1058               as_warn (_("end of file in comment; newline inserted"));
    1059             }
     1076            as_warn (_("end of file in comment; newline inserted"));
     1077
    10601078          state = 0;
    10611079          PUT ('\n');
     
    10651083        case LEX_IS_DOUBLEBAR_1ST:
    10661084          ch2 = GET ();
     1085          UNGET (ch2);
    10671086          if (ch2 != '|')
    1068             {
    1069               UNGET (ch2);
    1070               goto de_fault;
    1071             }
    1072           /* Reset back to state 1 and pretend that we are parsing a line from
    1073              just after the first white space.  */
    1074           state = 1;
    1075           PUT ('|');
     1087            goto de_fault;
     1088
     1089          /* Handle '||' in two states as invoking PUT twice might
     1090             result in the first one jumping out of this loop.  We'd
     1091             then lose track of the state and one '|' char.  */
     1092          state = 13;
    10761093          PUT ('|');
    10771094          break;
     
    10951112                  UNGET (ch2);
    10961113                }
    1097             } /* bad hack */
     1114            }
    10981115
    10991116          if (state == 0 || state == 1) /* Only comment at start of line.  */
     
    11081125                }
    11091126              while (ch != EOF && IS_WHITESPACE (ch));
     1127
    11101128              if (ch == EOF)
    11111129                {
     
    11141132                  break;
    11151133                }
     1134
    11161135              if (ch < '0' || ch > '9' || state != 0 || startch != '#')
    11171136                {
     
    11201139                    ch = GET ();
    11211140                  if (ch == EOF)
    1122                     as_warn (_("EOF in Comment: Newline inserted"));
     1141                    as_warn (_("end of file in comment; newline inserted"));
    11231142                  state = 0;
    11241143                  PUT ('\n');
     
    12061225
    12071226          /* This is a common case.  Quickly copy CH and all the
    1208              following symbol component or normal characters.  */
     1227             following symbol component or normal characters.  */
    12091228          if (to + 1 < toend
    12101229              && mri_state == NULL
     
    12271246                    break;
    12281247                }
     1248
    12291249              if (s > from)
    1230                 {
    1231                   /* Handle the last character normally, for
    1232                      simplicity.  */
    1233                   --s;
    1234                 }
     1250                /* Handle the last character normally, for
     1251                   simplicity.  */
     1252                --s;
     1253
    12351254              len = s - from;
     1255
    12361256              if (len > (toend - to) - 1)
    12371257                len = (toend - to) - 1;
     1258
    12381259              if (len > 0)
    12391260                {
     
    12691290          if (state == 0)
    12701291            {
    1271               state = 11;       /* Now seeing label definition */
     1292              state = 11;       /* Now seeing label definition. */
    12721293            }
    12731294          else if (state == 1)
    12741295            {
    1275               state = 2;        /* Ditto */
     1296              state = 2;        /* Ditto. */
    12761297            }
    12771298          else if (state == 9)
     
    13261347}
    13271348
    1328 /* end of app.c */
Note: See TracChangeset for help on using the changeset viewer.