1 /* expr.c -operands, expressions-
2 Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
4 Free Software Foundation, Inc.
6 This file is part of GAS, the GNU Assembler.
8 GAS is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GAS is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GAS; see the file COPYING. If not, write to the Free
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 /* This is really a branch office of as-read.c. I split it out to clearly
24 distinguish the world of expressions from the world of statements.
25 (It also gives smaller files to re-compile.)
26 Here, "operand"s are of expressions, not instructions. */
29 #define min(a, b) ((a) < (b) ? (a) : (b))
32 #include "safe-ctype.h"
35 static void floating_constant (expressionS
* expressionP
);
36 static valueT
generic_bignum_to_int32 (void);
38 static valueT
generic_bignum_to_int64 (void);
40 static void integer_constant (int radix
, expressionS
* expressionP
);
41 static void mri_char_constant (expressionS
*);
42 static void current_location (expressionS
*);
43 static void clean_up_expression (expressionS
* expressionP
);
44 static segT
operand (expressionS
*);
45 static operatorT
operator (int *);
47 extern const char EXP_CHARS
[], FLT_CHARS
[];
49 /* We keep a mapping of expression symbols to file positions, so that
50 we can provide better error messages. */
52 struct expr_symbol_line
{
53 struct expr_symbol_line
*next
;
59 static struct expr_symbol_line
*expr_symbol_lines
;
61 /* Build a dummy symbol to hold a complex expression. This is how we
62 build expressions up out of other expressions. The symbol is put
63 into the fake section expr_section. */
66 make_expr_symbol (expressionS
*expressionP
)
70 struct expr_symbol_line
*n
;
72 if (expressionP
->X_op
== O_symbol
73 && expressionP
->X_add_number
== 0)
74 return expressionP
->X_add_symbol
;
76 if (expressionP
->X_op
== O_big
)
78 /* This won't work, because the actual value is stored in
79 generic_floating_point_number or generic_bignum, and we are
80 going to lose it if we haven't already. */
81 if (expressionP
->X_add_number
> 0)
82 as_bad (_("bignum invalid"));
84 as_bad (_("floating point number invalid"));
85 zero
.X_op
= O_constant
;
86 zero
.X_add_number
= 0;
88 clean_up_expression (&zero
);
92 /* Putting constant symbols in absolute_section rather than
93 expr_section is convenient for the old a.out code, for which
94 S_GET_SEGMENT does not always retrieve the value put in by
96 symbolP
= symbol_create (FAKE_LABEL_NAME
,
97 (expressionP
->X_op
== O_constant
100 0, &zero_address_frag
);
101 symbol_set_value_expression (symbolP
, expressionP
);
103 if (expressionP
->X_op
== O_constant
)
104 resolve_symbol_value (symbolP
);
106 n
= (struct expr_symbol_line
*) xmalloc (sizeof *n
);
108 as_where (&n
->file
, &n
->line
);
109 n
->next
= expr_symbol_lines
;
110 expr_symbol_lines
= n
;
115 /* Return the file and line number for an expr symbol. Return
116 non-zero if something was found, 0 if no information is known for
120 expr_symbol_where (symbolS
*sym
, char **pfile
, unsigned int *pline
)
122 register struct expr_symbol_line
*l
;
124 for (l
= expr_symbol_lines
; l
!= NULL
; l
= l
->next
)
137 /* Utilities for building expressions.
138 Since complex expressions are recorded as symbols for use in other
139 expressions these return a symbolS * and not an expressionS *.
140 These explicitly do not take an "add_number" argument. */
141 /* ??? For completeness' sake one might want expr_build_symbol.
142 It would just return its argument. */
144 /* Build an expression for an unsigned constant.
145 The corresponding one for signed constants is missing because
146 there's currently no need for it. One could add an unsigned_p flag
147 but that seems more clumsy. */
150 expr_build_uconstant (offsetT value
)
155 e
.X_add_number
= value
;
157 return make_expr_symbol (&e
);
160 /* Build an expression for OP s1. */
163 expr_build_unary (operatorT op
, symbolS
*s1
)
170 return make_expr_symbol (&e
);
173 /* Build an expression for s1 OP s2. */
176 expr_build_binary (operatorT op
, symbolS
*s1
, symbolS
*s2
)
184 return make_expr_symbol (&e
);
187 /* Build an expression for the current location ('.'). */
190 expr_build_dot (void)
194 current_location (&e
);
195 return make_expr_symbol (&e
);
198 /* Build any floating-point literal here.
199 Also build any bignum literal here. */
201 /* Seems atof_machine can backscan through generic_bignum and hit whatever
202 happens to be loaded before it in memory. And its way too complicated
203 for me to fix right. Thus a hack. JF: Just make generic_bignum bigger,
204 and never write into the early words, thus they'll always be zero.
205 I hate Dean's floating-point code. Bleh. */
206 LITTLENUM_TYPE generic_bignum
[SIZE_OF_LARGE_NUMBER
+ 6];
208 FLONUM_TYPE generic_floating_point_number
= {
209 &generic_bignum
[6], /* low. (JF: Was 0) */
210 &generic_bignum
[SIZE_OF_LARGE_NUMBER
+ 6 - 1], /* high. JF: (added +6) */
216 /* If nonzero, we've been asked to assemble nan, +inf or -inf. */
217 int generic_floating_point_magic
;
220 floating_constant (expressionS
*expressionP
)
222 /* input_line_pointer -> floating-point constant. */
225 error_code
= atof_generic (&input_line_pointer
, ".", EXP_CHARS
,
226 &generic_floating_point_number
);
230 if (error_code
== ERROR_EXPONENT_OVERFLOW
)
232 as_bad (_("bad floating-point constant: exponent overflow"));
236 as_bad (_("bad floating-point constant: unknown error code=%d"),
240 expressionP
->X_op
= O_big
;
241 /* input_line_pointer -> just after constant, which may point to
243 expressionP
->X_add_number
= -1;
247 generic_bignum_to_int32 (void)
250 ((generic_bignum
[1] & LITTLENUM_MASK
) << LITTLENUM_NUMBER_OF_BITS
)
251 | (generic_bignum
[0] & LITTLENUM_MASK
);
252 number
&= 0xffffffff;
258 generic_bignum_to_int64 (void)
261 ((((((((valueT
) generic_bignum
[3] & LITTLENUM_MASK
)
262 << LITTLENUM_NUMBER_OF_BITS
)
263 | ((valueT
) generic_bignum
[2] & LITTLENUM_MASK
))
264 << LITTLENUM_NUMBER_OF_BITS
)
265 | ((valueT
) generic_bignum
[1] & LITTLENUM_MASK
))
266 << LITTLENUM_NUMBER_OF_BITS
)
267 | ((valueT
) generic_bignum
[0] & LITTLENUM_MASK
));
273 integer_constant (int radix
, expressionS
*expressionP
)
275 char *start
; /* Start of number. */
278 valueT number
; /* Offset or (absolute) value. */
279 short int digit
; /* Value of next digit in current radix. */
280 short int maxdig
= 0; /* Highest permitted digit value. */
281 int too_many_digits
= 0; /* If we see >= this number of. */
282 char *name
; /* Points to name of symbol. */
283 symbolS
*symbolP
; /* Points to symbol. */
285 int small
; /* True if fits in 32 bits. */
287 /* May be bignum, or may fit in 32 bits. */
288 /* Most numbers fit into 32 bits, and we want this case to be fast.
289 so we pretend it will fit into 32 bits. If, after making up a 32
290 bit number, we realise that we have scanned more digits than
291 comfortably fit into 32 bits, we re-scan the digits coding them
292 into a bignum. For decimal and octal numbers we are
293 conservative: Some numbers may be assumed bignums when in fact
294 they do fit into 32 bits. Numbers of any radix can have excess
295 leading zeros: We strive to recognise this and cast them back
296 into 32 bits. We must check that the bignum really is more than
297 32 bits, and change it back to a 32-bit number if it fits. The
298 number we are looking for is expected to be positive, but if it
299 fits into 32 bits as an unsigned number, we let it be a 32-bit
300 number. The cavalier approach is for speed in ordinary cases. */
301 /* This has been extended for 64 bits. We blindly assume that if
302 you're compiling in 64-bit mode, the target is a 64-bit machine.
303 This should be cleaned up. */
307 #else /* includes non-bfd case, mostly */
311 if ((NUMBERS_WITH_SUFFIX
|| flag_m68k_mri
) && radix
== 0)
315 /* In MRI mode, the number may have a suffix indicating the
316 radix. For that matter, it might actually be a floating
318 for (suffix
= input_line_pointer
; ISALNUM (*suffix
); suffix
++)
320 if (*suffix
== 'e' || *suffix
== 'E')
324 if (suffix
== input_line_pointer
)
337 else if (c
== 'O' || c
== 'Q')
341 else if (suffix
[1] == '.' || c
== 'E' || flt
)
343 floating_constant (expressionP
);
358 too_many_digits
= valuesize
+ 1;
362 too_many_digits
= (valuesize
+ 2) / 3 + 1;
366 too_many_digits
= (valuesize
+ 3) / 4 + 1;
370 too_many_digits
= (valuesize
+ 11) / 4; /* Very rough. */
373 start
= input_line_pointer
;
374 c
= *input_line_pointer
++;
376 (digit
= hex_value (c
)) < maxdig
;
377 c
= *input_line_pointer
++)
379 number
= number
* radix
+ digit
;
381 /* c contains character after number. */
382 /* input_line_pointer->char after c. */
383 small
= (input_line_pointer
- start
- 1) < too_many_digits
;
385 if (radix
== 16 && c
== '_')
387 /* This is literal of the form 0x333_0_12345678_1.
388 This example is equivalent to 0x00000333000000001234567800000001. */
390 int num_little_digits
= 0;
392 input_line_pointer
= start
; /* -> 1st digit. */
394 know (LITTLENUM_NUMBER_OF_BITS
== 16);
396 for (c
= '_'; c
== '_'; num_little_digits
+= 2)
399 /* Convert one 64-bit word. */
402 for (c
= *input_line_pointer
++;
403 (digit
= hex_value (c
)) < maxdig
;
404 c
= *(input_line_pointer
++))
406 number
= number
* radix
+ digit
;
410 /* Check for 8 digit per word max. */
412 as_bad (_("a bignum with underscores may not have more than 8 hex digits in any word"));
414 /* Add this chunk to the bignum.
415 Shift things down 2 little digits. */
416 know (LITTLENUM_NUMBER_OF_BITS
== 16);
417 for (i
= min (num_little_digits
+ 1, SIZE_OF_LARGE_NUMBER
- 1);
420 generic_bignum
[i
] = generic_bignum
[i
- 2];
422 /* Add the new digits as the least significant new ones. */
423 generic_bignum
[0] = number
& 0xffffffff;
424 generic_bignum
[1] = number
>> 16;
427 /* Again, c is char after number, input_line_pointer->after c. */
429 if (num_little_digits
> SIZE_OF_LARGE_NUMBER
- 1)
430 num_little_digits
= SIZE_OF_LARGE_NUMBER
- 1;
432 assert (num_little_digits
>= 4);
434 if (num_little_digits
!= 8)
435 as_bad (_("a bignum with underscores must have exactly 4 words"));
437 /* We might have some leading zeros. These can be trimmed to give
438 us a change to fit this constant into a small number. */
439 while (generic_bignum
[num_little_digits
- 1] == 0
440 && num_little_digits
> 1)
443 if (num_little_digits
<= 2)
445 /* will fit into 32 bits. */
446 number
= generic_bignum_to_int32 ();
450 else if (num_little_digits
<= 4)
452 /* Will fit into 64 bits. */
453 number
= generic_bignum_to_int64 ();
461 /* Number of littlenums in the bignum. */
462 number
= num_little_digits
;
467 /* We saw a lot of digits. manufacture a bignum the hard way. */
468 LITTLENUM_TYPE
*leader
; /* -> high order littlenum of the bignum. */
469 LITTLENUM_TYPE
*pointer
; /* -> littlenum we are frobbing now. */
472 leader
= generic_bignum
;
473 generic_bignum
[0] = 0;
474 generic_bignum
[1] = 0;
475 generic_bignum
[2] = 0;
476 generic_bignum
[3] = 0;
477 input_line_pointer
= start
; /* -> 1st digit. */
478 c
= *input_line_pointer
++;
479 for (; (carry
= hex_value (c
)) < maxdig
; c
= *input_line_pointer
++)
481 for (pointer
= generic_bignum
; pointer
<= leader
; pointer
++)
485 work
= carry
+ radix
* *pointer
;
486 *pointer
= work
& LITTLENUM_MASK
;
487 carry
= work
>> LITTLENUM_NUMBER_OF_BITS
;
491 if (leader
< generic_bignum
+ SIZE_OF_LARGE_NUMBER
- 1)
493 /* Room to grow a longer bignum. */
498 /* Again, c is char after number. */
499 /* input_line_pointer -> after c. */
500 know (LITTLENUM_NUMBER_OF_BITS
== 16);
501 if (leader
< generic_bignum
+ 2)
503 /* Will fit into 32 bits. */
504 number
= generic_bignum_to_int32 ();
508 else if (leader
< generic_bignum
+ 4)
510 /* Will fit into 64 bits. */
511 number
= generic_bignum_to_int64 ();
517 /* Number of littlenums in the bignum. */
518 number
= leader
- generic_bignum
+ 1;
522 if ((NUMBERS_WITH_SUFFIX
|| flag_m68k_mri
)
524 && input_line_pointer
- 1 == suffix
)
525 c
= *input_line_pointer
++;
529 /* Here with number, in correct radix. c is the next char.
530 Note that unlike un*x, we allow "011f" "0x9f" to both mean
531 the same as the (conventional) "9f".
532 This is simply easier than checking for strict canonical
535 if (LOCAL_LABELS_FB
&& c
== 'b')
537 /* Backward ref to local label.
538 Because it is backward, expect it to be defined. */
539 /* Construct a local label. */
540 name
= fb_label_name ((int) number
, 0);
542 /* Seen before, or symbol is defined: OK. */
543 symbolP
= symbol_find (name
);
544 if ((symbolP
!= NULL
) && (S_IS_DEFINED (symbolP
)))
546 /* Local labels are never absolute. Don't waste time
547 checking absoluteness. */
548 know (SEG_NORMAL (S_GET_SEGMENT (symbolP
)));
550 expressionP
->X_op
= O_symbol
;
551 expressionP
->X_add_symbol
= symbolP
;
555 /* Either not seen or not defined. */
556 /* @@ Should print out the original string instead of
557 the parsed number. */
558 as_bad (_("backward ref to unknown label \"%d:\""),
560 expressionP
->X_op
= O_constant
;
563 expressionP
->X_add_number
= 0;
565 else if (LOCAL_LABELS_FB
&& c
== 'f')
567 /* Forward reference. Expect symbol to be undefined or
568 unknown. undefined: seen it before. unknown: never seen
571 Construct a local label name, then an undefined symbol.
572 Don't create a xseg frag for it: caller may do that.
573 Just return it as never seen before. */
574 name
= fb_label_name ((int) number
, 1);
575 symbolP
= symbol_find_or_make (name
);
576 /* We have no need to check symbol properties. */
577 #ifndef many_segments
578 /* Since "know" puts its arg into a "string", we
579 can't have newlines in the argument. */
580 know (S_GET_SEGMENT (symbolP
) == undefined_section
|| S_GET_SEGMENT (symbolP
) == text_section
|| S_GET_SEGMENT (symbolP
) == data_section
);
582 expressionP
->X_op
= O_symbol
;
583 expressionP
->X_add_symbol
= symbolP
;
584 expressionP
->X_add_number
= 0;
586 else if (LOCAL_LABELS_DOLLAR
&& c
== '$')
588 /* If the dollar label is *currently* defined, then this is just
589 another reference to it. If it is not *currently* defined,
590 then this is a fresh instantiation of that number, so create
593 if (dollar_label_defined ((long) number
))
595 name
= dollar_label_name ((long) number
, 0);
596 symbolP
= symbol_find (name
);
597 know (symbolP
!= NULL
);
601 name
= dollar_label_name ((long) number
, 1);
602 symbolP
= symbol_find_or_make (name
);
605 expressionP
->X_op
= O_symbol
;
606 expressionP
->X_add_symbol
= symbolP
;
607 expressionP
->X_add_number
= 0;
611 expressionP
->X_op
= O_constant
;
612 #ifdef TARGET_WORD_SIZE
613 /* Sign extend NUMBER. */
614 number
|= (-(number
>> (TARGET_WORD_SIZE
- 1))) << (TARGET_WORD_SIZE
- 1);
616 expressionP
->X_add_number
= number
;
617 input_line_pointer
--; /* Restore following character. */
618 } /* Really just a number. */
622 /* Not a small number. */
623 expressionP
->X_op
= O_big
;
624 expressionP
->X_add_number
= number
; /* Number of littlenums. */
625 input_line_pointer
--; /* -> char following number. */
629 /* Parse an MRI multi character constant. */
632 mri_char_constant (expressionS
*expressionP
)
636 if (*input_line_pointer
== '\''
637 && input_line_pointer
[1] != '\'')
639 expressionP
->X_op
= O_constant
;
640 expressionP
->X_add_number
= 0;
644 /* In order to get the correct byte ordering, we must build the
645 number in reverse. */
646 for (i
= SIZE_OF_LARGE_NUMBER
- 1; i
>= 0; i
--)
650 generic_bignum
[i
] = 0;
651 for (j
= 0; j
< CHARS_PER_LITTLENUM
; j
++)
653 if (*input_line_pointer
== '\'')
655 if (input_line_pointer
[1] != '\'')
657 ++input_line_pointer
;
659 generic_bignum
[i
] <<= 8;
660 generic_bignum
[i
] += *input_line_pointer
;
661 ++input_line_pointer
;
664 if (i
< SIZE_OF_LARGE_NUMBER
- 1)
666 /* If there is more than one littlenum, left justify the
667 last one to make it match the earlier ones. If there is
668 only one, we can just use the value directly. */
669 for (; j
< CHARS_PER_LITTLENUM
; j
++)
670 generic_bignum
[i
] <<= 8;
673 if (*input_line_pointer
== '\''
674 && input_line_pointer
[1] != '\'')
680 as_bad (_("character constant too large"));
689 c
= SIZE_OF_LARGE_NUMBER
- i
;
690 for (j
= 0; j
< c
; j
++)
691 generic_bignum
[j
] = generic_bignum
[i
+ j
];
695 know (LITTLENUM_NUMBER_OF_BITS
== 16);
698 expressionP
->X_op
= O_big
;
699 expressionP
->X_add_number
= i
;
703 expressionP
->X_op
= O_constant
;
705 expressionP
->X_add_number
= generic_bignum
[0] & LITTLENUM_MASK
;
707 expressionP
->X_add_number
=
708 (((generic_bignum
[1] & LITTLENUM_MASK
)
709 << LITTLENUM_NUMBER_OF_BITS
)
710 | (generic_bignum
[0] & LITTLENUM_MASK
));
713 /* Skip the final closing quote. */
714 ++input_line_pointer
;
717 /* Return an expression representing the current location. This
718 handles the magic symbol `.'. */
721 current_location (expressionS
*expressionp
)
723 if (now_seg
== absolute_section
)
725 expressionp
->X_op
= O_constant
;
726 expressionp
->X_add_number
= abs_section_offset
;
730 expressionp
->X_op
= O_symbol
;
731 expressionp
->X_add_symbol
= symbol_temp_new_now ();
732 expressionp
->X_add_number
= 0;
736 /* In: Input_line_pointer points to 1st char of operand, which may
740 The operand may have been empty: in this case X_op == O_absent.
741 Input_line_pointer->(next non-blank) char after operand. */
744 operand (expressionS
*expressionP
)
747 symbolS
*symbolP
; /* Points to symbol. */
748 char *name
; /* Points to name of symbol. */
751 /* All integers are regarded as unsigned unless they are negated.
752 This is because the only thing which cares whether a number is
753 unsigned is the code in emit_expr which extends constants into
754 bignums. It should only sign extend negative numbers, so that
755 something like ``.quad 0x80000000'' is not sign extended even
756 though it appears negative if valueT is 32 bits. */
757 expressionP
->X_unsigned
= 1;
759 /* Digits, assume it is a bignum. */
761 SKIP_WHITESPACE (); /* Leading whitespace is part of operand. */
762 c
= *input_line_pointer
++; /* input_line_pointer -> past char in c. */
764 if (is_end_of_line
[(unsigned char) c
])
778 input_line_pointer
--;
780 integer_constant ((NUMBERS_WITH_SUFFIX
|| flag_m68k_mri
)
785 #ifdef LITERAL_PREFIXDOLLAR_HEX
787 /* $L is the start of a local label, not a hex constant. */
788 if (* input_line_pointer
== 'L')
790 integer_constant (16, expressionP
);
794 #ifdef LITERAL_PREFIXPERCENT_BIN
796 integer_constant (2, expressionP
);
801 /* Non-decimal radix. */
803 if (NUMBERS_WITH_SUFFIX
|| flag_m68k_mri
)
807 /* Check for a hex or float constant. */
808 for (s
= input_line_pointer
; hex_p (*s
); s
++)
810 if (*s
== 'h' || *s
== 'H' || *input_line_pointer
== '.')
812 --input_line_pointer
;
813 integer_constant (0, expressionP
);
817 c
= *input_line_pointer
;
826 if (NUMBERS_WITH_SUFFIX
|| flag_m68k_mri
)
828 integer_constant (0, expressionP
);
834 if (c
&& strchr (FLT_CHARS
, c
))
836 input_line_pointer
++;
837 floating_constant (expressionP
);
838 expressionP
->X_add_number
= - TOLOWER (c
);
842 /* The string was only zero. */
843 expressionP
->X_op
= O_constant
;
844 expressionP
->X_add_number
= 0;
853 input_line_pointer
++;
854 integer_constant (16, expressionP
);
858 if (LOCAL_LABELS_FB
&& ! (flag_m68k_mri
|| NUMBERS_WITH_SUFFIX
))
860 /* This code used to check for '+' and '-' here, and, in
861 some conditions, fall through to call
862 integer_constant. However, that didn't make sense,
863 as integer_constant only accepts digits. */
864 /* Some of our code elsewhere does permit digits greater
865 than the expected base; for consistency, do the same
867 if (input_line_pointer
[1] < '0'
868 || input_line_pointer
[1] > '9')
870 /* Parse this as a back reference to label 0. */
871 input_line_pointer
--;
872 integer_constant (10, expressionP
);
875 /* Otherwise, parse this as a binary number. */
879 input_line_pointer
++;
880 if (flag_m68k_mri
|| NUMBERS_WITH_SUFFIX
)
882 integer_constant (2, expressionP
);
893 integer_constant ((flag_m68k_mri
|| NUMBERS_WITH_SUFFIX
)
901 /* If it says "0f" and it could possibly be a floating point
902 number, make it one. Otherwise, make it a local label,
903 and try to deal with parsing the rest later. */
904 if (!input_line_pointer
[1]
905 || (is_end_of_line
[0xff & input_line_pointer
[1]])
906 || strchr (FLT_CHARS
, 'f') == NULL
)
909 char *cp
= input_line_pointer
+ 1;
910 int r
= atof_generic (&cp
, ".", EXP_CHARS
,
911 &generic_floating_point_number
);
915 case ERROR_EXPONENT_OVERFLOW
:
916 if (*cp
== 'f' || *cp
== 'b')
917 /* Looks like a difference expression. */
919 else if (cp
== input_line_pointer
+ 1)
920 /* No characters has been accepted -- looks like
926 as_fatal (_("expr.c(operand): bad atof_generic return val %d"),
931 /* Okay, now we've sorted it out. We resume at one of these
932 two labels, depending on what we've decided we're probably
935 input_line_pointer
--;
936 integer_constant (10, expressionP
);
946 if (flag_m68k_mri
|| NUMBERS_WITH_SUFFIX
)
948 integer_constant (0, expressionP
);
958 input_line_pointer
++;
959 floating_constant (expressionP
);
960 expressionP
->X_add_number
= - TOLOWER (c
);
964 if (LOCAL_LABELS_DOLLAR
)
966 integer_constant (10, expressionP
);
976 #ifndef NEED_INDEX_OPERATOR
979 /* Didn't begin with digit & not a name. */
980 segment
= expression (expressionP
);
981 /* expression () will pass trailing whitespace. */
982 if ((c
== '(' && *input_line_pointer
!= ')')
983 || (c
== '[' && *input_line_pointer
!= ']'))
985 #ifdef RELAX_PAREN_GROUPING
988 as_bad (_("missing '%c'"), c
== '(' ? ')' : ']');
991 input_line_pointer
++;
993 /* Here with input_line_pointer -> char after "(...)". */
998 if (! flag_m68k_mri
|| *input_line_pointer
!= '\'')
1000 as_bad (_("EBCDIC constants are not supported"));
1003 if (! flag_m68k_mri
|| *input_line_pointer
!= '\'')
1005 ++input_line_pointer
;
1009 if (! flag_m68k_mri
)
1011 /* Warning: to conform to other people's assemblers NO
1012 ESCAPEMENT is permitted for a single quote. The next
1013 character, parity errors and all, is taken as the value
1014 of the operand. VERY KINKY. */
1015 expressionP
->X_op
= O_constant
;
1016 expressionP
->X_add_number
= *input_line_pointer
++;
1020 mri_char_constant (expressionP
);
1024 /* Do not accept ++e as +(+e).
1025 Disabled, since the preprocessor removes whitespace. */
1026 if (0 && *input_line_pointer
== '+')
1028 (void) operand (expressionP
);
1033 /* Double quote is the bitwise not operator in MRI mode. */
1034 if (! flag_m68k_mri
)
1039 /* '~' is permitted to start a label on the Delta. */
1040 if (is_name_beginner (c
))
1045 /* Do not accept --e as -(-e)
1046 Disabled, since the preprocessor removes whitespace. */
1047 if (0 && c
== '-' && *input_line_pointer
== '-')
1050 operand (expressionP
);
1051 if (expressionP
->X_op
== O_constant
)
1053 /* input_line_pointer -> char after operand. */
1056 expressionP
->X_add_number
= - expressionP
->X_add_number
;
1057 /* Notice: '-' may overflow: no warning is given.
1058 This is compatible with other people's
1059 assemblers. Sigh. */
1060 expressionP
->X_unsigned
= 0;
1062 else if (c
== '~' || c
== '"')
1063 expressionP
->X_add_number
= ~ expressionP
->X_add_number
;
1065 expressionP
->X_add_number
= ! expressionP
->X_add_number
;
1067 else if (expressionP
->X_op
== O_big
1068 && expressionP
->X_add_number
<= 0
1070 && (generic_floating_point_number
.sign
== '+'
1071 || generic_floating_point_number
.sign
== 'P'))
1073 /* Negative flonum (eg, -1.000e0). */
1074 if (generic_floating_point_number
.sign
== '+')
1075 generic_floating_point_number
.sign
= '-';
1077 generic_floating_point_number
.sign
= 'N';
1079 else if (expressionP
->X_op
== O_big
1080 && expressionP
->X_add_number
> 0)
1084 if (c
== '~' || c
== '-')
1086 for (i
= 0; i
< expressionP
->X_add_number
; ++i
)
1087 generic_bignum
[i
] = ~generic_bignum
[i
];
1089 for (i
= 0; i
< expressionP
->X_add_number
; ++i
)
1091 generic_bignum
[i
] += 1;
1092 if (generic_bignum
[i
])
1099 for (i
= 0; i
< expressionP
->X_add_number
; ++i
)
1101 if (generic_bignum
[i
])
1103 generic_bignum
[i
] = 0;
1105 generic_bignum
[0] = nonzero
;
1108 else if (expressionP
->X_op
!= O_illegal
1109 && expressionP
->X_op
!= O_absent
)
1111 expressionP
->X_add_symbol
= make_expr_symbol (expressionP
);
1113 expressionP
->X_op
= O_uminus
;
1114 else if (c
== '~' || c
== '"')
1115 expressionP
->X_op
= O_bit_not
;
1117 expressionP
->X_op
= O_logical_not
;
1118 expressionP
->X_add_number
= 0;
1121 as_warn (_("Unary operator %c ignored because bad operand follows"),
1126 #if defined (DOLLAR_DOT) || defined (TC_M68K)
1128 /* '$' is the program counter when in MRI mode, or when
1129 DOLLAR_DOT is defined. */
1131 if (! flag_m68k_mri
)
1134 if (flag_m68k_mri
&& hex_p (*input_line_pointer
))
1136 /* In MRI mode, '$' is also used as the prefix for a
1137 hexadecimal constant. */
1138 integer_constant (16, expressionP
);
1142 if (is_part_of_name (*input_line_pointer
))
1145 current_location (expressionP
);
1150 if (!is_part_of_name (*input_line_pointer
))
1152 current_location (expressionP
);
1155 else if ((strncasecmp (input_line_pointer
, "startof.", 8) == 0
1156 && ! is_part_of_name (input_line_pointer
[8]))
1157 || (strncasecmp (input_line_pointer
, "sizeof.", 7) == 0
1158 && ! is_part_of_name (input_line_pointer
[7])))
1162 start
= (input_line_pointer
[1] == 't'
1163 || input_line_pointer
[1] == 'T');
1164 input_line_pointer
+= start
? 8 : 7;
1166 if (*input_line_pointer
!= '(')
1167 as_bad (_("syntax error in .startof. or .sizeof."));
1172 ++input_line_pointer
;
1174 name
= input_line_pointer
;
1175 c
= get_symbol_end ();
1177 buf
= (char *) xmalloc (strlen (name
) + 10);
1179 sprintf (buf
, ".startof.%s", name
);
1181 sprintf (buf
, ".sizeof.%s", name
);
1182 symbolP
= symbol_make (buf
);
1185 expressionP
->X_op
= O_symbol
;
1186 expressionP
->X_add_symbol
= symbolP
;
1187 expressionP
->X_add_number
= 0;
1189 *input_line_pointer
= c
;
1191 if (*input_line_pointer
!= ')')
1192 as_bad (_("syntax error in .startof. or .sizeof."));
1194 ++input_line_pointer
;
1205 /* Can't imagine any other kind of operand. */
1206 expressionP
->X_op
= O_absent
;
1207 input_line_pointer
--;
1212 if (! flag_m68k_mri
)
1214 integer_constant (2, expressionP
);
1218 if (! flag_m68k_mri
)
1220 integer_constant (8, expressionP
);
1224 if (! flag_m68k_mri
)
1227 /* In MRI mode, this is a floating point constant represented
1228 using hexadecimal digits. */
1230 ++input_line_pointer
;
1231 integer_constant (16, expressionP
);
1235 if (! flag_m68k_mri
|| is_part_of_name (*input_line_pointer
))
1238 current_location (expressionP
);
1246 if (is_name_beginner (c
)) /* Here if did not begin with a digit. */
1248 /* Identifier begins here.
1249 This is kludged for speed, so code is repeated. */
1251 name
= --input_line_pointer
;
1252 c
= get_symbol_end ();
1254 #ifdef md_parse_name
1255 /* This is a hook for the backend to parse certain names
1256 specially in certain contexts. If a name always has a
1257 specific value, it can often be handled by simply
1258 entering it in the symbol table. */
1259 if (md_parse_name (name
, expressionP
, &c
))
1261 *input_line_pointer
= c
;
1267 /* The MRI i960 assembler permits
1269 FIXME: This should use md_parse_name. */
1271 && (strcasecmp (name
, "sizeof") == 0
1272 || strcasecmp (name
, "startof") == 0))
1277 start
= (name
[1] == 't'
1280 *input_line_pointer
= c
;
1283 name
= input_line_pointer
;
1284 c
= get_symbol_end ();
1286 buf
= (char *) xmalloc (strlen (name
) + 10);
1288 sprintf (buf
, ".startof.%s", name
);
1290 sprintf (buf
, ".sizeof.%s", name
);
1291 symbolP
= symbol_make (buf
);
1294 expressionP
->X_op
= O_symbol
;
1295 expressionP
->X_add_symbol
= symbolP
;
1296 expressionP
->X_add_number
= 0;
1298 *input_line_pointer
= c
;
1305 symbolP
= symbol_find_or_make (name
);
1307 /* If we have an absolute symbol or a reg, then we know its
1309 segment
= S_GET_SEGMENT (symbolP
);
1310 if (segment
== absolute_section
)
1312 expressionP
->X_op
= O_constant
;
1313 expressionP
->X_add_number
= S_GET_VALUE (symbolP
);
1315 else if (segment
== reg_section
)
1317 expressionP
->X_op
= O_register
;
1318 expressionP
->X_add_number
= S_GET_VALUE (symbolP
);
1322 expressionP
->X_op
= O_symbol
;
1323 expressionP
->X_add_symbol
= symbolP
;
1324 expressionP
->X_add_number
= 0;
1326 *input_line_pointer
= c
;
1331 /* Let the target try to parse it. Success is indicated by changing
1332 the X_op field to something other than O_absent and pointing
1333 input_line_pointer past the expression. If it can't parse the
1334 expression, X_op and input_line_pointer should be unchanged. */
1335 expressionP
->X_op
= O_absent
;
1336 --input_line_pointer
;
1337 md_operand (expressionP
);
1338 if (expressionP
->X_op
== O_absent
)
1340 ++input_line_pointer
;
1341 as_bad (_("bad expression"));
1342 expressionP
->X_op
= O_constant
;
1343 expressionP
->X_add_number
= 0;
1349 /* It is more 'efficient' to clean up the expressionS when they are
1350 created. Doing it here saves lines of code. */
1351 clean_up_expression (expressionP
);
1352 SKIP_WHITESPACE (); /* -> 1st char after operand. */
1353 know (*input_line_pointer
!= ' ');
1355 /* The PA port needs this information. */
1356 if (expressionP
->X_add_symbol
)
1357 symbol_mark_used (expressionP
->X_add_symbol
);
1359 switch (expressionP
->X_op
)
1362 return absolute_section
;
1364 return S_GET_SEGMENT (expressionP
->X_add_symbol
);
1370 /* Internal. Simplify a struct expression for use by expr (). */
1372 /* In: address of an expressionS.
1373 The X_op field of the expressionS may only take certain values.
1374 Elsewise we waste time special-case testing. Sigh. Ditto SEG_ABSENT.
1376 Out: expressionS may have been modified:
1377 Unused fields zeroed to help expr (). */
1380 clean_up_expression (expressionS
*expressionP
)
1382 switch (expressionP
->X_op
)
1386 expressionP
->X_add_number
= 0;
1391 expressionP
->X_add_symbol
= NULL
;
1396 expressionP
->X_op_symbol
= NULL
;
1403 /* Expression parser. */
1405 /* We allow an empty expression, and just assume (absolute,0) silently.
1406 Unary operators and parenthetical expressions are treated as operands.
1407 As usual, Q==quantity==operand, O==operator, X==expression mnemonics.
1409 We used to do an aho/ullman shift-reduce parser, but the logic got so
1410 warped that I flushed it and wrote a recursive-descent parser instead.
1411 Now things are stable, would anybody like to write a fast parser?
1412 Most expressions are either register (which does not even reach here)
1413 or 1 symbol. Then "symbol+constant" and "symbol-symbol" are common.
1414 So I guess it doesn't really matter how inefficient more complex expressions
1417 After expr(RANK,resultP) input_line_pointer->operator of rank <= RANK.
1418 Also, we have consumed any leading or trailing spaces (operand does that)
1419 and done all intervening operators.
1421 This returns the segment of the result, which will be
1422 absolute_section or the segment of a symbol. */
1425 #define __ O_illegal
1427 /* Maps ASCII -> operators. */
1428 static const operatorT op_encoding
[256] = {
1429 __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
,
1430 __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
,
1432 __
, O_bit_or_not
, __
, __
, __
, O_modulus
, O_bit_and
, __
,
1433 __
, __
, O_multiply
, O_add
, __
, O_subtract
, __
, O_divide
,
1434 __
, __
, __
, __
, __
, __
, __
, __
,
1435 __
, __
, __
, __
, O_lt
, __
, O_gt
, __
,
1436 __
, __
, __
, __
, __
, __
, __
, __
,
1437 __
, __
, __
, __
, __
, __
, __
, __
,
1438 __
, __
, __
, __
, __
, __
, __
, __
,
1440 #ifdef NEED_INDEX_OPERATOR
1445 __
, __
, O_bit_exclusive_or
, __
,
1446 __
, __
, __
, __
, __
, __
, __
, __
,
1447 __
, __
, __
, __
, __
, __
, __
, __
,
1448 __
, __
, __
, __
, __
, __
, __
, __
,
1449 __
, __
, __
, __
, O_bit_inclusive_or
, __
, __
, __
,
1451 __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
,
1452 __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
,
1453 __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
,
1454 __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
,
1455 __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
,
1456 __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
,
1457 __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
,
1458 __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
, __
1462 0 operand, (expression)
1467 5 used for * / % in MRI mode
1472 static operator_rankT op_rank
[] = {
1477 0, /* O_symbol_rva */
1482 9, /* O_logical_not */
1486 8, /* O_left_shift */
1487 8, /* O_right_shift */
1488 7, /* O_bit_inclusive_or */
1489 7, /* O_bit_or_not */
1490 7, /* O_bit_exclusive_or */
1500 3, /* O_logical_and */
1501 2, /* O_logical_or */
1521 /* Unfortunately, in MRI mode for the m68k, multiplication and
1522 division have lower precedence than the bit wise operators. This
1523 function sets the operator precedences correctly for the current
1524 mode. Also, MRI uses a different bit_not operator, and this fixes
1527 #define STANDARD_MUL_PRECEDENCE 8
1528 #define MRI_MUL_PRECEDENCE 6
1531 expr_set_precedence (void)
1535 op_rank
[O_multiply
] = MRI_MUL_PRECEDENCE
;
1536 op_rank
[O_divide
] = MRI_MUL_PRECEDENCE
;
1537 op_rank
[O_modulus
] = MRI_MUL_PRECEDENCE
;
1541 op_rank
[O_multiply
] = STANDARD_MUL_PRECEDENCE
;
1542 op_rank
[O_divide
] = STANDARD_MUL_PRECEDENCE
;
1543 op_rank
[O_modulus
] = STANDARD_MUL_PRECEDENCE
;
1547 /* Initialize the expression parser. */
1552 expr_set_precedence ();
1554 /* Verify that X_op field is wide enough. */
1558 assert (e
.X_op
== O_max
);
1562 /* Return the encoding for the operator at INPUT_LINE_POINTER, and
1563 sets NUM_CHARS to the number of characters in the operator.
1564 Does not advance INPUT_LINE_POINTER. */
1566 static inline operatorT
1567 operator (int *num_chars
)
1572 c
= *input_line_pointer
& 0xff;
1575 if (is_end_of_line
[c
])
1581 return op_encoding
[c
];
1585 /* Do not allow a++b and a--b to be a + (+b) and a - (-b)
1586 Disabled, since the preprocessor removes whitespace. */
1587 if (1 || input_line_pointer
[1] != c
)
1588 return op_encoding
[c
];
1592 switch (input_line_pointer
[1])
1595 return op_encoding
[c
];
1610 if (input_line_pointer
[1] != '=')
1611 return op_encoding
[c
];
1617 switch (input_line_pointer
[1])
1620 return op_encoding
[c
];
1622 ret
= O_right_shift
;
1632 /* We accept !! as equivalent to ^ for MRI compatibility. */
1633 if (input_line_pointer
[1] != '!')
1636 return O_bit_inclusive_or
;
1637 return op_encoding
[c
];
1640 return O_bit_exclusive_or
;
1643 if (input_line_pointer
[1] != '|')
1644 return op_encoding
[c
];
1647 return O_logical_or
;
1650 if (input_line_pointer
[1] != '&')
1651 return op_encoding
[c
];
1654 return O_logical_and
;
1660 /* Parse an expression. */
1663 expr (int rankarg
, /* Larger # is higher rank. */
1664 expressionS
*resultP
/* Deliver result here. */)
1666 operator_rankT rank
= (operator_rankT
) rankarg
;
1675 /* Save the value of dot for the fixup code. */
1677 dot_value
= frag_now_fix ();
1679 retval
= operand (resultP
);
1681 /* operand () gobbles spaces. */
1682 know (*input_line_pointer
!= ' ');
1684 op_left
= operator (&op_chars
);
1685 while (op_left
!= O_illegal
&& op_rank
[(int) op_left
] > rank
)
1689 input_line_pointer
+= op_chars
; /* -> after operator. */
1691 rightseg
= expr (op_rank
[(int) op_left
], &right
);
1692 if (right
.X_op
== O_absent
)
1694 as_warn (_("missing operand; zero assumed"));
1695 right
.X_op
= O_constant
;
1696 right
.X_add_number
= 0;
1697 right
.X_add_symbol
= NULL
;
1698 right
.X_op_symbol
= NULL
;
1701 know (*input_line_pointer
!= ' ');
1703 if (op_left
== O_index
)
1705 if (*input_line_pointer
!= ']')
1706 as_bad ("missing right bracket");
1709 ++input_line_pointer
;
1714 op_right
= operator (&op_chars
);
1716 know (op_right
== O_illegal
1717 || op_rank
[(int) op_right
] <= op_rank
[(int) op_left
]);
1718 know ((int) op_left
>= (int) O_multiply
1719 && (int) op_left
<= (int) O_logical_or
);
1721 /* input_line_pointer->after right-hand quantity. */
1722 /* left-hand quantity in resultP. */
1723 /* right-hand quantity in right. */
1724 /* operator in op_left. */
1726 if (resultP
->X_op
== O_big
)
1728 if (resultP
->X_add_number
> 0)
1729 as_warn (_("left operand is a bignum; integer 0 assumed"));
1731 as_warn (_("left operand is a float; integer 0 assumed"));
1732 resultP
->X_op
= O_constant
;
1733 resultP
->X_add_number
= 0;
1734 resultP
->X_add_symbol
= NULL
;
1735 resultP
->X_op_symbol
= NULL
;
1737 if (right
.X_op
== O_big
)
1739 if (right
.X_add_number
> 0)
1740 as_warn (_("right operand is a bignum; integer 0 assumed"));
1742 as_warn (_("right operand is a float; integer 0 assumed"));
1743 right
.X_op
= O_constant
;
1744 right
.X_add_number
= 0;
1745 right
.X_add_symbol
= NULL
;
1746 right
.X_op_symbol
= NULL
;
1749 /* Optimize common cases. */
1750 #ifdef md_optimize_expr
1751 if (md_optimize_expr (resultP
, op_left
, &right
))
1758 if (op_left
== O_add
&& right
.X_op
== O_constant
)
1761 resultP
->X_add_number
+= right
.X_add_number
;
1763 /* This case comes up in PIC code. */
1764 else if (op_left
== O_subtract
1765 && right
.X_op
== O_symbol
1766 && resultP
->X_op
== O_symbol
1767 && (symbol_get_frag (right
.X_add_symbol
)
1768 == symbol_get_frag (resultP
->X_add_symbol
))
1769 && (SEG_NORMAL (rightseg
)
1770 || right
.X_add_symbol
== resultP
->X_add_symbol
))
1772 resultP
->X_add_number
-= right
.X_add_number
;
1773 resultP
->X_add_number
+= (S_GET_VALUE (resultP
->X_add_symbol
)
1774 - S_GET_VALUE (right
.X_add_symbol
));
1775 resultP
->X_op
= O_constant
;
1776 resultP
->X_add_symbol
= 0;
1778 else if (op_left
== O_subtract
&& right
.X_op
== O_constant
)
1781 resultP
->X_add_number
-= right
.X_add_number
;
1783 else if (op_left
== O_add
&& resultP
->X_op
== O_constant
)
1786 resultP
->X_op
= right
.X_op
;
1787 resultP
->X_add_symbol
= right
.X_add_symbol
;
1788 resultP
->X_op_symbol
= right
.X_op_symbol
;
1789 resultP
->X_add_number
+= right
.X_add_number
;
1792 else if (resultP
->X_op
== O_constant
&& right
.X_op
== O_constant
)
1794 /* Constant OP constant. */
1795 offsetT v
= right
.X_add_number
;
1796 if (v
== 0 && (op_left
== O_divide
|| op_left
== O_modulus
))
1798 as_warn (_("division by zero"));
1804 case O_multiply
: resultP
->X_add_number
*= v
; break;
1805 case O_divide
: resultP
->X_add_number
/= v
; break;
1806 case O_modulus
: resultP
->X_add_number
%= v
; break;
1807 case O_left_shift
: resultP
->X_add_number
<<= v
; break;
1809 /* We always use unsigned shifts, to avoid relying on
1810 characteristics of the compiler used to compile gas. */
1811 resultP
->X_add_number
=
1812 (offsetT
) ((valueT
) resultP
->X_add_number
>> (valueT
) v
);
1814 case O_bit_inclusive_or
: resultP
->X_add_number
|= v
; break;
1815 case O_bit_or_not
: resultP
->X_add_number
|= ~v
; break;
1816 case O_bit_exclusive_or
: resultP
->X_add_number
^= v
; break;
1817 case O_bit_and
: resultP
->X_add_number
&= v
; break;
1818 case O_add
: resultP
->X_add_number
+= v
; break;
1819 case O_subtract
: resultP
->X_add_number
-= v
; break;
1821 resultP
->X_add_number
=
1822 resultP
->X_add_number
== v
? ~ (offsetT
) 0 : 0;
1825 resultP
->X_add_number
=
1826 resultP
->X_add_number
!= v
? ~ (offsetT
) 0 : 0;
1829 resultP
->X_add_number
=
1830 resultP
->X_add_number
< v
? ~ (offsetT
) 0 : 0;
1833 resultP
->X_add_number
=
1834 resultP
->X_add_number
<= v
? ~ (offsetT
) 0 : 0;
1837 resultP
->X_add_number
=
1838 resultP
->X_add_number
>= v
? ~ (offsetT
) 0 : 0;
1841 resultP
->X_add_number
=
1842 resultP
->X_add_number
> v
? ~ (offsetT
) 0 : 0;
1845 resultP
->X_add_number
= resultP
->X_add_number
&& v
;
1848 resultP
->X_add_number
= resultP
->X_add_number
|| v
;
1852 else if (resultP
->X_op
== O_symbol
1853 && right
.X_op
== O_symbol
1854 && (op_left
== O_add
1855 || op_left
== O_subtract
1856 || (resultP
->X_add_number
== 0
1857 && right
.X_add_number
== 0)))
1859 /* Symbol OP symbol. */
1860 resultP
->X_op
= op_left
;
1861 resultP
->X_op_symbol
= right
.X_add_symbol
;
1862 if (op_left
== O_add
)
1863 resultP
->X_add_number
+= right
.X_add_number
;
1864 else if (op_left
== O_subtract
)
1866 resultP
->X_add_number
-= right
.X_add_number
;
1867 if (retval
== rightseg
&& SEG_NORMAL (retval
))
1869 retval
= absolute_section
;
1870 rightseg
= absolute_section
;
1876 /* The general case. */
1877 resultP
->X_add_symbol
= make_expr_symbol (resultP
);
1878 resultP
->X_op_symbol
= make_expr_symbol (&right
);
1879 resultP
->X_op
= op_left
;
1880 resultP
->X_add_number
= 0;
1881 resultP
->X_unsigned
= 1;
1884 if (retval
!= rightseg
)
1886 if (! SEG_NORMAL (retval
))
1888 if (retval
!= undefined_section
|| SEG_NORMAL (rightseg
))
1891 else if (SEG_NORMAL (rightseg
)
1893 && op_left
!= O_subtract
1896 as_bad (_("operation combines symbols in different segments"));
1900 } /* While next operator is >= this rank. */
1902 /* The PA port needs this information. */
1903 if (resultP
->X_add_symbol
)
1904 symbol_mark_used (resultP
->X_add_symbol
);
1906 return resultP
->X_op
== O_constant
? absolute_section
: retval
;
1909 /* This lives here because it belongs equally in expr.c & read.c.
1910 expr.c is just a branch office read.c anyway, and putting it
1911 here lessens the crowd at read.c.
1913 Assume input_line_pointer is at start of symbol name.
1914 Advance input_line_pointer past symbol name.
1915 Turn that character into a '\0', returning its former value.
1916 This allows a string compare (RMS wants symbol names to be strings)
1918 There will always be a char following symbol name, because all good
1919 lines end in end-of-line. */
1922 get_symbol_end (void)
1926 /* We accept \001 in a name in case this is being called with a
1927 constructed string. */
1928 if (is_name_beginner (c
= *input_line_pointer
++) || c
== '\001')
1930 while (is_part_of_name (c
= *input_line_pointer
++)
1933 if (is_name_ender (c
))
1934 c
= *input_line_pointer
++;
1936 *--input_line_pointer
= 0;
1941 get_single_number (void)
1945 return exp
.X_add_number
;