binops not working yet
This commit is contained in:
parent
53ddd5803e
commit
251c25cbad
2 changed files with 17 additions and 21 deletions
|
@ -1 +1 @@
|
||||||
34
|
(3+5)*6-8
|
||||||
|
|
36
05/parse.b
36
05/parse.b
|
@ -90,12 +90,12 @@ function parse_expression
|
||||||
if c == SYMBOL_QUESTION goto parse_conditional
|
if c == SYMBOL_QUESTION goto parse_conditional
|
||||||
*1out = binop_symbol_to_expression_type(c)
|
*1out = binop_symbol_to_expression_type(c)
|
||||||
out += 8
|
out += 8
|
||||||
parse_expression(tokens, best, out) ; first operand
|
out = parse_expression(tokens, best, out) ; first operand
|
||||||
if c == SYMBOL_DOT goto parse_expr_member
|
if c == SYMBOL_DOT goto parse_expr_member
|
||||||
if c == SYMBOL_ARROW goto parse_expr_member
|
if c == SYMBOL_ARROW goto parse_expr_member
|
||||||
p = best + 16
|
p = best + 16
|
||||||
parse_expression(p, tokens_end, out) ; second operand
|
out = parse_expression(p, tokens_end, out) ; second operand
|
||||||
|
return out
|
||||||
;@TODO: casts
|
;@TODO: casts
|
||||||
|
|
||||||
|
|
||||||
|
@ -392,17 +392,18 @@ function int_value_to_type
|
||||||
if value [ 0x8000000000000000 goto return_type_long
|
if value [ 0x8000000000000000 goto return_type_long
|
||||||
goto return_type_unsigned_long
|
goto return_type_unsigned_long
|
||||||
|
|
||||||
function print_p_expression
|
; returns pointer to end of expression
|
||||||
argument p_expression
|
function print_expression
|
||||||
|
argument expression
|
||||||
local c
|
local c
|
||||||
local b
|
local b
|
||||||
local p
|
local p
|
||||||
local expression
|
|
||||||
expression = *8p_expression
|
|
||||||
p = expression + 4
|
p = expression + 4
|
||||||
|
if *4p == 0 goto print_expr_skip_type
|
||||||
putc(40)
|
putc(40)
|
||||||
print_type(*4p)
|
print_type(*4p)
|
||||||
putc(41)
|
putc(41)
|
||||||
|
:print_expr_skip_type
|
||||||
c = *1expression
|
c = *1expression
|
||||||
|
|
||||||
if c == EXPRESSION_CONSTANT_INT goto print_expr_int
|
if c == EXPRESSION_CONSTANT_INT goto print_expr_int
|
||||||
|
@ -415,34 +416,29 @@ function print_p_expression
|
||||||
expression += 8
|
expression += 8
|
||||||
putn(*8expression)
|
putn(*8expression)
|
||||||
expression += 8
|
expression += 8
|
||||||
goto print_p_expression_ret
|
return expression
|
||||||
:print_expr_float
|
:print_expr_float
|
||||||
expression += 8
|
expression += 8
|
||||||
putx64(*8expression)
|
putx64(*8expression)
|
||||||
expression += 8
|
expression += 8
|
||||||
goto print_p_expression_ret
|
return expression
|
||||||
:print_expr_str
|
:print_expr_str
|
||||||
expression += 8
|
expression += 8
|
||||||
putc('0)
|
putc('0)
|
||||||
putc('x)
|
putc('x)
|
||||||
putx32(*8expression)
|
putx32(*8expression)
|
||||||
expression += 8
|
expression += 8
|
||||||
goto print_p_expression_ret
|
return expression
|
||||||
:print_expr_binop
|
:print_expr_binop
|
||||||
|
putc(40)
|
||||||
expression += 8
|
expression += 8
|
||||||
print_p_expression(&expression) ; 1st operand
|
expression = print_expression(expression) ; 1st operand
|
||||||
b = get_keyword_str(b)
|
b = get_keyword_str(b)
|
||||||
puts(b)
|
puts(b)
|
||||||
print_expression(expression) ; 2nd operand
|
expression = print_expression(expression) ; 2nd operand
|
||||||
goto print_p_expression_ret
|
putc(41)
|
||||||
:print_p_expression_ret
|
return expression
|
||||||
*8p_expression = expression
|
|
||||||
return
|
|
||||||
|
|
||||||
function print_expression
|
|
||||||
argument expression
|
|
||||||
print_p_expression(&expression)
|
|
||||||
return
|
|
||||||
|
|
||||||
; NOTE: to make things easier, the format which this outputs isn't the same as C's, specifically we have
|
; NOTE: to make things easier, the format which this outputs isn't the same as C's, specifically we have
|
||||||
; *int for pointer to int and [5]int for array of 5 ints
|
; *int for pointer to int and [5]int for array of 5 ints
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue