Allow line continuations within // comments.

This is what the standards specify.
This commit is contained in:
Stephen Heumann 2022-12-04 23:15:22 -06:00
parent facd1bf992
commit 8e1db102eb
3 changed files with 68 additions and 5 deletions

View File

@ -743,11 +743,16 @@ lc2 anop
lda chPtr+2
cmp eofPtr+2
jeq lc5
! else if (cch = '/') and (chPtr^ = return) then begin
! else if (cch = '/') then begin
lc2a lda cch
cmp #'/'
bne lc2b
! if charKinds[ord(ch)] = ch_eol then
! if (charKinds[ord(chPtr^)] = ch_eol)
! and (ptr(ord4(chPtr)-1)^ <> '\')
! and ((ptr(ord4(chPtr)-1)^ <> '/')
! or (ptr(ord4(chPtr)-2)^ <> '?')
! or (ptr(ord4(chPtr)-3)^ <> '?'))
! then
! done := true
! else
! chPtr := pointer(ord4(chPtr)+1);
@ -758,8 +763,19 @@ lc2a lda cch
tax
lda charKinds,X
cmp #ch_eol
jeq lc5
inc4 chPtr
bne lc2aa
dec4 p1
lda [p1]
and #$00FF
cmp #'\'
beq lc2aa
cmp #'/'
jne lc5
sub4 p1,#2
lda [p1]
cmp #'??'
jne lc5
lc2aa inc4 chPtr
bra lc2
! end {else if}
! else begin

View File

@ -636,3 +636,48 @@
.f
mnote "Missing closing '}'",16
mend
macro
&l sub4 &m1,&m2,&m3
lclb &yistwo
lclc &c
&l ~setm
aif c:&m3,.a
&c amid "&m2",1,1
aif "&c"<>"#",.a
&c amid "&m1",1,1
aif "&c"="{",.a
aif "&c"="[",.a
&c amid "&m2",2,l:&m2-1
aif &c>=65536,.a
sec
~lda &m1
~op sbc,&m2
~sta &m1
bcs ~&SYSCNT
~op.h dec,&m1
~&SYSCNT anop
ago .c
.a
aif c:&m3,.b
lclc &m3
&m3 setc &m1
.b
sec
~lda &m1
~op sbc,&m2
~sta &m3
~lda.h &m1
~op.h sbc,&m2
~sta.h &m3
.c
~restm
mend
macro
&l dec4 &a
&l ~setm
lda &a
bne ~&SYSCNT
dec 2+&a
~&SYSCNT dec &a
~restm
mend

View File

@ -1364,7 +1364,7 @@ WARNING: If you add a defaults.h file, be sure and delete all .sym files. .sym
// Comments
-----------
ORCA/C supports // comments. These comments begin with the characters //, and continue to the end of the physical line.
ORCA/C supports // comments. These comments begin with the characters //, and continue to the end of the line.
// comments are a flagrant violation of the ANSI C89 standard, although they are supported by the C99 and later standards. This is legal ANSI C89, and it should print 4:
@ -2017,6 +2017,8 @@ int foo(int[42]);
224. Comparisons against four-byte values in global structures, unions, or arrays might not work correctly when using the large memory model.
225. According to the C99 and later standards, a line continuation with \ should let a // comment continue to the next line. ORCA/C now behaves accordingly.
-- Bugs from C 2.1.0 that have been fixed -----------------------------------
1. In some situations, fread() reread the first 1K or so of the file.