"Fossies" - the Fresh Open Source Software Archive

Member "FreeBASIC-1.07.1-source/src/compiler/parser-compound-extern.bas" (27 Sep 2019, 2055 Bytes) of package /linux/privat/FreeBASIC-1.07.1-source.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Visual Basic source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "parser-compound-extern.bas": 1.07.0_vs_1.07.1.

    1 '' EXTERN..END EXTERN compound statement parsing
    2 ''
    3 '' chng: may/2006 written [v1ctor]
    4 
    5 #include once "fb.bi"
    6 #include once "fbint.bi"
    7 #include once "parser.bi"
    8 
    9 '' ExternStmtBegin  =  EXTERN "mangling_spec" (LIB LITSTR)? .
   10 sub cExternStmtBegin( )
   11     dim as FB_CMPSTMTSTK ptr stk = any
   12     dim as integer mangling = any
   13     dim as const zstring ptr litstr = any
   14 
   15     if( fbLangOptIsSet( FB_LANG_OPT_EXTERN ) = FALSE ) then
   16         errReportNotAllowed( FB_LANG_OPT_EXTERN )
   17         '' error recovery: skip the whole compound stmt
   18         hSkipCompound( FB_TK_EXTERN )
   19         exit sub
   20     end if
   21 
   22     if( cCompStmtIsAllowed( FB_CMPSTMT_MASK_EXTERN ) = FALSE ) then
   23         '' error recovery: skip the whole compound stmt
   24         hSkipCompound( FB_TK_EXTERN )
   25         exit sub
   26     end if
   27 
   28     '' EXTERN
   29     lexSkipToken( )
   30 
   31     '' "mangling spec"
   32     if( lexGetClass( ) <> FB_TKCLASS_STRLITERAL ) then
   33         errReport( FB_ERRMSG_SYNTAXERROR )
   34         '' error recovery: assume it's "C"
   35         litstr = @"c"
   36     else
   37         litstr = lexGetText( )
   38     end if
   39 
   40     select case lcase( *litstr )
   41     case "c"
   42         mangling = FB_MANGLING_CDECL
   43         lexSkipToken( )
   44 
   45     case "windows"
   46         mangling = FB_MANGLING_STDCALL
   47         lexSkipToken( )
   48 
   49     case "windows-ms"
   50         mangling = FB_MANGLING_STDCALL_MS
   51         lexSkipToken( )
   52 
   53     case "c++"
   54         mangling = FB_MANGLING_CPP
   55         lexSkipToken( )
   56 
   57     case "rtlib"
   58         mangling = FB_MANGLING_RTLIB
   59         lexSkipToken( )
   60 
   61     case else
   62         errReport( FB_ERRMSG_SYNTAXERROR )
   63         '' error recovery: assume it's "C"
   64         mangling = FB_MANGLING_CDECL
   65         lexSkipToken( )
   66 
   67     end select
   68 
   69     '' [LIB "string"]
   70     cLibAttribute()
   71 
   72     stk = cCompStmtPush( FB_TK_EXTERN, _
   73                          FB_CMPSTMT_MASK_ALL and (not FB_CMPSTMT_MASK_CODE) _
   74                                              and (not FB_CMPSTMT_MASK_DATA) )
   75 
   76     stk->ext.lastmang = parser.mangling
   77     parser.mangling = mangling
   78 end sub
   79 
   80 '' ExternStmtEnd  =  END EXTERN .
   81 sub cExternStmtEnd( )
   82     dim as FB_CMPSTMTSTK ptr stk = any
   83 
   84     stk = cCompStmtGetTOS( FB_TK_EXTERN )
   85     if( stk = NULL ) then
   86         hSkipStmt( )
   87         exit sub
   88     end if
   89 
   90     '' END EXTERN
   91     lexSkipToken( )
   92     lexSkipToken( )
   93 
   94     '' pop from stmt stack
   95     parser.mangling = stk->ext.lastmang
   96     cCompStmtPop( stk )
   97 end sub