same name. This does also make it possible to introduce hard to find errors
in your code, so be careful!
+ <tag><tt>underline_in_numbers</tt><label id="underline_in_numbers"></tag>
+
+ Allow underlines within numeric constants. These may be used for grouping
+ the digits of numbers for easier reading.
+ Example:
+ <tscreen><verb>
+ .feature underline_in_numbers
+ .word %1100001110100101
+ .word %1100_0011_1010_0101 ; Identical but easier to read
+ </verb></tscreen>
+
</descrip>
It is also possible to specify features on the command line using the
/* */
/* */
/* */
-/* (C) 2000-2012, Ullrich von Bassewitz */
+/* (C) 2000-2013, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
"ubiquitous_idents",
"c_comments",
"force_range",
+ "underline_in_numbers",
};
case FEAT_UBIQUITOUS_IDENTS: UbiquitousIdents = 1; break;
case FEAT_C_COMMENTS: CComments = 1; break;
case FEAT_FORCE_RANGE: ForceRange = 1; break;
+ case FEAT_UNDERLINE_IN_NUMBERS: UnderlineInNumbers= 1; break;
default: /* Keep gcc silent */ break;
}
/* */
/* */
/* */
-/* (C) 2000-2012, Ullrich von Bassewitz */
+/* (C) 2000-2013, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
FEAT_UBIQUITOUS_IDENTS,
FEAT_C_COMMENTS,
FEAT_FORCE_RANGE,
+ FEAT_UNDERLINE_IN_NUMBERS,
/* Special value: Number of features available */
FEAT_COUNT
/* */
/* */
/* */
-/* (C) 1998-2012, Ullrich von Bassewitz */
+/* (C) 1998-2013, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
unsigned char OrgPerSeg = 0; /* Make .org local to current seg */
unsigned char CComments = 0; /* Allow C like comments */
unsigned char ForceRange = 0; /* Force values into expected range */
-
+unsigned char UnderlineInNumbers = 0; /* Allow underlines in numbers */
+
/* Misc stuff */
const char Copyright[] = "(C) Copyright 1998-2011 Ullrich von Bassewitz";
/* */
/* */
/* */
-/* (C) 1998-2012, Ullrich von Bassewitz */
+/* (C) 1998-2013, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
extern unsigned char OrgPerSeg; /* Make .org local to current seg */
extern unsigned char CComments; /* Allow C like comments */
extern unsigned char ForceRange; /* Force values into expected range */
+extern unsigned char UnderlineInNumbers; /* Allow underlines in numbers */
/* Misc stuff */
extern const char Copyright[]; /* Copyright string */
/* */
/* */
/* */
-/* (C) 1998-2012, Ullrich von Bassewitz */
+/* (C) 1998-2013, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
if (!IsXDigit (C)) {
if (DollarIsPC) {
CurTok.Tok = TOK_PC;
- return;
+ return;
} else {
Error ("Hexadecimal digit expected");
}
/* Read the number */
CurTok.IVal = 0;
- while (IsXDigit (C)) {
- if (CurTok.IVal & 0xF0000000) {
- Error ("Overflow in hexadecimal number");
- CurTok.IVal = 0;
- }
- CurTok.IVal = (CurTok.IVal << 4) + DigitVal (C);
- NextChar ();
- }
+ while (1) {
+ if (UnderlineInNumbers && C == '_') {
+ while (C == '_') {
+ NextChar ();
+ }
+ if (!IsXDigit (C)) {
+ Error ("Number may not end with underline");
+ }
+ }
+ if (IsXDigit (C)) {
+ if (CurTok.IVal & 0xF0000000) {
+ Error ("Overflow in hexadecimal number");
+ CurTok.IVal = 0;
+ }
+ CurTok.IVal = (CurTok.IVal << 4) + DigitVal (C);
+ NextChar ();
+ } else {
+ break;
+ }
+ }
/* This is an integer constant */
CurTok.Tok = TOK_INTCON;
/* Read the number */
CurTok.IVal = 0;
- while (IsBDigit (C)) {
- if (CurTok.IVal & 0x80000000) {
- Error ("Overflow in binary number");
- CurTok.IVal = 0;
- }
- CurTok.IVal = (CurTok.IVal << 1) + DigitVal (C);
- NextChar ();
- }
+ while (1) {
+ if (UnderlineInNumbers && C == '_') {
+ while (C == '_') {
+ NextChar ();
+ }
+ if (!IsBDigit (C)) {
+ Error ("Number may not end with underline");
+ }
+ }
+ if (IsBDigit (C)) {
+ if (CurTok.IVal & 0x80000000) {
+ Error ("Overflow in binary number");
+ CurTok.IVal = 0;
+ }
+ CurTok.IVal = (CurTok.IVal << 1) + DigitVal (C);
+ NextChar ();
+ } else {
+ break;
+ }
+ }
/* This is an integer constant */
CurTok.Tok = TOK_INTCON;
/* Read the number into Buf counting the digits */
Digits = 0;
- while (IsXDigit (C)) {
-
- /* Buf is big enough to allow any decimal and hex number to
- * overflow, so ignore excess digits here, they will be detected
- * when we convert the value.
- */
- if (Digits < sizeof (Buf)) {
- Buf[Digits++] = C;
+ while (1) {
+ if (UnderlineInNumbers && C == '_') {
+ while (C == '_') {
+ NextChar ();
+ }
+ if (!IsXDigit (C)) {
+ Error ("Number may not end with underline");
+ }
+ }
+ if (IsXDigit (C)) {
+ /* Buf is big enough to allow any decimal and hex number to
+ * overflow, so ignore excess digits here, they will be detected
+ * when we convert the value.
+ */
+ if (Digits < sizeof (Buf)) {
+ Buf[Digits++] = C;
+ }
+ NextChar ();
+ } else {
+ break;
}
-
- NextChar ();
}
/* Allow zilog/intel style hex numbers with a 'h' suffix */