more float stuff
This commit is contained in:
parent
06ebaf043b
commit
0779a0fab5
3 changed files with 40 additions and 0 deletions
|
@ -2,3 +2,4 @@
|
||||||
char * = "How are you"" d""o""i""ng today?\n";
|
char * = "How are you"" d""o""i""ng today?\n";
|
||||||
hi
|
hi
|
||||||
_TEST _ING _1
|
_TEST _ING _1
|
||||||
|
4.2
|
||||||
|
|
|
@ -310,6 +310,13 @@ function tokenize
|
||||||
data = significand
|
data = significand
|
||||||
exponent += 1023 ; float format
|
exponent += 1023 ; float format
|
||||||
data |= exponent < 52
|
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
|
:float_no_integer
|
||||||
byte 0xcc
|
byte 0xcc
|
||||||
:float_zero
|
:float_zero
|
||||||
|
@ -500,6 +507,7 @@ function print_tokens
|
||||||
if *1p > 20 goto print_token_keyword
|
if *1p > 20 goto print_token_keyword
|
||||||
if *1p == TOKEN_CONSTANT_INT goto print_token_int
|
if *1p == TOKEN_CONSTANT_INT goto print_token_int
|
||||||
if *1p == TOKEN_CONSTANT_CHAR goto print_token_char
|
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_STRING_LITERAL goto print_token_string_literal
|
||||||
if *1p == TOKEN_IDENTIFIER goto print_token_identifier
|
if *1p == TOKEN_IDENTIFIER goto print_token_identifier
|
||||||
fputs(2, .str_print_bad_token)
|
fputs(2, .str_print_bad_token)
|
||||||
|
@ -521,6 +529,12 @@ function print_tokens
|
||||||
s = p + 8
|
s = p + 8
|
||||||
puts(*8s)
|
puts(*8s)
|
||||||
goto print_token_data
|
goto print_token_data
|
||||||
|
:print_token_float
|
||||||
|
p += 8
|
||||||
|
puts(.str_constant_float)
|
||||||
|
putx(*8p)
|
||||||
|
p += 8
|
||||||
|
goto print_tokens_loop
|
||||||
:print_token_info
|
:print_token_info
|
||||||
p += 1
|
p += 1
|
||||||
putc('~)
|
putc('~)
|
||||||
|
@ -545,6 +559,9 @@ function print_tokens
|
||||||
:str_constant_int
|
:str_constant_int
|
||||||
string integer
|
string integer
|
||||||
byte 0
|
byte 0
|
||||||
|
:str_constant_float
|
||||||
|
string float
|
||||||
|
byte 0
|
||||||
:str_constant_char
|
:str_constant_char
|
||||||
string character
|
string character
|
||||||
byte 0
|
byte 0
|
||||||
|
|
22
05/util.b
22
05/util.b
|
@ -308,6 +308,28 @@ function fputn_signed
|
||||||
fputn(fd, n)
|
fputn(fd, n)
|
||||||
return
|
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
|
function putn
|
||||||
argument n
|
argument n
|
||||||
fputn(1, n)
|
fputn(1, n)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue