16 byval tk
as FB_TOKEN _
19 dim as ASTNODE
ptr usingexpr, filexpr, filexprcopy, expr
20 dim as integer expressions, issemicolon, iscomma, istab, isspc, islprint
26 case FB_TK_PRINT, CHAR_QUESTION
30 if( fbLangOptIsSet( FB_LANG_OPT_OPTION ) = FALSE )
then
46 if(
hMatch( CHAR_SHARP ) )
then
47 hMatchExpressionEx( filexpr, FB_DATATYPE_INTEGER )
56 if( astIsCONST( filexpr ) = FALSE )
then
67 if(
hMatch( FB_TK_USING ) )
then
69 if( usingexpr <> NULL )
then
75 islprint ) = FALSE )
then
80 hMatchExpressionEx( usingexpr, FB_DATATYPE_STRING )
82 if(
hMatch( CHAR_SEMICOLON ) = FALSE )
then
94 if(
hMatch( FB_TK_SPC ) )
then
97 hMatchExpressionEx( expr, FB_DATATYPE_INTEGER )
99 elseif(
hMatch( FB_TK_TAB ) )
then
102 hMatchExpressionEx( expr, FB_DATATYPE_INTEGER )
110 if(
hMatch( CHAR_COMMA ) )
then
111 if( usingexpr <> NULL )
then
116 elseif(
hMatch( CHAR_SEMICOLON ) )
then
121 if( (iscomma = FALSE)
and _
122 (issemicolon = FALSE)
and _
131 islprint ) = FALSE )
then
139 islprint ) = FALSE )
then
152 islprint ) = FALSE )
then
162 islprint ) = FALSE )
then
169 loop while( iscomma
or issemicolon )
171 if( usingexpr = NULL )
then
172 if( expressions = 0 )
then
178 islprint ) = FALSE )
then
185 islprint ) = FALSE )
then
201 dim as ASTNODE
ptr filexpr, filexprcopy, expr
202 dim as integer expressions, iscomma
210 if(
hMatch( CHAR_SHARP ) )
then
211 hMatchExpressionEx( filexpr, FB_DATATYPE_INTEGER )
221 if( astIsCONST( filexpr ) = FALSE )
then
229 if( expr = NULL )
then
234 if(
hMatch( CHAR_COMMA ) )
then
241 if( (iscomma = FALSE)
and (expr = NULL) )
then
242 if( expressions = 0 )
then
243 rtlWrite( filexprcopy, FALSE, NULL )
249 if(
rtlWrite( filexprcopy, iscomma, expr ) = FALSE )
then
254 loop while( iscomma )
270 dim as ASTNODE
ptr expr, dstexpr
271 dim as integer isfile, addnewline, issep, addquestion
284 addnewline = (
hMatch( CHAR_SEMICOLON ) = FALSE)
288 if(
hMatch( CHAR_SHARP ) )
then
294 if( expr = NULL )
then
296 errReport( FB_ERRMSG_EXPECTEDEXPRESSION )
305 if(
hMatch( CHAR_COMMA ) = FALSE )
then
306 if(
hMatch( CHAR_SEMICOLON ) = FALSE )
then
308 if( (expr = NULL)
or (isfile) )
then
320 if( dstexpr = NULL )
then
321 if( (expr = NULL)
or (isfile) )
then
322 errReport( FB_ERRMSG_EXPECTEDIDENTIFIER )
330 if( issep = FALSE )
then
336 if( typeIsConst( astGetFullType( dstexpr ) ) )
then
337 errReport( FB_ERRMSG_CONSTANTCANTBECHANGED )
340 select case astGetDataType( dstexpr )
341 case FB_DATATYPE_STRING, FB_DATATYPE_FIXSTR, FB_DATATYPE_CHAR
342 function =
rtlFileLineInput( isfile, expr, dstexpr, addquestion, addnewline )
344 case FB_DATATYPE_WCHAR
364 dim as ASTNODE
ptr filestrexpr, dstexpr
365 dim as integer islast, isfile, addnewline, addquestion
373 addnewline = (
hMatch( CHAR_SEMICOLON ) = FALSE)
377 if(
hMatch( CHAR_SHARP ) )
then
380 hMatchExpressionEx( filestrexpr, FB_DATATYPE_INTEGER )
395 if( (isfile)
or (filestrexpr <> NULL) )
then
396 if(
hMatch( CHAR_COMMA ) = FALSE )
then
397 if(
hMatch( CHAR_SEMICOLON ) = FALSE )
then
406 if(
rtlFileInput( isfile, filestrexpr, addquestion, addnewline ) = FALSE )
then
413 if( dstexpr = NULL )
then
414 errReport( FB_ERRMSG_EXPECTEDIDENTIFIER )
419 if(
hMatch( CHAR_COMMA ) )
then
425 if( dstexpr <> NULL )
then
427 if( typeIsConst( astGetFullType( dstexpr ) ) )
then
428 errReport( FB_ERRMSG_CONSTANTCANTBECHANGED )
445 byval isfunc
as integer _
449 dim as ASTNODE
ptr filenum, proc
466 if( filenum = NULL )
then
470 errReport( FB_ERRMSG_EXPECTEDEXPRESSION )
476 if( proc = NULL )
then
486 loop while(
hMatch( CHAR_COMMA ) )
502 byval isfunc
as integer _
505 dim as ASTNODE
ptr fileexpr, posexpr, srcexpr, elmexpr
506 dim as integer isarray
507 dim as FBSYMBOL
ptr s
516 hMatchExpressionEx( fileexpr, FB_DATATYPE_INTEGER )
522 if( posexpr = NULL )
then
529 hMatchExpressionEx( srcexpr, FB_DATATYPE_INTEGER )
533 if( astIsCONST( srcexpr )
or astIsOFFSET( srcexpr ) )
then
535 errReport( FB_ERRMSG_EXPECTEDIDENTIFIER, TRUE )
548 s = astGetSymbol( srcexpr )
554 if( symbGetType( s ) = FB_DATATYPE_STRING )
then
556 errReport( FB_ERRMSG_INVALIDDATATYPES, TRUE )
574 if(
hMatch( CHAR_COMMA ) )
then
576 errReport( FB_ERRMSG_ELEMENTSMUSTBEEMPTY )
579 if( elmexpr <> NULL )
then
585 select case astGetDataType( srcexpr )
586 case FB_DATATYPE_STRING, FB_DATATYPE_FIXSTR
587 errReport( FB_ERRMSG_ELEMENTSMUSTBEEMPTY )
590 if( elmexpr <> NULL )
then
596 if( elmexpr = NULL )
then
597 errReport( FB_ERRMSG_EXPECTEDEXPRESSION )
604 if( typeIsPtr( astGetDatatype( elmexpr ) ) )
then
607 if( astGetDatatype( elmexpr ) <> FB_DATATYPE_INTEGER )
then
608 elmexpr =
astNewCONV( FB_DATATYPE_INTEGER, NULL, elmexpr )
609 if( elmexpr = NULL )
then
618 if( isarray = FALSE )
then
619 function =
rtlFilePut( fileexpr, posexpr, srcexpr, elmexpr, isfunc )
632 byval isfunc
as integer _
635 dim as ASTNODE
ptr fileexpr, posexpr, dstexpr, elmexpr, iobexpr
636 dim as integer isarray
637 dim as FBSYMBOL
ptr s
646 hMatchExpressionEx( fileexpr, FB_DATATYPE_INTEGER )
657 if( dstexpr = NULL )
then
658 errReport( FB_ERRMSG_EXPECTEDIDENTIFIER )
670 s = astGetSymbol( dstexpr )
675 if( symbGetType( s ) = FB_DATATYPE_STRING )
then
676 errReport( FB_ERRMSG_INVALIDDATATYPES, TRUE )
692 if(
hMatch( CHAR_COMMA ) )
then
696 if( elmexpr <> NULL )
then
697 errReport( FB_ERRMSG_ELEMENTSMUSTBEEMPTY )
704 select case astGetDataType( dstexpr )
705 case FB_DATATYPE_STRING, FB_DATATYPE_FIXSTR
706 errReport( FB_ERRMSG_ELEMENTSMUSTBEEMPTY )
712 if( typeIsPtr( astGetDatatype( elmexpr ) ) )
then
715 if( astGetDatatype( elmexpr ) <> FB_DATATYPE_INTEGER )
then
716 elmexpr =
astNewCONV( FB_DATATYPE_INTEGER, NULL, elmexpr )
717 if( elmexpr = NULL )
then
729 if(
hMatch( CHAR_COMMA ) )
then
731 if( iobexpr <> NULL )
then
732 s = astGetSymbol( iobexpr )
742 var dtype = symbGetType( s )
743 if( (typeGetSize( dtype ) <> env.pointersize)
or _
744 (typeGetClass( dtype ) <> FB_DATACLASS_INTEGER)
or _
745 typeIsPtr( dtype ) )
then
750 errReport( FB_ERRMSG_EXPECTEDIDENTIFIER )
757 if( typeIsConst( astGetFullType( dstexpr ) ) )
then
758 errReport( FB_ERRMSG_CONSTANTCANTBECHANGED )
763 if( typeIsConst( astGetFullType( iobexpr ) ) )
then
764 errReport( FB_ERRMSG_CONSTANTCANTBECHANGED )
768 if( isarray = FALSE )
then
769 function =
rtlFileGet( fileexpr, posexpr, dstexpr, elmexpr, iobexpr, isfunc )
771 function =
rtlFileGetArray( fileexpr, posexpr, dstexpr, iobexpr, isfunc )
788 byval isfunc
as integer _
791 dim as ASTNODE
ptr filenum, filename, fmode, faccess, flock, flen, fencoding
792 dim as integer short_form
793 dim as integer file_mode, access_mode, lock_mode, record_len
794 dim as FBOPENKIND open_kind
798 open_kind = FB_FILE_TYPE_FILE
803 if( fbLangIsSet( FB_LANG_QB ) = FALSE )
then
808 if( lexGetSymChain( ) = NULL )
then
810 open_kind = FB_FILE_TYPE_CONS
815 open_kind = FB_FILE_TYPE_ERR
819 if( lexGetSymChain( ) = NULL )
then
821 open_kind = FB_FILE_TYPE_PIPE
826 if( lexGetSymChain( ) = NULL )
then
828 open_kind = FB_FILE_TYPE_SCRN
833 if( lexGetSymChain( ) = NULL )
then
835 open_kind = FB_FILE_TYPE_LPT
840 if( lexGetSymChain( ) = NULL )
then
842 open_kind = FB_FILE_TYPE_COM
854 if( fbLangIsSet( FB_LANG_QB ) )
then
855 open_kind = FB_FILE_TYPE_QB
858 select case as const open_kind
859 case FB_FILE_TYPE_FILE, FB_FILE_TYPE_PIPE, FB_FILE_TYPE_LPT, _
860 FB_FILE_TYPE_COM, FB_FILE_TYPE_QB
864 hMatchExpressionEx( filename, FB_DATATYPE_STRING )
872 select case open_kind
873 case FB_FILE_TYPE_FILE, FB_FILE_TYPE_QB
876 case FB_TK_FOR, FB_TK_ACCESS, FB_TK_AS
881 if(
hMatch( CHAR_COMMA ) )
then
895 if( short_form )
then
902 hMatchExpressionEx( filenum, FB_DATATYPE_INTEGER )
906 hMatchExpressionEx( filename, FB_DATATYPE_STRING )
909 if(
hMatch( CHAR_COMMA ) )
then
911 hMatchExpressionEx( flen, FB_DATATYPE_INTEGER )
914 if(
hMatch( CHAR_COMMA ) )
then
916 hMatchExpressionEx( faccess, FB_DATATYPE_STRING )
919 if(
hMatch( CHAR_COMMA ) )
then
920 hMatchExpressionEx( flock, FB_DATATYPE_STRING )
925 if( flen = NULL )
then
929 if( faccess = NULL )
then
933 if( flock = NULL )
then
943 filenum, flen, isfunc )
949 if(
hMatch( FB_TK_FOR ) )
then
952 file_mode = FB_FILE_MODE_INPUT
954 file_mode = FB_FILE_MODE_OUTPUT
956 file_mode = FB_FILE_MODE_BINARY
958 file_mode = FB_FILE_MODE_RANDOM
960 file_mode = FB_FILE_MODE_APPEND
968 file_mode = FB_FILE_MODE_RANDOM
980 if( fbLangIsSet( FB_LANG_QB ) ) = FALSE
then
982 select case file_mode
983 case FB_FILE_MODE_INPUT, FB_FILE_MODE_OUTPUT, FB_FILE_MODE_APPEND
985 if(
hMatch( FB_TK_ENCODING ) )
then
986 hMatchExpressionEx( fencoding, FB_DATATYPE_STRING )
1001 access_mode = FB_FILE_ACCESS_WRITE
1005 if(
hMatch( FB_TK_WRITE ) )
then
1006 access_mode = FB_FILE_ACCESS_READWRITE
1008 access_mode = FB_FILE_ACCESS_READ
1012 access_mode = FB_FILE_ACCESS_ANY
1023 if(
hMatch( FB_TK_SHARED ) )
then
1024 lock_mode = FB_FILE_LOCK_SHARED
1030 lock_mode = FB_FILE_LOCK_WRITE
1034 if(
hMatch( FB_TK_WRITE ) )
then
1035 lock_mode = FB_FILE_LOCK_READWRITE
1037 lock_mode = FB_FILE_LOCK_READ
1041 lock_mode = FB_FILE_LOCK_SHARED
1052 if(
hMatch( FB_TK_AS ) = FALSE )
then
1058 hMatchExpressionEx( filenum, FB_DATATYPE_INTEGER )
1071 hMatchExpressionEx( flen, FB_DATATYPE_INTEGER )
1083 function =
rtlFileOpen( filename, fmode, faccess, flock, _
1084 filenum, flen, fencoding, isfunc, open_kind )
1091 byval isfunc
as integer _
1094 dim as ASTNODE
ptr filename_old, filename_new
1095 dim as integer matchprnt
1104 matchprnt =
hMatch( CHAR_LPRNT )
1107 hMatchExpressionEx( filename_old, FB_DATATYPE_STRING )
1113 if(
hMatch( FB_TK_AS ) = FALSE )
then
1114 if(
hMatch( CHAR_COMMA ) = FALSE )
then
1120 hMatchExpressionEx( filename_new, FB_DATATYPE_STRING )
1122 if( isfunc
or matchprnt )
then
1128 function =
rtlFileRename( filename_new, filename_old, isfunc )
1140 byval tk
as FB_TOKEN _
1143 dim as ASTNODE
ptr filenum, expr1, expr2
1144 dim as integer islock
1148 select case as const tk
1165 hMatchExpressionEx( filenum, FB_DATATYPE_INTEGER )
1169 hMatchExpressionEx( expr1, FB_DATATYPE_INTEGER )
1181 function = (
hFilePut( FALSE ) <> NULL)
1191 function = (
hFileGet( FALSE ) <> NULL)
1194 case FB_TK_LOCK, FB_TK_UNLOCK
1195 if( tk = FB_TK_LOCK )
then
1205 hMatchExpressionEx( filenum, FB_DATATYPE_INTEGER )
1209 hMatchExpressionEx( expr1, FB_DATATYPE_INTEGER )
1211 if(
hMatch( FB_TK_TO ) )
then
1212 hMatchExpressionEx( expr2, FB_DATATYPE_INTEGER )
1217 function =
rtlFileLock( islock, filenum, expr1, expr2 )
1234 dim as ASTNODE
ptr filenum, expr
1239 select case as const tk
1243 hMatchExpressionEx( filenum, FB_DATATYPE_INTEGER )
1248 case FB_TK_INPUT, FB_TK_WINPUT
1251 hMatchExpressionEx( expr, FB_DATATYPE_INTEGER )
1252 if(
hMatch( CHAR_COMMA ) )
then
1254 hMatchExpressionEx( filenum, FB_DATATYPE_INTEGER )