This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

GAS: Treat macro parameters as valid symbol starters


Hi Guys,

  The patch below is to fix a bug with GAS's macro expansion
  capability.  Given an input file of the form:

    .macro FOO arg
      opcode text \arg  
    .endm

        FOO register

  The assembler will actually pass this string to the md_assemble()
  function: 

	opcode textregister

  (ie no space between 'text' and 'register').

  To fix this the patch adds a new lexical value, LEX_IS_BACKSLASH,
  which allows it to treat backslashes just as it did before except
  when in state 10 (after seeing a whitespace after a symchar), when
  it can now treat the backslash as introducing another symbol.

  OK to apply ?

Cheers
	Nick


2000-02-14  Nick Clifton  <nickc@cygnus.com>

	* app.c (LEX_IS_BACKSLASH): New lexical value.  For characters
	that can introduce a macro parameter.
	(do_scrub_chars): If a macro parameter is encountered whilst
	in state 10, treat it as introducing a new symbol.

Index: app.c
===================================================================
RCS file: /cvs/src//src/gas/app.c,v
retrieving revision 1.5
diff -p -r1.5 app.c
*** app.c	2000/02/10 21:00:10	1.5
--- app.c	2000/02/14 21:59:18
*************** static const char symbol_chars[] =
*** 72,78 ****
  #endif
  #ifdef DOUBLEBAR_PARALLEL
  #define LEX_IS_DOUBLEBAR_1ST		13
! #endif
  #define IS_SYMBOL_COMPONENT(c)		(lex[c] == LEX_IS_SYMBOL_COMPONENT)
  #define IS_WHITESPACE(c)		(lex[c] == LEX_IS_WHITESPACE)
  #define IS_LINE_SEPARATOR(c)		(lex[c] == LEX_IS_LINE_SEPARATOR)
--- 72,80 ----
  #endif
  #ifdef DOUBLEBAR_PARALLEL
  #define LEX_IS_DOUBLEBAR_1ST		13
! #endi
! #define LEX_IS_BACKSLASH		14
! 
  #define IS_SYMBOL_COMPONENT(c)		(lex[c] == LEX_IS_SYMBOL_COMPONENT)
  #define IS_WHITESPACE(c)		(lex[c] == LEX_IS_WHITESPACE)
  #define IS_LINE_SEPARATOR(c)		(lex[c] == LEX_IS_LINE_SEPARATOR)
*************** do_scrub_begin (m68k_mri)
*** 101,106 ****
--- 103,109 ----
    lex['\n'] = LEX_IS_NEWLINE;
    lex[';'] = LEX_IS_LINE_SEPARATOR;
    lex[':'] = LEX_IS_COLON;
+   lex['\\'] = LEX_IS_BACKSLASH;
  
    if (! m68k_mri)
      {
*************** do_scrub_chars (get, tostart, tolen)
*** 1270,1275 ****
--- 1273,1291 ----
  	    }
  	  PUT (ch);
  	  break;
+ 	  
+ 	case LEX_IS_BACKSLASH:
+ 	  if (state == 10)
+ 	    {
+ 	      /* This is a macro parameter following a symbol character
+ 		 with whitespace in between.  We skipped the whitespace
+ 		 earlier, so output it now.  */
+ 	      UNGET (ch);
+ 	      state = 3;
+ 	      PUT (' ');
+ 	      break;
+ 	    }
+ 	  goto de_fault;
  	}
      }
  

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]