18 parser.stmt.
for = NULL
20 parser.stmt.
while = NULL
21 parser.stmt.
select = NULL
22 parser.stmt.proc = NULL
23 parser.stmt.
with.sym = NULL
36 #macro CHECK_CODEMASK( for_tk, until_tk )
38 hSkipCompound( for_tk, until_tk )
55 if( env.clopt.lang = FB_LANG_QB )
then
56 if( lexGetType() <> FB_DATATYPE_INVALID )
then
63 CHECK_CODEMASK( FB_TK_IF, FB_TK_IF )
67 CHECK_CODEMASK( FB_TK_FOR, FB_TK_NEXT )
71 CHECK_CODEMASK( FB_TK_DO, FB_TK_LOOP )
75 CHECK_CODEMASK( FB_TK_WHILE, FB_TK_WEND )
79 CHECK_CODEMASK( FB_TK_SELECT, FB_TK_SELECT )
83 CHECK_CODEMASK( FB_TK_WITH, FB_TK_WITH )
87 CHECK_CODEMASK( FB_TK_SCOPE, FB_TK_SCOPE )
96 case FB_TK_ELSE, FB_TK_ELSEIF
120 CHECK_CODEMASK( INVALID, INVALID )
141 dim as ASTNODE
ptr errlevel =
any
148 case FB_TK_STMTSEP, FB_TK_EOL, FB_TK_EOF, FB_TK_COMMENT, FB_TK_REM, _
149 FB_TK_ELSE, FB_TK_END, FB_TK_ENDIF
159 function = FB_ERRMSG_OK
161 if( symbGetProcStatReturnUsed( parser.currproc ) )
then
165 function = FB_ERRMSG_MISSINGRETURNFORCTORRESULT
170 symbSetProcStatAssignUsed( parser.currproc )
176 #macro hExitError( errnum )
185 dim as FBSYMBOL
ptr label = NULL
193 if( parser.stmt.
for = NULL )
then
194 hExitError( FB_ERRMSG_ILLEGALOUTSIDEFORSTMT )
199 dim as FB_CMPSTMTSTK
ptr stk = parser.stmt.
for
204 hExitError( FB_ERRMSG_EXPECTEDFOR )
208 if( stk = NULL )
then
209 hExitError( FB_ERRMSG_NOENCLOSEDFORSTMT )
215 label = stk->
for.endlabel
218 if( parser.stmt.
do = NULL )
then
219 hExitError( FB_ERRMSG_ILLEGALOUTSIDEDOSTMT )
224 dim as FB_CMPSTMTSTK
ptr stk = parser.stmt.
do
229 hExitError( FB_ERRMSG_EXPECTEDDO )
233 if( stk = NULL )
then
234 hExitError( FB_ERRMSG_NOENCLOSEDDOSTMT )
240 label = stk->
do.endlabel
243 if( parser.stmt.
while = NULL )
then
244 hExitError( FB_ERRMSG_ILLEGALOUTSIDEWHILESTMT )
249 dim as FB_CMPSTMTSTK
ptr stk = parser.stmt.
while
254 hExitError( FB_ERRMSG_EXPECTEDWHILE )
257 stk = stk->
while.last
258 if( stk = NULL )
then
259 hExitError( FB_ERRMSG_NOENCLOSEDWHILESTMT )
265 label = stk->
while.endlabel
268 if( parser.stmt.
select = NULL )
then
269 hExitError( FB_ERRMSG_ILLEGALOUTSIDESELSTMT )
274 dim as FB_CMPSTMTSTK
ptr stk = parser.stmt.
select
279 hExitError( FB_ERRMSG_EXPECTEDSELECT )
282 stk = stk->
select.last
283 if( stk = NULL )
then
284 hExitError( FB_ERRMSG_NOENCLOSEDSELSTMT )
290 label = stk->
select.endlabel
292 case FB_TK_SUB, FB_TK_FUNCTION, FB_TK_PROPERTY, FB_TK_OPERATOR, _
293 FB_TK_CONSTRUCTOR, FB_TK_DESTRUCTOR
295 if( parser.stmt.proc <> NULL )
then
296 label = parser.stmt.proc->proc.endlabel
299 if( label = NULL )
then
300 hExitError( FB_ERRMSG_ILLEGALOUTSIDEAPROC )
303 dim as FB_ERRMSG errnum = FB_ERRMSG_OK
307 if( symbGetType( parser.currproc ) = FB_DATATYPE_VOID )
then
308 if( (symbGetAttrib( parser.currproc )
and _
309 (FB_SYMBATTRIB_PROPERTY
or FB_SYMBATTRIB_OPERATOR
or _
310 FB_SYMBATTRIB_CONSTRUCTOR
or FB_SYMBATTRIB_DESTRUCTOR)) <> 0 )
then
311 errnum = FB_ERRMSG_ILLEGALOUTSIDEASUB
314 errnum = FB_ERRMSG_ILLEGALOUTSIDEASUB
318 if( symbGetType( parser.currproc ) <> FB_DATATYPE_VOID )
then
319 if( (symbGetAttrib( parser.currproc )
and _
320 (FB_SYMBATTRIB_PROPERTY
or FB_SYMBATTRIB_OPERATOR
or _
321 FB_SYMBATTRIB_CONSTRUCTOR
or FB_SYMBATTRIB_DESTRUCTOR)) <> 0 )
then
322 errnum = FB_ERRMSG_ILLEGALOUTSIDEAFUNCTION
327 errnum = FB_ERRMSG_ILLEGALOUTSIDEAFUNCTION
331 if( symbIsProperty( parser.currproc ) )
then
334 errnum = FB_ERRMSG_ILLEGALOUTSIDEANPROPERTY
338 if( symbIsOperator( parser.currproc ) )
then
341 errnum = FB_ERRMSG_ILLEGALOUTSIDEANOPERATOR
344 case FB_TK_CONSTRUCTOR
345 if( symbIsConstructor( parser.currproc ) = FALSE )
then
346 errnum = FB_ERRMSG_ILLEGALOUTSIDEACTOR
349 case FB_TK_DESTRUCTOR
350 if( symbIsDestructor( parser.currproc ) = FALSE )
then
351 errnum = FB_ERRMSG_ILLEGALOUTSIDEADTOR
356 if( errnum <> FB_ERRMSG_OK )
then
363 hExitError( FB_ERRMSG_INVALIDEXITSTMT )
371 dim as FBSYMBOL
ptr label = NULL
379 if( parser.stmt.
for = NULL )
then
380 hExitError( FB_ERRMSG_ILLEGALOUTSIDEFORSTMT )
385 dim as FB_CMPSTMTSTK
ptr stk = parser.stmt.
for
390 hExitError( FB_ERRMSG_EXPECTEDFOR )
394 if( stk = NULL )
then
395 hExitError( FB_ERRMSG_NOENCLOSEDFORSTMT )
401 label = stk->
for.cmplabel
404 if( parser.stmt.
do = NULL )
then
405 hExitError( FB_ERRMSG_ILLEGALOUTSIDEDOSTMT )
410 dim as FB_CMPSTMTSTK
ptr stk = parser.stmt.
do
415 hExitError( FB_ERRMSG_EXPECTEDDO )
419 if( stk = NULL )
then
420 hExitError( FB_ERRMSG_NOENCLOSEDDOSTMT )
426 label = stk->
do.cmplabel
429 if( parser.stmt.
while = NULL )
then
430 hExitError( FB_ERRMSG_ILLEGALOUTSIDEWHILESTMT )
435 dim as FB_CMPSTMTSTK
ptr stk = parser.stmt.
while
440 hExitError( FB_ERRMSG_EXPECTEDWHILE )
443 stk = stk->
while.last
444 if( stk = NULL )
then
445 hExitError( FB_ERRMSG_NOENCLOSEDWHILESTMT )
451 label = stk->
while.cmplabel
454 hExitError( FB_ERRMSG_INVALIDCONTINUESTMT )
469 case FB_TK_SUB, FB_TK_FUNCTION, FB_TK_CONSTRUCTOR, FB_TK_DESTRUCTOR, _
470 FB_TK_OPERATOR, FB_TK_PROPERTY
486 case FB_TK_ELSE, FB_TK_END, FB_TK_ENDIF
498 dim as integer errmsg
499 dim as FB_CMPSTMTSTK
ptr stk
502 if( stk = NULL )
then
506 select case as const stk->id
508 errmsg = FB_ERRMSG_EXPECTEDENDIF
511 errmsg = FB_ERRMSG_EXPECTEDENDSELECT
514 errmsg = FB_ERRMSG_EXPECTEDENDSCOPE
517 errmsg = FB_ERRMSG_EXPECTEDENDWITH
520 errmsg = FB_ERRMSG_EXPECTEDENDNAMESPACE
523 errmsg = FB_ERRMSG_EXPECTEDENDEXTERN
526 select case as const stk->proc.tkn
528 errmsg = FB_ERRMSG_EXPECTEDENDSUB
530 errmsg = FB_ERRMSG_EXPECTEDENDFUNCTION
531 case FB_TK_CONSTRUCTOR
532 errmsg = FB_ERRMSG_EXPECTEDENDCTOR
533 case FB_TK_DESTRUCTOR
534 errmsg = FB_ERRMSG_EXPECTEDENDDTOR
536 errmsg = FB_ERRMSG_EXPECTEDENDOPERATOR
538 errmsg = FB_ERRMSG_EXPECTEDENDPROPERTY
542 errmsg = FB_ERRMSG_EXPECTEDLOOP
545 errmsg = FB_ERRMSG_EXPECTEDWEND
548 errmsg = FB_ERRMSG_EXPECTEDNEXT
561 byval id
as FB_TOKEN, _
562 byval allowmask
as FB_CMPSTMT_MASK _
563 )
as FB_CMPSTMTSTK
ptr static
565 dim as FB_CMPSTMTSTK
ptr stk
569 stk->allowmask = allowmask
570 stk->scopenode = NULL
573 select case as const id
575 stk->
do.last = parser.stmt.
do
579 stk->
for.last = parser.stmt.
for
580 parser.stmt.
for = stk
583 stk->
select.last = parser.stmt.
select
584 parser.stmt.
select = stk
587 stk->
while.last = parser.stmt.
while
588 parser.stmt.
while = stk
591 stk->proc.last = parser.stmt.proc
592 parser.stmt.proc = stk
604 byval forid
as FB_TOKEN, _
605 byval showerror
as integer _
606 )
as FB_CMPSTMTSTK
ptr static
608 dim as FB_CMPSTMTSTK
ptr stk
609 dim as integer iserror
612 iserror = (stk = NULL)
614 if( iserror = FALSE )
then
616 iserror = (stk->id <> forid)
621 if( stk <> NULL )
then
625 dim as integer errmsg
626 select case as const forid
628 errmsg = FB_ERRMSG_LOOPWITHOUTDO
631 errmsg = FB_ERRMSG_ENDEXTERNWITHOUTEXTERN
634 errmsg = FB_ERRMSG_NEXTWITHOUTFOR
637 errmsg = FB_ERRMSG_ENDIFWITHOUTIF
640 errmsg = FB_ERRMSG_ENDSCOPEWITHOUTSCOPE
643 errmsg = FB_ERRMSG_ENDSELECTWITHOUTSELECT
646 errmsg = FB_ERRMSG_WENDWITHOUTWHILE
649 errmsg = FB_ERRMSG_ENDWITHWITHOUTWITH
652 errmsg = FB_ERRMSG_ENDSUBWITHOUTSUB
655 errmsg = FB_ERRMSG_ENDNAMESPACEWITHOUTNAMESPACE
672 select case as const stk->id
674 parser.stmt.
do = stk->
do.last
677 parser.stmt.
for = stk->
for.last
680 parser.stmt.
select = stk->
select.last
683 parser.stmt.
while = stk->
while.last
686 parser.stmt.proc = stk->proc.last
693 parser.stmt.id = stk->id
700 dim as FB_CMPSTMTSTK
ptr stk =
any
701 dim as integer errmsg =
any
706 if( stk = NULL )
then
711 if( stk->allowmask
and allowmask )
then
716 if( fbIsModLevel( ) = FALSE )
then
717 errmsg = FB_ERRMSG_ILLEGALINSIDEASUB
719 if( symbIsGlobalNamespc( ) )
then
720 if( stk->id = FB_TK_SELECT )
then
721 errmsg = FB_ERRMSG_ILLEGALINSIDESELECT
723 errmsg = FB_ERRMSG_ILLEGALINSIDEASCOPE
726 errmsg = FB_ERRMSG_ILLEGALINSIDEANAMESPC