@@ -317,6 +317,57 @@ private function hMacro_getArgW( byval argtb as LEXPP_ARGTB ptr, byval num as in
317317
318318end function
319319
320+ #define hIsTokenEndOfStream() ((lexGetToken() = FB_TK_EOL) orelse (lexGetToken() = FB_TK_EOF))
321+
322+ private sub hArgAppendLFCHAR( )
323+ '' Add an end of expression marker so that the parser
324+ '' doesn't read past the end of the expression text
325+ '' by appending an LFCHAR to the end of the expression
326+ '' It would be better to use the explicit EOF character,
327+ '' but we can't appened an extra NUL character to a zstring
328+
329+ '' ascii
330+ if ( env.inf.format = FBFILE_FORMAT_ASCII ) then
331+ DZstrConcatAssign( lex.ctx->deftext, LFCHAR )
332+ lex.ctx->defptr = lex.ctx->deftext.data
333+ lex.ctx->deflen += len( LFCHAR )
334+ '' unicode
335+ else
336+ DWstrConcatAssignA( lex.ctx->deftextw, LFCHAR )
337+ lex.ctx->defptrw = lex.ctx->deftextw.data
338+ lex.ctx->deflen += len( LFCHAR )
339+ end if
340+ end sub
341+
342+ private sub hArgInsertArgA( byval arg as zstring ptr )
343+ '' ascii
344+ if ( env.inf.format = FBFILE_FORMAT_ASCII ) then
345+ DZstrAssign( lex.ctx->deftext, *arg )
346+ lex.ctx->defptr = lex.ctx->deftext.data
347+ lex.ctx->deflen += len( *arg )
348+ '' unicode
349+ else
350+ DWstrAssignA( lex.ctx->deftextw, *arg )
351+ lex.ctx->defptrw = lex.ctx->deftextw.data
352+ lex.ctx->deflen += len( *arg )
353+ end if
354+ end sub
355+
356+ private sub hArgInsertArgW( byval arg as wstring ptr )
357+ '' ascii
358+ if ( env.inf.format = FBFILE_FORMAT_ASCII ) then
359+ DZstrAssignW( lex.ctx->deftext, *arg )
360+ lex.ctx->defptr = lex.ctx->deftext.data
361+ lex.ctx->deflen += len( *arg )
362+ '' unicode
363+ else
364+ DWstrAssign( lex.ctx->deftextw, *arg )
365+ lex.ctx->defptrw = lex.ctx->deftextw.data
366+ lex.ctx->deflen += len( *arg )
367+ end if
368+ end sub
369+
370+
320371private function hMacro_EvalZ( byval arg as zstring ptr, byval errnum as integer ptr ) as string
321372
322373 '' the expression should have already been handled in hLoadMacro|hLoadMacroW
@@ -343,19 +394,8 @@ private function hMacro_EvalZ( byval arg as zstring ptr, byval errnum as integer
343394 '' prevent cExpression from writing to .pp.bas file
344395 lex.ctx->reclevel += 1
345396
346- DZstrAssign( lex.ctx->deftext, *arg )
347- lex.ctx->defptr = lex.ctx->deftext.data
348- lex.ctx->deflen += len( *arg )
349-
350- '' Add an end of expression marker so that the parser
351- '' doesn't read past the end of the expression text
352- '' by appending an LFCHAR to the end of the expression
353- '' It would be better to use the explicit EOF character,
354- '' but we can't appened an extra NUL character to a zstring
355-
356- DZstrConcatAssign( lex.ctx->deftext, LFCHAR )
357- lex.ctx->defptr = lex.ctx->deftext.data
358- lex.ctx->deflen += len( LFCHAR )
397+ hArgInsertArgA( arg )
398+ hArgAppendLFCHAR()
359399
360400 dim expr as ASTNODE ptr = cExpression( )
361401 var errmsg = FB_ERRMSG_OK
@@ -367,13 +407,13 @@ private function hMacro_EvalZ( byval arg as zstring ptr, byval errnum as integer
367407 DZStrAssign( res, astConstFlushToStr( expr ) )
368408
369409 '' any tokens still in the buffer? cExpression() should have used them all
370- if ( lexGetToken( ) <> FB_TK_EOL ) then
410+ if ( not hIsTokenEndOfStream() ) then
371411 errmsg = FB_ERRMSG_SYNTAXERROR
372412 end if
373413 elseif ( astIsConstant( expr ) ) then
374414 DZStrAssign( res, symbGetConstStrAsStr( expr->sym ) )
375415 '' any tokens still in the buffer? cExpression() should have used them all
376- if ( lexGetToken( ) <> FB_TK_EOL ) then
416+ if ( not hIsTokenEndOfStream() ) then
377417 errmsg = FB_ERRMSG_SYNTAXERROR
378418 end if
379419 astDelTree( expr )
@@ -430,19 +470,8 @@ private function hMacro_EvalW( byval arg as wstring ptr, byval errnum as integer
430470 '' prevent cExpression from writing to .pp.bas file
431471 lex.ctx->reclevel += 1
432472
433- DWstrAssign( lex.ctx->deftextw, *arg )
434- lex.ctx->defptrw = lex.ctx->deftextw.data
435- lex.ctx->deflen += len( *arg )
436-
437- '' Add an end of expression marker so that the parser
438- '' doesn't read past the end of the expression text
439- '' by appending an LFCHAR to the end of the expression
440- '' It would be better to use the explicit EOF character,
441- '' but we can't appened an extra NUL character to a zstring
442-
443- DWstrConcatAssign( lex.ctx->deftextw, LFCHAR )
444- lex.ctx->defptrw = lex.ctx->deftextw.data
445- lex.ctx->deflen += len( LFCHAR )
473+ hArgInsertArgW( arg )
474+ hArgAppendLFCHAR()
446475
447476 dim expr as ASTNODE ptr = cExpression( )
448477 var errmsg = FB_ERRMSG_OK
@@ -454,13 +483,13 @@ private function hMacro_EvalW( byval arg as wstring ptr, byval errnum as integer
454483 DWStrAssign( res, astConstFlushToWstr( expr ) )
455484
456485 '' any tokens still in the buffer? cExpression() should have used them all
457- if ( lexGetToken( ) <> FB_TK_EOL ) then
486+ if ( not hIsTokenEndOfStream() ) then
458487 errmsg = FB_ERRMSG_SYNTAXERROR
459488 end if
460489 elseif ( astIsConstant( expr ) ) then
461490 DWStrAssign( res, symbGetConstStrAsWstr( expr->sym ) )
462491 '' any tokens still in the buffer? cExpression() should have used them all
463- if ( lexGetToken( ) <> FB_TK_EOL ) then
492+ if ( not hIsTokenEndOfStream() ) then
464493 errmsg = FB_ERRMSG_SYNTAXERROR
465494 end if
466495 astDelTree( expr )
@@ -1035,9 +1064,8 @@ private function hDefQuerySymZ_cb( byval argtb as LEXPP_ARGTB ptr, byval errnum
10351064 '' prevent cExpression from writing to .pp.bas file
10361065 lex.ctx->reclevel += 1
10371066
1038- DZstrAssign( lex.ctx->deftext, *sexpr )
1039- lex.ctx->defptr = lex.ctx->deftext.data
1040- lex.ctx->deflen += len( *sexpr )
1067+ hArgInsertArgA( sexpr )
1068+ hArgAppendLFCHAR()
10411069
10421070 '' if filtervalue is zero then set the default methods to use for
10431071 '' look-up depending on what we are looking for
@@ -1071,6 +1099,9 @@ private function hDefQuerySymZ_cb( byval argtb as LEXPP_ARGTB ptr, byval errnum
10711099 FB_TKCLASS_QUIRKWD, FB_TKCLASS_OPERATOR
10721100
10731101 sym = cIdentifierOrUDTMember( )
1102+ if ( sym = NULL ) then
1103+ retry = TRUE
1104+ end if
10741105 end select
10751106
10761107 '' for some symbols, we maybe want to reset and try a TYPEOF below
@@ -1114,7 +1145,7 @@ private function hDefQuerySymZ_cb( byval argtb as LEXPP_ARGTB ptr, byval errnum
11141145 '' because there is more, try as typeof.
11151146
11161147 '' not the end of 'sym'? retry as TYPEOF
1117- if ( lexGetToken( ) <> FB_TK_EOF ) then
1148+ if ( not hIsTokenEndOfStream() ) then
11181149 retry = TRUE
11191150 end if
11201151
@@ -1124,9 +1155,8 @@ private function hDefQuerySymZ_cb( byval argtb as LEXPP_ARGTB ptr, byval errnum
11241155 '' reset the current lexer context and refresh the text to parse.
11251156 lexInit( FALSE , TRUE )
11261157
1127- DZstrAssign( lex.ctx->deftext, *sexpr )
1128- lex.ctx->defptr = lex.ctx->deftext.data
1129- lex.ctx->deflen += len( *sexpr )
1158+ hArgInsertArgA( sexpr )
1159+ hArgAppendLFCHAR()
11301160 end if
11311161
11321162 end if
@@ -1181,6 +1211,12 @@ private function hDefQuerySymZ_cb( byval argtb as LEXPP_ARGTB ptr, byval errnum
11811211 res = str( - 1 )
11821212 end select
11831213
1214+ if ( *errnum <> FB_ERRMSG_OK ) then
1215+ errReport( *errnum )
1216+ '' error recovery: skip until next line (in the buffer)
1217+ hSkipUntil( FB_TK_EOL, TRUE )
1218+ end if
1219+
11841220 lex.ctx->reclevel -= 1
11851221
11861222 lexPopCtx()
0 commit comments