Skip to content

Commit 5e02be7

Browse files
committed
Merge remote-tracking branch 'jayrm/bugfix-993' into fbc-1.10
2 parents 004f0cd + 20e3e61 commit 5e02be7

File tree

9 files changed

+227
-5
lines changed

9 files changed

+227
-5
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Version 1.10.1
2222
- emscripten: non-graphical programs will now run under node.js. Use -x output.js to produce a .js rather than an .html
2323
- rtlib: emscripten: CURDIR and EXEPATH always returned ""
2424
- emscripten/fbc: -sASYNCIFY wasn't passed to emcc at link-time as needed by recent Emscripten
25+
- sf.net #993: ignore (parse) single line comments for macros invoked with optional parentheses instead of passing as an argument to macro
2526

2627

2728
Version 1.10.0

src/compiler/fbc.bas

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,8 @@ private function hLinkFiles( ) as integer
12641264
exit function
12651265
end if
12661266

1267-
put #f, 533, clng( fbGetOption( FB_COMPOPT_STACKSIZE ) )
1267+
dim value as long = clng( fbGetOption( FB_COMPOPT_STACKSIZE ) )
1268+
put #f, 533, value
12681269

12691270
close #f
12701271

src/compiler/pp-define.bas

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,19 +207,51 @@ private function hLoadMacro _
207207
case FB_TK_STMTSEP
208208
if( not hasParens ) then
209209
readdchar = CHAR_COLON
210-
prntcnt = 0
210+
if( prntcnt > 0 ) then
211+
prntcnt -= 1
212+
end if
211213
exit do
212214
end if
213215

214216
case FB_TK_EOL, FB_TK_EOF
215217
if( hasParens ) then
216218
hReportMacroError( s, FB_ERRMSG_EXPECTEDRPRNT )
219+
prntcnt = 0
217220
else
221+
if( prntcnt > 0 ) then
222+
prntcnt -= 1
223+
end if
218224
readdchar = iif(t.id = FB_TK_EOF, 0, CHAR_LF)
219225
end if
220-
prntcnt = 0
221226
exit do
222227

228+
case FB_TK_COMMENT
229+
if( hasParens ) then
230+
if( argtb ) then
231+
if( argtb->count = 0 ) then
232+
argtb->count = 1
233+
end if
234+
end if
235+
else
236+
do
237+
lexSkipToken( LEX_FLAGS or LEXCHECK_NOMULTILINECOMMENT )
238+
239+
select case lexGetToken( LEX_FLAGS )
240+
case FB_TK_EOL, FB_TK_EOF
241+
exit do
242+
end select
243+
loop
244+
245+
lexSkipToken( LEX_FLAGS or LEXCHECK_NOMULTILINECOMMENT )
246+
247+
readdchar = iif(t.id = FB_TK_EOF, 0, CHAR_LF)
248+
if( prntcnt > 0 ) then
249+
prntcnt -= 1
250+
end if
251+
252+
exit do
253+
end if
254+
223255
case CHAR_SPACE, CHAR_TAB
224256

225257
case else
@@ -644,19 +676,51 @@ private function hLoadMacroW _
644676
case FB_TK_STMTSEP
645677
if( not hasParens ) then
646678
readdchar = CHAR_COLON
647-
prntcnt = 0
679+
if( prntcnt > 0 ) then
680+
prntcnt -= 1
681+
end if
648682
exit do
649683
end if
650684

651685
case FB_TK_EOL, FB_TK_EOF
652686
if( hasParens ) then
653687
hReportMacroError( s, FB_ERRMSG_EXPECTEDRPRNT )
688+
prntcnt = 0
654689
else
690+
if( prntcnt > 0 ) then
691+
prntcnt -= 1
692+
end if
655693
readdchar = iif(t.id = FB_TK_EOF, 0, CHAR_LF)
656694
end if
657-
prntcnt = 0
658695
exit do
659696

697+
case FB_TK_COMMENT
698+
if( hasParens ) then
699+
if( argtb ) then
700+
if( argtb->count = 0 ) then
701+
argtb->count = 1
702+
end if
703+
end if
704+
else
705+
do
706+
lexSkipToken( LEX_FLAGS or LEXCHECK_NOMULTILINECOMMENT )
707+
708+
select case lexGetToken( LEX_FLAGS )
709+
case FB_TK_EOL, FB_TK_EOF
710+
exit do
711+
end select
712+
loop
713+
714+
lexSkipToken( LEX_FLAGS or LEXCHECK_NOMULTILINECOMMENT)
715+
716+
readdchar = iif(t.id = FB_TK_EOF, 0, CHAR_LF)
717+
if( prntcnt > 0 ) then
718+
prntcnt -= 1
719+
end if
720+
721+
exit do
722+
end if
723+
660724
case CHAR_SPACE, CHAR_TAB
661725

662726
case else

tests/syntax/optional-parens-2.bas

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'' check that single line comments are allowed (parsed and ignored) after
2+
'' macros exapanding with optional parentheses
3+
4+
#macro foo?(_a, _c...)
5+
#if #_c=""
6+
#print " A is " #_a
7+
#print " C is " #_c
8+
#else
9+
#print " A is " #_a
10+
#print " C is " #_c
11+
#endif
12+
#endmacro
13+
14+
#print "-----"
15+
#print "foo 10"
16+
foo 10
17+
18+
#print "-----"
19+
#print "10 ', 100"
20+
foo 10 ', 100
21+
22+
#print "-----"
23+
#print "foo 10 ', "
24+
foo 10 ',
25+
26+
#print "-----"
27+
#print "foo 10 ', asdasd"
28+
foo 10 ', asdasd
29+
30+
#print "-----"
31+
#print "foo 10 ', foo"
32+
foo 10 ', foo
33+
34+
#print "-----"
35+
#print "foo 10 'foo"
36+
foo 10 'foo
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
-----
2+
foo 10
3+
A is $"10"
4+
C is ""
5+
-----
6+
10 ', 100
7+
A is $"10"
8+
C is ""
9+
-----
10+
foo 10 ',
11+
A is $"10"
12+
C is ""
13+
-----
14+
foo 10 ', asdasd
15+
A is $"10"
16+
C is ""
17+
-----
18+
foo 10 ', foo
19+
A is $"10"
20+
C is ""
21+
-----
22+
foo 10 'foo
23+
A is $"10"
24+
C is ""
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
-----
2+
foo 10
3+
A is $"10"
4+
C is ""
5+
-----
6+
10 ', 100
7+
A is $"10"
8+
C is ""
9+
-----
10+
foo 10 ',
11+
A is $"10"
12+
C is ""
13+
-----
14+
foo 10 ', asdasd
15+
A is $"10"
16+
C is ""
17+
-----
18+
foo 10 ', foo
19+
A is $"10"
20+
C is ""
21+
-----
22+
foo 10 'foo
23+
A is $"10"
24+
C is ""
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
-----
2+
foo 10
3+
A is $"10"
4+
C is ""
5+
-----
6+
10 ', 100
7+
A is $"10"
8+
C is ""
9+
-----
10+
foo 10 ',
11+
A is $"10"
12+
C is ""
13+
-----
14+
foo 10 ', asdasd
15+
A is $"10"
16+
C is ""
17+
-----
18+
foo 10 ', foo
19+
A is $"10"
20+
C is ""
21+
-----
22+
foo 10 'foo
23+
A is $"10"
24+
C is ""
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
-----
2+
foo 10
3+
A is $"10"
4+
C is ""
5+
-----
6+
10 ', 100
7+
A is $"10"
8+
C is ""
9+
-----
10+
foo 10 ',
11+
A is $"10"
12+
C is ""
13+
-----
14+
foo 10 ', asdasd
15+
A is $"10"
16+
C is ""
17+
-----
18+
foo 10 ', foo
19+
A is $"10"
20+
C is ""
21+
-----
22+
foo 10 'foo
23+
A is $"10"
24+
C is ""
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
-----
2+
foo 10
3+
A is $"10"
4+
C is ""
5+
-----
6+
10 ', 100
7+
A is $"10"
8+
C is ""
9+
-----
10+
foo 10 ',
11+
A is $"10"
12+
C is ""
13+
-----
14+
foo 10 ', asdasd
15+
A is $"10"
16+
C is ""
17+
-----
18+
foo 10 ', foo
19+
A is $"10"
20+
C is ""
21+
-----
22+
foo 10 'foo
23+
A is $"10"
24+
C is ""

0 commit comments

Comments
 (0)