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 .
20 #ifndef INCLUDED_BASIC_SOURCE_INC_PARSER_HXX
21 #define INCLUDED_BASIC_SOURCE_INC_PARSER_HXX
24 #include "codegen.hxx"
29 typedef ::std::vector
< OUString
> StringVector
;
33 class SbiParser
: public SbiTokenizer
35 friend class SbiExpression
;
37 SbiParseStack
* pStack
;
39 SbiExprNode
* pWithVar
;
41 sal_uInt32 nGblChain
; // for global DIMs
42 bool bGblDefs
; // true: global definitions general
43 bool bNewGblDefs
; // true: globale definitions before sub
47 SbiSymDef
* VarDecl( SbiDimList
**, bool, bool );
48 SbiProcDef
* ProcDecl(bool bDecl
);
49 void DefStatic( bool bPrivate
);
50 void DefProc( bool bStatic
, bool bPrivate
); // read in procedure
51 void DefVar( SbiOpcode eOp
, bool bStatic
); // read in DIM/REDIM
52 void TypeDecl( SbiSymDef
&, bool bAsNewAlreadyParsed
=false ); // AS-declaration
53 void OpenBlock( SbiToken
, SbiExprNode
* = NULL
);
55 bool Channel( bool bAlways
=false ); // parse channel number
56 void StmntBlock( SbiToken
);
57 void DefType( bool bPrivate
); // Parse type declaration
58 void DefEnum( bool bPrivate
); // Parse enum declaration
59 void DefDeclare( bool bPrivate
);
60 void EnableCompatibility();
61 static bool IsUnoInterface( const OUString
& sTypeName
);
63 SbxArrayRef rTypeArray
;
64 SbxArrayRef rEnumArray
;
65 SbiStringPool aGblStrings
; // string-pool
66 SbiStringPool aLclStrings
; // string-pool
68 SbiSymPool aPublics
; // module global
69 SbiSymPool aRtlSyms
; // Runtime-Library
70 SbiCodeGen aGen
; // Code-Generator
71 StarBASIC
* pBasic
; // StarBASIC instance
74 short nBase
; // OPTION BASE-value
75 bool bText
; // OPTION COMPARE TEXT
76 bool bExplicit
; // true: OPTION EXPLICIT
77 bool bClassModule
; // true: OPTION ClassModule
78 StringVector aIfaceVector
; // Holds all interfaces implemented by a class module
79 StringVector aRequiredTypes
; // Types used in Dim As New <type> outside subs
80 # define N_DEF_TYPES 26
81 SbxDataType eDefTypes
[N_DEF_TYPES
]; // DEFxxx data types
83 SbiParser( StarBASIC
*, SbModule
* );
85 void SetCodeCompleting( const bool& b
);
86 bool IsCodeCompleting() const { return bCodeCompleting
;}
87 SbiExprNode
* GetWithVar();
89 // from 31.3.1996, search symbol in the runtime-library
90 SbiSymDef
* CheckRTLForSym( const OUString
& rSym
, SbxDataType eType
);
95 bool TestToken( SbiToken
);
96 bool TestSymbol( bool bKwdOk
=false );
100 void Symbol( const KeywordSymbolInfo
* pKeywordSymbolInfo
= NULL
); // let or call
101 void ErrorStmnt(); // ERROR n
102 void NotImp(); // not implemented
103 void BadBlock(); // LOOP/WEND/NEXT
104 void BadSyntax(); // wrong SbiToken
105 void NoIf(); // ELSE/ELSE IF without IF
106 void Assign(); // LET
109 void Close(); // CLOSE
110 void Declare(); // DECLARE
111 void DefXXX(); // DEFxxx
113 void ReDim(); // ReDim();
114 void Erase(); // ERASE
116 void For(); // FOR...NEXT
117 void Goto(); // GOTO / GOSUB
119 void Implements(); // IMPLEMENTS
120 void Input(); // INPUT, INPUT #
121 void Line(); // LINE -> LINE INPUT [#] (#i92642)
122 void LineInput(); // LINE INPUT, LINE INPUT #
124 void Name(); // NAME .. AS ..
125 void On(); // ON ERROR/variable
126 void OnGoto(); // ON...GOTO / GOSUB
128 void Option(); // OPTION
129 void Print(); // PRINT, PRINT #
130 void SubFunc(); // SUB / FUNCTION
131 void Resume(); // RESUME
132 void Return(); // RETURN
134 void DoLoop(); // DO...LOOP
135 void Select(); // SELECT ... CASE
137 void Static(); // STATIC
138 void Stop(); // STOP/SYSTEM
139 void Type(); // TYPE...AS...END TYPE
140 void Enum(); // TYPE...END ENUM
141 void While(); // WHILE/WEND
143 void Write(); // WRITE
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */