|
42 | 42 | <data>\" yyput('"'); BEGIN(datastring);
|
43 | 43 | <datastring>\" yyput('"'); BEGIN(data);
|
44 | 44 |
|
45 |
| -//xxxxx need to handle literal numeric expressions here. Not just ASCII. |
46 |
| -// 0 = 0x11 = 17 |
47 |
| -// 1 = 0x12 = 18 |
48 |
| -// -1 = 0xF4 0x12 = -18 |
| 45 | + //xxxxx need to handle literal numeric expressions here. Not just ASCII. |
| 46 | +-?[0-9.]+([%#!]|[DE][-+]?[0-9]+ if ( yytext[0] == '-') |
| 47 | + yyput(0xF1); |
| 48 | + yyput(atoi(yytext) + 0x11); |
| 49 | + BEGIN(INITIAL) |
49 | 50 |
|
50 | 51 | /* Newline ends <string>, <remark>, <data>, and <datastring> conditions. */
|
51 | 52 | <*>\r?\n yyput('\0'); BEGIN(INITIAL);
|
@@ -213,3 +214,71 @@ LOF yyput(0xff); yyput(0xa9);
|
213 | 214 |
|
214 | 215 | /* The main() routine, yyput(), fixup_ptrs() */
|
215 | 216 | #include "m100-tokenize-main.c"
|
| 217 | + |
| 218 | +/* Literal number handling routine */ |
| 219 | +int tokenize_number(char *s) { |
| 220 | + int len = strlen(s); |
| 221 | + if (len == 0) return 1; |
| 222 | + int sign = (s[0] == '-'); |
| 223 | + if (sign) s++, len--; |
| 224 | + |
| 225 | + |
| 226 | + |
| 227 | + return 0; |
| 228 | + } |
| 229 | + |
| 230 | + // xxx this is not finished yet. xxxx |
| 231 | + // N82 integers can only range from -32768 to 32767 |
| 232 | + /* Single digit integers are efficiently encoded as 0 = 0x11 to 9 = 0x1A. */ |
| 233 | + // 0 = 0x11 |
| 234 | + // 1 = 0x12 |
| 235 | + // 9 = 0x1A |
| 236 | + |
| 237 | + /* Minus sign is encoded as 0xF4 */ |
| 238 | + // -1 = 0xF4 0x12 |
| 239 | + |
| 240 | + /* Numbers from 10 to 255 are encoded with an ID of 0F */ |
| 241 | + // 10 = 0x0F0A |
| 242 | + // 255 = 0x0FFF |
| 243 | + |
| 244 | + /* Numbers 256 to 32767 are encoded with an ID of 1C */ |
| 245 | + // 256 1C 00 01 |
| 246 | + // 257 1C 01 01 |
| 247 | + // 512 1C 00 02 |
| 248 | + // 32767 1C FF 7F |
| 249 | + |
| 250 | + /* Single precision floating point. 1D B0 B1 B2 EX */ |
| 251 | + // 32768 1D 00 00 00 90 |
| 252 | + // 32769 1D 00 01 00 90 |
| 253 | + // 65534 1D 00 FE 7F 90 |
| 254 | + // 65535 1D 00 FF 7F 90 |
| 255 | + // 131071 1D 80 FF 7F 91 |
| 256 | + // 131072 1D 00 00 00 92 |
| 257 | + |
| 258 | + /* Double-precision floating point. ID: 1F */ |
| 259 | + // 1F 00 00 00 00 00 00 00 7E .125# 2^-3 |
| 260 | + // 1F 00 00 00 00 00 00 00 7F .25# 2^-2 |
| 261 | + // 1F 00 00 00 00 00 00 00 80 .5# 2^-1 |
| 262 | + // 1F 00 00 00 00 00 00 20 80 .625# 2^-1 + 2^-3 |
| 263 | + // 1F 00 00 00 00 00 00 40 80 .75# 2^-1 + 2^-2 |
| 264 | + // 1F 00 00 00 00 00 00 60 80 .875# 2^-1 + 2^-2 + 2^-3 |
| 265 | + // 1F 80 00 00 00 00 00 00 FF 8.507059173023492D+37 -> (same) |
| 266 | + |
| 267 | + /*******************************************************************/ |
| 268 | + /* Microsoft Binary Format (MBF) for 64-bit floating point numbers */ |
| 269 | + /* Tokenized as nine bytes: */ |
| 270 | + /* ID B0 B1 B2 B3 B4 B5 B6 EX */ |
| 271 | + /* */ |
| 272 | + /* ID is 1F for double-precision floating point */ |
| 273 | + /* Value is (-1)^Signbit x Mantissa ^ Exponent */ |
| 274 | + /* 8-bit Exponent is EX-128 */ |
| 275 | + /* Signbit is high bit of B6. (B6 is left with only 7 bits) */ |
| 276 | + /* 55-bit Mantissa is B6 B5 B4 B3 B2 B1 B0 */ |
| 277 | + /* */ |
| 278 | + /* There is an implicit "1" bit at the start of the mantissa. */ |
| 279 | + /* Note that the implicit 1 is AFTER the decimal point. */ |
| 280 | + /* */ |
| 281 | + /*******************************************************************/ |
| 282 | + |
| 283 | + |
| 284 | + |
0 commit comments