Lines Matching defs:in

14    GAS is distributed in the hope that it will be useful,
29 /* The routines in this file handle macro definition and expansion.
53 /* Whether we are in alternate syntax mode. */
57 /* Whether we are in MRI mode. */
87 /* Switch in and out of alternate mode on the fly. */
95 /* Switch in and out of MRI mode on the fly. */
135 to the dot. With the alternate, labels have to start in
251 get_token (size_t idx, sb *in, sb *name)
253 if (idx < in->len
254 && is_name_beginner (in->ptr[idx]))
256 sb_add_char (name, in->ptr[idx++]);
257 while (idx < in->len
258 && is_part_of_name (in->ptr[idx]))
260 sb_add_char (name, in->ptr[idx++]);
262 if (idx < in->len
263 && is_name_ender (in->ptr[idx]))
265 sb_add_char (name, in->ptr[idx++]);
269 if (macro_alternate && idx < in->len && in->ptr[idx] == '&')
277 getstring (size_t idx, sb *in, sb *acc)
279 while (idx < in->len
280 && (in->ptr[idx] == '"'
281 || (in->ptr[idx] == '<' && (macro_alternate || macro_mri))
282 || (in->ptr[idx] == '\'' && macro_alternate)))
284 if (in->ptr[idx] == '<')
288 while ((in->ptr[idx] != '>' || nest)
289 && idx < in->len)
291 if (in->ptr[idx] == '!')
294 sb_add_char (acc, in->ptr[idx++]);
298 if (in->ptr[idx] == '>')
300 if (in->ptr[idx] == '<')
302 sb_add_char (acc, in->ptr[idx++]);
307 else if (in->ptr[idx] == '"' || in->ptr[idx] == '\'')
309 char tchar = in->ptr[idx];
314 while (idx < in->len)
316 if (in->ptr[idx - 1] == '\\')
321 if (macro_alternate && in->ptr[idx] == '!')
325 sb_add_char (acc, in->ptr[idx]);
329 else if (escaped && in->ptr[idx] == tchar)
336 if (in->ptr[idx] == tchar)
340 if (idx >= in->len || in->ptr[idx] != tchar)
344 sb_add_char (acc, in->ptr[idx]);
363 get_any_string (size_t idx, sb *in, sb *out)
366 idx = sb_skip_white (idx, in);
368 if (idx < in->len)
370 if (in->len > idx + 2 && in->ptr[idx + 1] == '\'' && ISBASE (in->ptr[idx]))
372 while (!ISSEP (in->ptr[idx]))
373 sb_add_char (out, in->ptr[idx++]);
375 else if (in->ptr[idx] == '%' && macro_alternate)
384 in,
389 else if (in->ptr[idx] == '"'
390 || (in->ptr[idx] == '<' && (macro_alternate || macro_mri))
391 || (macro_alternate && in->ptr[idx] == '\''))
393 if (macro_alternate && ! macro_strip_at && in->ptr[idx] != '<')
397 idx = getstring (idx, in, out);
402 idx = getstring (idx, in, out);
411 while (idx < in->len
413 || (in->ptr[idx] != ' '
414 && in->ptr[idx] != '\t'))
415 && in->ptr[idx] != ','
416 && (in->ptr[idx] != '<'
419 char tchar = in->ptr[idx];
425 sb_add_char (out, in->ptr[idx++]);
426 while (idx < in->len
427 && in->ptr[idx] != tchar)
428 sb_add_char (out, in->ptr[idx++]);
429 if (idx == in->len)
498 do_formals (macro_entry *macro, size_t idx, sb *in)
503 idx = sb_skip_white (idx, in);
504 while (idx < in->len)
509 idx = get_token (idx, in, &formal->name);
517 idx = sb_skip_white (idx, in);
521 && idx < in->len
522 && in->ptr[idx] == ':'
524 || idx + 1 >= in->len
525 || ! is_part_of_name (in->ptr[idx + 1])))
531 idx = get_token (sb_skip_white (idx + 1, in), in, &qual);
536 _("Missing parameter qualifier for `%s' in macro `%s'"),
546 _("`%s' is not a valid parameter qualifier for `%s' in macro `%s'"),
551 idx = sb_skip_white (idx, in);
553 if (idx < in->len && in->ptr[idx] == '=')
556 idx = get_any_string (idx + 1, in, &formal->def);
557 idx = sb_skip_white (idx, in);
563 _("Pointless default value for required parameter `%s' in macro `%s'"),
585 idx = sb_skip_comma (idx, in);
586 if (idx != cidx && idx >= in->len)
612 _("Reserved word `%s' used as parameter in macro `%s'"),
649 define_macro (size_t idx, sb *in, sb *label,
668 idx = sb_skip_white (idx, in);
670 error = _("unexpected end of file in macro `%s' definition");
675 if (idx < in->len && in->ptr[idx] == '(')
678 idx = do_formals (macro, idx + 1, in);
679 if (idx < in->len && in->ptr[idx] == ')')
680 idx = sb_skip_white (idx + 1, in);
682 error = _("missing `)' after formals in macro definition `%s'");
687 idx = do_formals (macro, idx, in);
694 idx = get_token (idx, in, &name);
698 cidx = sb_skip_white (idx, in);
699 idx = sb_skip_comma (cidx, in);
700 if (idx == cidx || idx < in->len)
701 idx = do_formals (macro, idx, in);
705 if (!error && idx < in->len)
708 /* And stick it in the macro hash table. */
730 get_apost_token (size_t idx, sb *in, sb *name, int kind)
732 idx = get_token (idx, in, name);
733 if (idx < in->len
734 && in->ptr[idx] == kind
744 sub_actual (size_t start, sb *in, sb *t, struct hash_control *formal_hash,
750 src = get_apost_token (start, in, t, kind);
751 /* See if it's in the macro's hash table, unless this is
752 macro_strip_at and kind is '@' and the token did not end in '@'. */
755 && (src == start || in->ptr[src - 1] != '@'))
772 /* Doing this permits people to use & in macro bodies. */
775 if (src != start && in->ptr[src - 1] == '&')
793 macro_expand_body (sb *in, sb *out, formal_entry *formals,
804 while (src < in->len && !err)
806 if (in->ptr[src] == '&')
811 if (src + 1 < in->len && in->ptr[src + 1] == '&')
812 src = sub_actual (src + 2, in, &t, formal_hash, '\'', out, 1);
814 sb_add_char (out, in->ptr[src++]);
820 src = sub_actual (src + 1, in, &t, formal_hash, '&', out, 0);
823 else if (in->ptr[src] == '\\')
826 if (src < in->len && in->ptr[src] == '(')
828 /* Sub in till the next ')' literally. */
830 while (src < in->len && in->ptr[src] != ')')
832 sb_add_char (out, in->ptr[src++]);
834 if (src < in->len)
841 else if (src < in->len && in->ptr[src] == '@')
843 /* Sub in the macro invocation number. */
850 else if (src < in->len && in->ptr[src] == '&')
858 else if (macro_mri && src < in->len && ISALNUM (in->ptr[src]))
863 if (ISDIGIT (in->ptr[src]))
864 ind = in->ptr[src] - '0';
865 else if (ISUPPER (in->ptr[src]))
866 ind = in->ptr[src] - 'A' + 10;
868 ind = in->ptr[src] - 'a' + 10;
885 src = sub_actual (src, in, &t, formal_hash, '\'', out, 0);
889 && is_name_beginner (in->ptr[src])
892 || (src > 0 && in->ptr[src - 1] == '@')))
895 || src + 5 >= in->len
896 || strncasecmp (in->ptr + src, "LOCAL", 5) != 0
897 || ! ISWHITE (in->ptr[src + 5])
902 src = sub_actual (src, in, &t, formal_hash,
908 src = sb_skip_white (src + 5, in);
909 while (in->ptr[src] != '\n')
914 src = get_token (src, in, &f->name);
941 src = sb_skip_comma (src, in);
945 else if (in->ptr[src] == '"'
946 || (macro_mri && in->ptr[src] == '\''))
949 sb_add_char (out, in->ptr[src++]);
951 else if (in->ptr[src] == '@' && macro_strip_at)
954 if (src < in->len
955 && in->ptr[src] == '@')
962 && in->ptr[src] == '='
963 && src + 1 < in->len
964 && in->ptr[src + 1] == '=')
969 src = get_token (src + 2, in, &t);
974 but we can't, because the == might be in the MRI
979 the == in place, which should cause a syntax error if
980 it is not in a comment. */
999 if (in->ptr[src] == '\n')
1001 sb_add_char (out, in->ptr[src++]);
1026 macro_expand (size_t idx, sb *in, macro_entry *m, sb *out)
1047 be referred to in the macro body as \0. */
1048 if (idx < in->len && in->ptr[idx] == '.')
1053 if ( idx < in->len
1054 && in->ptr[idx] != ' '
1055 && in->ptr[idx] != '\t')
1064 idx = get_any_string (idx, in, &n->actual);
1069 /* Peel off the actuals and store them away in the hash tables' actuals. */
1070 idx = sb_skip_white (idx, in);
1071 while (idx < in->len)
1077 while (scan < in->len
1078 && !ISSEP (in->ptr[scan])
1079 && !(macro_mri && in->ptr[scan] == '\'')
1080 && (!macro_alternate && in->ptr[scan] != '='))
1082 if (scan < in->len && !macro_alternate && in->ptr[scan] == '=')
1091 idx = get_token (idx, in, &t);
1092 if (in->ptr[idx] != '=')
1094 err = _("confusion in formal parameters");
1098 /* Lookup the formal in the macro's list. */
1106 idx = get_any_string (idx + 1, in, &t);
1118 idx = get_any_string (idx + 1, in, &ptr->actual);
1155 idx = get_any_string (idx, in, &f->actual);
1158 sb_add_buffer (&f->actual, in->ptr + idx, in->len - idx);
1159 idx = in->len;
1171 idx = sb_skip_comma (idx, in);
1174 if (in->ptr[idx] == ',')
1176 if (ISWHITE (in->ptr[idx]))
1263 /* Wrap the line up in an sb. */
1296 macros in reverse order to their definition.
1313 expand_irp (int irpc, size_t idx, sb *in, sb *out, size_t (*get_line) (sb *))
1320 idx = sb_skip_white (idx, in);
1324 return _("unexpected end of file in irp or irpc");
1330 idx = get_token (idx, in, &f.name);
1345 idx = sb_skip_comma (idx, in);
1346 if (idx >= in->len)
1355 if (irpc && in->ptr[idx] == '"')
1361 while (idx < in->len)
1364 idx = get_any_string (idx, in, &f.actual);
1367 if (in->ptr[idx] == '"')
1374 nxt = sb_skip_white (idx + 1, in);
1375 if (nxt >= in->len)
1382 sb_add_char (&f.actual, in->ptr[idx]);
1390 idx = sb_skip_comma (idx, in);
1392 idx = sb_skip_white (idx, in);