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