}
else if (is_radix_char (ref_l, ref_s, &c))
{
+ /* Parse the radix, which is expressed in base 10. */
(sym++)[0] = c;
+ char *end;
+ int64_t radix = strtol (A68_PARSER (scan_buf), &end, 10);
+ gcc_assert (end != A68_PARSER (scan_buf) && *end == 'r');
+
+ /* Get the rest of the bits literal. Typographical display features
+ are allowed in the reference language between the digit symbols
+ composing the denotation. However, in SUPPER stropping this could
+ lead to confusing situations like:
+
+ while bitmask /= 16r0 do ~ od
+
+ Where the scanner would recognize a bits denotation 16r0d and then
+ the parser would complain about a missing 'do'. This is not a
+ problem in UPPER stropping since D is not a valid hexadecimal
+ digit.
+
+ To avoid confusing errors, in SUPPER stropping we do not allow
+ typographical display features in bits denotations when the radix
+ is 16. */
c = next_char (ref_l, ref_s, true);
- /* This is valid for both UPPER and SUPPER stropping. */
- while (ISDIGIT (c) || strchr ("abcdef", c) != NO_TEXT)
+ while (((radix == 2 && (c == '0' || c == '1'))
+ || (radix == 4 && (c >= '0' && c <= '3'))
+ || (radix == 8 && (c >= '0' && c <= '7'))
+ || (radix == 16 && (ISDIGIT (c) || strchr ("abcdef", c) != NO_TEXT))))
{
(sym++)[0] = c;
- c = next_char (ref_l, ref_s, true);
+ c = next_char (ref_l, ref_s,
+ OPTION_STROPPING (&A68_JOB) != SUPPER_STROPPING
+ || radix != 16);
}
*att = BITS_DENOTATION;
}
not alter the meaning of the program. However, when a space or a tab
appear in string or character denotations, they represent the
@code{space symbol} and the @code{tab symbol}
-respectively@footnote{The @code{tab symbol} is a GNU extension}.
+respectively@footnote{The @code{tab symbol} is a GNU extension}. The
+different stropping regimes, however, may impose specific restrictions
+on where typographical display features may or may not
+appear. @xref{Stropping regimes}.
@node Worthy characters
@section Worthy characters
the stropping. For example, both @code{goto found_zero} and
@code{goto foundzero} jump to the same label.
+In general, typographical display features are allowed between any
+symbol in the written program. In SUPPER stropping, however, it is
+not allowed to place spaces or tab characters between the constituent
+digits of bits denotations when the radix is 16. This is to avoid
+confusing situations like the following invalid program:
+
+@example
+@B{while} bitmask /= 16r0 @B{do} ~ @B{od}
+@end example
+
+@noindent
+Where the bits denotation would be interpreted as @code{16r0d} rather
+than @code{16r0}, leading to a syntax error. Note however that
+typographical display features are still allowed between the radix
+part and the digits, so @code{16r aabb} is valid also in SUPPER
+stropping.
+
The @code{recsel output records} procedure, encoded in SUPPER
stropping, looks like below.
--- /dev/null
+(bits a = 2r03; skip) { dg-error "" }
--- /dev/null
+(bits b = 8r09; skip) { dg-error "" }
--- /dev/null
+(bits c = 8rab, skip) { dg-error "" }
--- /dev/null
+(bits d = 16rfg; skip) { dg-error "" }
--- /dev/null
+{ Make sure that in supper stropping the bits
+ denotation is parsed as 16rab and not 16rabd }
+while bits foo; foo /= 16r ab do ~ od
--- /dev/null
+# { dg-options "-fstropping=upper" } #
+
+# Typographical display features are allowed between
+ digit symbols in hexadecimal bits denotations in UPPER
+ stropping. #
+WHILE BITS foo; foo /= 16r a b DO ~ OD
# { dg-options "-fstropping=upper" } #
# Environment enquiries for SIZETY BITs #
-BEGIN ASSERT (max bits /= 10r0);
+BEGIN ASSERT (max bits /= 2r0);
# XXX use LENG max bits below #
- ASSERT (long max bits >= LONG 10r0);
- ASSERT (long long max bits >= LONG LONG 10r0)
+ ASSERT (long max bits >= LONG 16r0);
+ ASSERT (long long max bits >= LONG LONG 4r0)
END