fix multi-line fmacro invocations
This commit is contained in:
parent
e21c1c39a7
commit
16bad1636d
2 changed files with 71 additions and 1 deletions
|
@ -1,2 +1,11 @@
|
||||||
|
#define funciton( h, \
|
||||||
|
i, j ) h##ello * 2 * i##ello * j##ello
|
||||||
|
int hello = 7;
|
||||||
int main() {
|
int main() {
|
||||||
|
int x = funciton(
|
||||||
|
h,
|
||||||
|
h,
|
||||||
|
h
|
||||||
|
);
|
||||||
|
int y = funciton(h,h,h);
|
||||||
}
|
}
|
||||||
|
|
|
@ -435,6 +435,25 @@ function pptoken_skip
|
||||||
*8p_in = in + 1
|
*8p_in = in + 1
|
||||||
return
|
return
|
||||||
|
|
||||||
|
; reverse one pptoken
|
||||||
|
; don't call this on the first pptoken in the file
|
||||||
|
function pptoken_reverse
|
||||||
|
argument p_in
|
||||||
|
argument p_line_number
|
||||||
|
local in
|
||||||
|
in = *8p_in
|
||||||
|
in -= 2
|
||||||
|
:pptoken_rev_loop
|
||||||
|
if *1in == 0 goto pptoken_rev_loop_end
|
||||||
|
in -= 1
|
||||||
|
goto pptoken_rev_loop
|
||||||
|
:pptoken_rev_loop_end
|
||||||
|
in += 1
|
||||||
|
*8p_in = in
|
||||||
|
if *1in != 10 goto return_0
|
||||||
|
*8p_line_number -= 1
|
||||||
|
return
|
||||||
|
|
||||||
; skip any space tokens here
|
; skip any space tokens here
|
||||||
function pptoken_skip_spaces
|
function pptoken_skip_spaces
|
||||||
argument p_in
|
argument p_in
|
||||||
|
@ -448,6 +467,42 @@ function pptoken_skip_spaces
|
||||||
*8p_in = in
|
*8p_in = in
|
||||||
return
|
return
|
||||||
|
|
||||||
|
; skip any whitespace tokens here
|
||||||
|
function pptoken_skip_whitespace
|
||||||
|
argument p_in
|
||||||
|
argument p_line_number
|
||||||
|
local in
|
||||||
|
in = *8p_in
|
||||||
|
:skip_whitespace_loop
|
||||||
|
if *1in == 10 goto skip_whitespace_incline
|
||||||
|
if *1in != 32 goto skip_whitespace_loop_end
|
||||||
|
pptoken_skip(&in)
|
||||||
|
goto skip_whitespace_loop
|
||||||
|
:skip_whitespace_incline
|
||||||
|
*8p_line_number += 1
|
||||||
|
pptoken_skip(&in)
|
||||||
|
goto skip_whitespace_loop
|
||||||
|
:skip_whitespace_loop_end
|
||||||
|
*8p_in = in
|
||||||
|
return
|
||||||
|
|
||||||
|
; go backwards before any spaces and newlines here
|
||||||
|
; don't do this for spaces at the start of the file
|
||||||
|
function pptoken_reverse_whitespace
|
||||||
|
argument p_in
|
||||||
|
argument p_line_number
|
||||||
|
local in
|
||||||
|
in = *8p_in
|
||||||
|
:reverse_whitespace_loop
|
||||||
|
if *1in == 10 goto reverse_whitespace
|
||||||
|
if *1in != 32 goto reverse_whitespace_loop_end
|
||||||
|
:reverse_whitespace
|
||||||
|
pptoken_reverse(&in, p_line_number)
|
||||||
|
goto reverse_whitespace_loop
|
||||||
|
:reverse_whitespace_loop_end
|
||||||
|
*8p_in = in
|
||||||
|
return
|
||||||
|
|
||||||
function pptoken_skip_to_newline
|
function pptoken_skip_to_newline
|
||||||
argument p_in
|
argument p_in
|
||||||
local in
|
local in
|
||||||
|
@ -1233,6 +1288,7 @@ function macro_replacement
|
||||||
pptoken_skip(&in) ; skip macro name
|
pptoken_skip(&in) ; skip macro name
|
||||||
pptoken_skip_spaces(&in)
|
pptoken_skip_spaces(&in)
|
||||||
pptoken_skip(&in) ; skip opening bracket
|
pptoken_skip(&in) ; skip opening bracket
|
||||||
|
pptoken_skip_whitespace(&in, p_line_number)
|
||||||
|
|
||||||
local arguments
|
local arguments
|
||||||
local fmacro_out
|
local fmacro_out
|
||||||
|
@ -1245,17 +1301,19 @@ function macro_replacement
|
||||||
p = arguments
|
p = arguments
|
||||||
if *1in == ') goto fmacro_no_args
|
if *1in == ') goto fmacro_no_args
|
||||||
:fmacro_arg_loop
|
:fmacro_arg_loop
|
||||||
|
pptoken_skip_whitespace(&in, p_line_number)
|
||||||
b = fmacro_arg_end(filename, p_line_number, in)
|
b = fmacro_arg_end(filename, p_line_number, in)
|
||||||
b -= in
|
b -= in
|
||||||
|
; putnln(b)
|
||||||
memcpy(p, in, b) ; copy the argument to its proper place
|
memcpy(p, in, b) ; copy the argument to its proper place
|
||||||
p += b
|
p += b
|
||||||
in += b ; skip argument
|
in += b ; skip argument
|
||||||
|
pptoken_skip_whitespace(&in, p_line_number)
|
||||||
c = *1in
|
c = *1in
|
||||||
in += 2 ; skip , or )
|
in += 2 ; skip , or )
|
||||||
*1p = 255
|
*1p = 255
|
||||||
p += 1
|
p += 1
|
||||||
if c == ') goto fmacro_arg_loop_end
|
if c == ') goto fmacro_arg_loop_end
|
||||||
pptoken_skip_spaces(&in)
|
|
||||||
goto fmacro_arg_loop
|
goto fmacro_arg_loop
|
||||||
:fmacro_no_args
|
:fmacro_no_args
|
||||||
in += 2 ; skip )
|
in += 2 ; skip )
|
||||||
|
@ -1474,6 +1532,9 @@ function fmacro_arg_end
|
||||||
pptoken_skip(&in)
|
pptoken_skip(&in)
|
||||||
goto fmacro_arg_end_loop
|
goto fmacro_arg_end_loop
|
||||||
:fmacro_arg_end_loop_end
|
:fmacro_arg_end_loop_end
|
||||||
|
pptoken_reverse(&in, p_line_number)
|
||||||
|
pptoken_reverse_whitespace(&in, p_line_number)
|
||||||
|
pptoken_skip(&in)
|
||||||
|
|
||||||
return in
|
return in
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue