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