1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
23 #include "codegen.hxx"
25 #include <basic/sbx.hxx>
31 class SbiParser
: public SbiTokenizer
33 friend class SbiExpression
;
35 SbiParseStack
* pStack
;
37 SbiExprNode
* pWithVar
;
39 sal_uInt32 nGblChain
; // for global DIMs
40 bool bGblDefs
; // true: global definitions general
41 bool bNewGblDefs
; // true: globale definitions before sub
45 SbiSymDef
* VarDecl( SbiExprListPtr
*, bool, bool );
46 SbiProcDef
* ProcDecl(bool bDecl
);
47 void DefStatic( bool bPrivate
);
48 void DefProc( bool bStatic
, bool bPrivate
); // read in procedure
49 void DefVar( SbiOpcode eOp
, bool bStatic
); // read in DIM/REDIM
50 void TypeDecl( SbiSymDef
&, bool bAsNewAlreadyParsed
=false ); // AS-declaration
51 void OpenBlock( SbiToken
, SbiExprNode
* = nullptr );
53 bool Channel( bool bAlways
=false ); // parse channel number
54 void StmntBlock( SbiToken
);
55 void DefType(); // Parse type declaration
56 void DefEnum( bool bPrivate
); // Parse enum declaration
57 void DefDeclare( bool bPrivate
);
58 void EnableCompatibility();
59 static bool IsUnoInterface( const OUString
& sTypeName
);
61 SbxArrayRef rTypeArray
;
62 SbxArrayRef rEnumArray
;
63 SbiStringPool aGblStrings
; // string-pool
64 SbiStringPool aLclStrings
; // string-pool
66 SbiSymPool aPublics
; // module global
67 SbiSymPool aRtlSyms
; // Runtime-Library
68 SbiCodeGen aGen
; // Code-Generator
70 short nBase
; // OPTION BASE-value
71 bool bExplicit
; // true: OPTION EXPLICIT
72 bool bClassModule
; // true: OPTION ClassModule
73 std::vector
<OUString
> aIfaceVector
; // Holds all interfaces implemented by a class module
74 std::vector
<OUString
> aRequiredTypes
; // Types used in Dim As New <type> outside subs
75 # define N_DEF_TYPES 26
76 SbxDataType eDefTypes
[N_DEF_TYPES
]; // DEFxxx data types
78 SbiParser( StarBASIC
*, SbModule
* );
81 void SetCodeCompleting( bool b
);
82 bool IsCodeCompleting() const { return bCodeCompleting
;}
83 SbiExprNode
* GetWithVar();
85 // from 31.3.1996, search symbol in the runtime-library
86 SbiSymDef
* CheckRTLForSym( const OUString
& rSym
, SbxDataType eType
);
91 bool TestToken( SbiToken
);
96 void Symbol( const KeywordSymbolInfo
* pKeywordSymbolInfo
); // let or call
97 void ErrorStmnt(); // ERROR n
98 void BadBlock(); // LOOP/WEND/NEXT
99 void NoIf(); // ELSE/ELSE IF without IF
100 void Assign(); // LET
103 void Close(); // CLOSE
104 void Declare(); // DECLARE
105 void DefXXX(); // DEFxxx
107 void ReDim(); // ReDim();
108 void Erase(); // ERASE
110 void For(); // FOR...NEXT
111 void Goto(); // GOTO / GOSUB
113 void Implements(); // IMPLEMENTS
114 void Input(); // INPUT, INPUT #
115 void Line(); // LINE -> LINE INPUT [#] (#i92642)
116 void LineInput(); // LINE INPUT, LINE INPUT #
118 void Name(); // NAME .. AS ..
119 void On(); // ON ERROR/variable
120 void OnGoto(); // ON...GOTO / GOSUB
122 void Option(); // OPTION
123 void Print(); // PRINT, PRINT #
124 void SubFunc(); // SUB / FUNCTION
125 void Resume(); // RESUME
126 void Return(); // RETURN
128 void DoLoop(); // DO...LOOP
129 void Select(); // SELECT ... CASE
131 void Static(); // STATIC
132 void Stop(); // STOP/SYSTEM
133 void Type(); // TYPE...AS...END TYPE
134 void Enum(); // TYPE...END ENUM
135 void While(); // WHILE/WEND
137 void Write(); // WRITE
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */