xref: /AOO41X/main/basic/source/inc/parser.hxx (revision 234bd5c559aaf7abbd02d045859137b774cd8b34)
1*234bd5c5SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*234bd5c5SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*234bd5c5SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*234bd5c5SAndrew Rist  * distributed with this work for additional information
6*234bd5c5SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*234bd5c5SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*234bd5c5SAndrew Rist  * "License"); you may not use this file except in compliance
9*234bd5c5SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*234bd5c5SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*234bd5c5SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*234bd5c5SAndrew Rist  * software distributed under the License is distributed on an
15*234bd5c5SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*234bd5c5SAndrew Rist  * KIND, either express or implied.  See the License for the
17*234bd5c5SAndrew Rist  * specific language governing permissions and limitations
18*234bd5c5SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*234bd5c5SAndrew Rist  *************************************************************/
21*234bd5c5SAndrew Rist 
22*234bd5c5SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _PARSER_HXX
25cdf0e10cSrcweir #define _PARSER_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "expr.hxx"
28cdf0e10cSrcweir #include "codegen.hxx"
29cdf0e10cSrcweir #include "symtbl.hxx"
30cdf0e10cSrcweir 
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <vector>
33cdf0e10cSrcweir typedef ::std::vector< String > StringVector;
34cdf0e10cSrcweir 
35cdf0e10cSrcweir struct SbiParseStack;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir class SbiParser : public SbiTokenizer
38cdf0e10cSrcweir {
39cdf0e10cSrcweir     friend class SbiExpression;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir     SbiParseStack* pStack;          // Block-Stack
42cdf0e10cSrcweir     SbiProcDef* pProc;              // aktuelle Prozedur
43cdf0e10cSrcweir     SbiExprNode*  pWithVar;         // aktuelle With-Variable
44cdf0e10cSrcweir     SbiToken    eEndTok;            // das Ende-Token
45cdf0e10cSrcweir     sal_uInt32      nGblChain;          // Chainkette fuer globale DIMs
46cdf0e10cSrcweir     sal_Bool        bGblDefs;           // sal_True globale Definitionen allgemein
47cdf0e10cSrcweir     sal_Bool        bNewGblDefs;        // sal_True globale Definitionen vor Sub
48cdf0e10cSrcweir     sal_Bool        bSingleLineIf;      // sal_True einzeiliges if-Statement
49cdf0e10cSrcweir 
50cdf0e10cSrcweir     SbiSymDef*  VarDecl( SbiDimList**,sal_Bool,sal_Bool );// Variablen-Deklaration
51cdf0e10cSrcweir     SbiProcDef* ProcDecl(sal_Bool bDecl);// Prozedur-Deklaration
52cdf0e10cSrcweir     void DefStatic( sal_Bool bPrivate );
53cdf0e10cSrcweir     void DefProc( sal_Bool bStatic, sal_Bool bPrivate ); // Prozedur einlesen
54cdf0e10cSrcweir     void DefVar( SbiOpcode eOp, sal_Bool bStatic ); // DIM/REDIM einlesen
55cdf0e10cSrcweir     void TypeDecl( SbiSymDef&, sal_Bool bAsNewAlreadyParsed=sal_False );    // AS-Deklaration
56cdf0e10cSrcweir     void OpenBlock( SbiToken, SbiExprNode* = NULL );    // Block oeffnen
57cdf0e10cSrcweir     void CloseBlock();              // Block aufloesen
58cdf0e10cSrcweir     sal_Bool Channel( sal_Bool=sal_False );     // Kanalnummer parsen
59cdf0e10cSrcweir     void StmntBlock( SbiToken );    // Statement-Block abarbeiten
60cdf0e10cSrcweir     void DefType( sal_Bool bPrivate );  // Parse type declaration
61cdf0e10cSrcweir     void DefEnum( sal_Bool bPrivate );  // Parse enum declaration
62cdf0e10cSrcweir     void DefDeclare( sal_Bool bPrivate );
63cdf0e10cSrcweir     void EnableCompatibility();
64cdf0e10cSrcweir public:
65cdf0e10cSrcweir     SbxArrayRef   rTypeArray;       // das Type-Array
66cdf0e10cSrcweir     SbxArrayRef   rEnumArray;       // Enum types
67cdf0e10cSrcweir     SbiStringPool aGblStrings;      // der String-Pool
68cdf0e10cSrcweir     SbiStringPool aLclStrings;      // der String-Pool
69cdf0e10cSrcweir     SbiSymPool    aGlobals;         // globale Variable
70cdf0e10cSrcweir     SbiSymPool    aPublics;         // modulglobale Variable
71cdf0e10cSrcweir     SbiSymPool    aRtlSyms;         // Runtime-Library
72cdf0e10cSrcweir     SbiCodeGen    aGen;             // Code-Generator
73cdf0e10cSrcweir     StarBASIC*    pBasic;           // StarBASIC-Instanz
74cdf0e10cSrcweir     SbiSymPool*   pPool;            // aktueller Pool
75cdf0e10cSrcweir     SbiExprType   eCurExpr;         // aktueller Expr-Typ
76cdf0e10cSrcweir     short         nBase;            // OPTION BASE-Wert
77cdf0e10cSrcweir     sal_Bool          bText;            // OPTION COMPARE TEXT
78cdf0e10cSrcweir     sal_Bool          bExplicit;        // sal_True: OPTION EXPLICIT
79cdf0e10cSrcweir     sal_Bool          bClassModule;     // sal_True: OPTION ClassModule
80cdf0e10cSrcweir     StringVector  aIfaceVector;     // Holds all interfaces implemented by a class module
81cdf0e10cSrcweir     StringVector  aRequiredTypes;   // Types used in Dim As New <type> outside subs
82cdf0e10cSrcweir     SbxDataType   eDefTypes[26];    // DEFxxx-Datentypen
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     SbiParser( StarBASIC*, SbModule* );
85cdf0e10cSrcweir     sal_Bool Parse();                   // die Aktion
86cdf0e10cSrcweir     SbiExprNode* GetWithVar();      // Innerste With-Variable liefern
87cdf0e10cSrcweir 
88cdf0e10cSrcweir     // AB 31.3.1996, Symbol in Runtime-Library suchen
89cdf0e10cSrcweir     SbiSymDef* CheckRTLForSym( const String& rSym, SbxDataType eType );
90cdf0e10cSrcweir     void AddConstants( void );
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     sal_Bool HasGlobalCode();           // Globaler Code definiert?
93cdf0e10cSrcweir 
94cdf0e10cSrcweir     sal_Bool TestToken( SbiToken );     // bestimmtes TOken?
95cdf0e10cSrcweir     sal_Bool TestSymbol( sal_Bool=sal_False );  // Symbol?
96cdf0e10cSrcweir     sal_Bool TestComma();               // Komma oder EOLN?
97cdf0e10cSrcweir     void TestEoln();                // EOLN?
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     void Symbol( const KeywordSymbolInfo* pKeywordSymbolInfo = NULL );  // Let oder Call
100cdf0e10cSrcweir     void ErrorStmnt();              // ERROR n
101cdf0e10cSrcweir     void NotImp();                  // nicht implementiert
102cdf0e10cSrcweir     void BadBlock();                // LOOP/WEND/NEXT
103cdf0e10cSrcweir     void BadSyntax();               // Falsches SbiToken
104cdf0e10cSrcweir     void NoIf();                    // ELSE/ELSE IF ohne IF
105cdf0e10cSrcweir     void Assign();                  // LET
106cdf0e10cSrcweir     void Call();                    // CALL
107cdf0e10cSrcweir     void Close();                   // CLOSE
108cdf0e10cSrcweir     void Declare();                 // DECLARE
109cdf0e10cSrcweir     void DefXXX();                  // DEFxxx
110cdf0e10cSrcweir     void Dim();                     // DIM
111cdf0e10cSrcweir     void ReDim();                   // ReDim();
112cdf0e10cSrcweir     void Erase();                   // ERASE
113cdf0e10cSrcweir     void Exit();                    // EXIT
114cdf0e10cSrcweir     void For();                     // FOR...NEXT
115cdf0e10cSrcweir     void Goto();                    // GOTO / GOSUB
116cdf0e10cSrcweir     void If();                      // IF
117cdf0e10cSrcweir     void Implements();              // IMPLEMENTS
118cdf0e10cSrcweir     void Input();                   // INPUT, INPUT #
119cdf0e10cSrcweir     void Line();                    // LINE -> LINE INPUT [#] (#i92642)
120cdf0e10cSrcweir     void LineInput();               // LINE INPUT, LINE INPUT #
121cdf0e10cSrcweir     void LSet();                    // LSET
122cdf0e10cSrcweir     void Name();                    // NAME .. AS ..
123cdf0e10cSrcweir     void On();                      // ON ERROR/variable
124cdf0e10cSrcweir     void OnGoto();                  // ON...GOTO / GOSUB
125cdf0e10cSrcweir     void Open();                    // OPEN
126cdf0e10cSrcweir     void Option();                  // OPTION
127cdf0e10cSrcweir     void Print();                   // PRINT, PRINT #
128cdf0e10cSrcweir     void SubFunc();                 // SUB / FUNCTION
129cdf0e10cSrcweir     void Resume();                  // RESUME
130cdf0e10cSrcweir     void Return();                  // RETURN
131cdf0e10cSrcweir     void RSet();                    // RSET
132cdf0e10cSrcweir     void DoLoop();                  // DO...LOOP
133cdf0e10cSrcweir     void Select();                  // SELECT ... CASE
134cdf0e10cSrcweir     void Set();                     // SET
135cdf0e10cSrcweir     void Static();                  // STATIC
136cdf0e10cSrcweir     void Stop();                    // STOP/SYSTEM
137cdf0e10cSrcweir     void Type();                    // TYPE...AS...END TYPE
138cdf0e10cSrcweir     void Enum();                    // TYPE...END ENUM
139cdf0e10cSrcweir     void While();                   // WHILE/WEND
140cdf0e10cSrcweir     void With();                    // WITH
141cdf0e10cSrcweir     void Write();                   // WRITE
142cdf0e10cSrcweir };
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 
149cdf0e10cSrcweir #endif
150