/* The routines in this file handle macro definition and expansion.
They are called by gas. */
-#define ISSEP(x) \
- (is_whitespace (x) || (x) == ',' || (x) == '"' || (x) == ';' \
- || (x) == ')' || (x) == '(' \
- || ((flag_macro_alternate || flag_mri) && ((x) == '<' || (x) == '>')))
-
-#define ISBASE(x) \
- ((x) == 'b' || (x) == 'B' \
- || (x) == 'q' || (x) == 'Q' \
- || (x) == 'h' || (x) == 'H' \
- || (x) == 'd' || (x) == 'D')
-
/* The macro hash table. */
htab_t macro_hash;
/* Fetch string from the input stream,
rules:
- 'Bxyx<whitespace> -> return 'Bxyza
%<expr> -> return string of decimal value of <expr>
"string" -> return string
(string) -> return (string-including-whitespaces)
if (idx < in->len)
{
- if (in->len > idx + 2 && in->ptr[idx + 1] == '\'' && ISBASE (in->ptr[idx]))
- {
- while (idx < in->len && !ISSEP (in->ptr[idx]))
- sb_add_char (out, in->ptr[idx++]);
- }
- else if (in->ptr[idx] == '%' && flag_macro_alternate)
+ if (in->ptr[idx] == '%' && flag_macro_alternate)
{
/* Turn the following expression into a string. */
expressionS ex;
idx = sb_skip_white (idx, in);
while (idx < in->len)
{
+ /* Look and see if it's a positional or keyword arg. */
size_t scan;
- /* Look and see if it's a positional or keyword arg. */
- scan = idx;
- while (scan < in->len
- && !ISSEP (in->ptr[scan])
- && !(flag_mri && in->ptr[scan] == '\'')
- && (!flag_macro_alternate && in->ptr[scan] != '='))
- scan++;
- if (scan < in->len && !flag_macro_alternate && in->ptr[scan] == '=')
+ sb_reset (&t);
+ scan = !flag_macro_alternate ? get_token (idx, in, &t) : idx;
+
+ if (scan > idx && scan < in->len && in->ptr[scan] == '=')
{
is_keyword = 1;
/* It's OK to go from positional to keyword. */
- /* This is a keyword arg, fetch the formal name and
- then the actual stuff. */
- sb_reset (&t);
- idx = get_token (idx, in, &t);
- if (idx >= in->len || in->ptr[idx] != '=')
- {
- err = _("confusion in formal parameters");
- break;
- }
-
/* Lookup the formal in the macro's list. */
ptr = str_hash_find (m->formal_hash, sb_terminate (&t));
if (!ptr)
t.ptr,
m->name);
sb_reset (&t);
- idx = get_any_string (idx + 1, in, &t);
+ /* Skip what would be the actual stuff. */
+ idx = get_any_string (scan + 1, in, &t);
}
else
{
m->name);
sb_reset (&ptr->actual);
}
- idx = get_any_string (idx + 1, in, &ptr->actual);
+ /* Fetch the actual stuff. */
+ idx = get_any_string (scan + 1, in, &ptr->actual);
if (ptr->actual.len > 0)
++narg;
}