Skip to content

Commit 91e58fe

Browse files
committed
In the macro definition (#define/#macro), "##_" is used to indicate the dynamic addition of a line continuation character ("_"), Causes the compiler to delay parsing the line continuation.This allows multiple lines of code in the input file to be combined into a single statement. For example:
Type _MAP_ENTRY id As integer pA As integer End Type #macro BEGIN_ENTRIESMAP() Function _GetMapEntries() As _MAP_ENTRY Ptr Static As _MAP_ENTRY _entries(0 To ...) = { ##_ #endmacro #macro END_ENTRIESMAP() (0, 0)} Return @_entries(0) End Function #endmacro #define _INTERFACE_ENTRY(x, y) (x, y), ##_ BEGIN_ENTRIESMAP() _INTERFACE_ENTRY(1, 2) _INTERFACE_ENTRY(3, 4) _INTERFACE_ENTRY(5, 6) END_ENTRIESMAP() /' Compiler parsing results: Function _GetMapEntries() As _MAP_ENTRY Ptr Static As _MAP_ENTRY _entries(0 To ...) = { _ (1, 2), _ (3, 4), _ (5, 6), _ (0, 0)} Return @_entries(0) End Function '/
1 parent ea8c233 commit 91e58fe

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/compiler/pp-define.bas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ private function hReadMacroText _
957957
'' '##'?
958958
case CHAR_SHARP
959959
lexSkipToken( LEX_FLAGS )
960-
lexSkipToken( LEX_FLAGS )
960+
lexSkipToken( LEX_FLAGS or LEXCHECK_NOLINECONT)
961961
continue do
962962

963963
'' '#' macro?

src/compiler/pp.bas

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,14 @@ function ppReadLiteral _
546546
case CHAR_SHARP
547547
select case lexGetLookAhead( 1, (LEX_FLAGS or LEXCHECK_KWDNAMESPC) and _
548548
(not LEXCHECK_NOWHITESPC) )
549+
'' '##'?
550+
case CHAR_SHARP
551+
lexSkipToken( LEX_FLAGS )
552+
lexSkipToken( LEX_FLAGS or LEXCHECK_NOLINECONT)
553+
if *lexGetText( ) <> "_" then '' Is only '##_'?
554+
DZstrConcatAssign( text, "##" )
555+
end if
556+
549557
'' '#' macro?
550558
case FB_TK_PP_MACRO
551559
if( ismultiline ) then
@@ -689,6 +697,14 @@ function ppReadLiteralW _
689697
case CHAR_SHARP
690698
select case lexGetLookAhead( 1, (LEX_FLAGS or LEXCHECK_KWDNAMESPC) and _
691699
(not LEXCHECK_NOWHITESPC) )
700+
'' '##'?
701+
case CHAR_SHARP
702+
lexSkipToken( LEX_FLAGS )
703+
lexSkipToken( LEX_FLAGS or LEXCHECK_NOLINECONT)
704+
if *lexGetText( ) <> "_" then '' Is only '##_'?
705+
DWstrConcatAssignA( text, "##" )
706+
end if
707+
692708
'' '#' macro?
693709
case FB_TK_PP_MACRO
694710
if( ismultiline ) then

0 commit comments

Comments
 (0)