diff options
Diffstat (limited to '05')
-rw-r--r-- | 05/main.c | 1 | ||||
-rw-r--r-- | 05/tokenize.b | 17 | ||||
-rw-r--r-- | 05/util.b | 22 |
3 files changed, 40 insertions, 0 deletions
@@ -2,3 +2,4 @@ char * = "How are you"" d""o""i""ng today?\n"; hi _TEST _ING _1 +4.2 diff --git a/05/tokenize.b b/05/tokenize.b index e6bd48e..5f87c71 100644 --- a/05/tokenize.b +++ b/05/tokenize.b @@ -310,6 +310,13 @@ function tokenize data = significand exponent += 1023 ; float format data |= exponent < 52 + + *1out = TOKEN_CONSTANT_FLOAT + out += 1 + ; suffix + *1out = read_number_suffix(file, line_number, &in) + out += 1 + goto token_output :float_no_integer byte 0xcc :float_zero @@ -500,6 +507,7 @@ function print_tokens if *1p > 20 goto print_token_keyword if *1p == TOKEN_CONSTANT_INT goto print_token_int if *1p == TOKEN_CONSTANT_CHAR goto print_token_char + if *1p == TOKEN_CONSTANT_FLOAT goto print_token_float if *1p == TOKEN_STRING_LITERAL goto print_token_string_literal if *1p == TOKEN_IDENTIFIER goto print_token_identifier fputs(2, .str_print_bad_token) @@ -521,6 +529,12 @@ function print_tokens s = p + 8 puts(*8s) goto print_token_data + :print_token_float + p += 8 + puts(.str_constant_float) + putx(*8p) + p += 8 + goto print_tokens_loop :print_token_info p += 1 putc('~) @@ -545,6 +559,9 @@ function print_tokens :str_constant_int string integer byte 0 + :str_constant_float + string float + byte 0 :str_constant_char string character byte 0 @@ -308,6 +308,28 @@ function fputn_signed fputn(fd, n) return +function fputx + argument fd + argument n + local m + local x + m = 60 + :fputx_loop + x = n > m + x &= 0xf + x += .hex_digits + fputc(fd, *1x) + m -= 4 + if m >= 0 goto fputx_loop + return +:hex_digits + string 0123456789abcdef + +function putx + argument n + fputx(1, n) + return + function putn argument n fputn(1, n) |