1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: parser.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
35 #include "codegen.hxx"
40 typedef ::std::vector
< String
> IfaceVector
;
45 class SbiParser
: public SbiTokenizer
47 friend class SbiExpression
;
49 SbiParseStack
* pStack
; // Block-Stack
50 SbiProcDef
* pProc
; // aktuelle Prozedur
51 SbiExprNode
* pWithVar
; // aktuelle With-Variable
52 SbiToken eEndTok
; // das Ende-Token
53 UINT32 nGblChain
; // Chainkette fuer globale DIMs
54 BOOL bGblDefs
; // TRUE globale Definitionen allgemein
55 BOOL bNewGblDefs
; // TRUE globale Definitionen vor Sub
56 BOOL bSingleLineIf
; // TRUE einzeiliges if-Statement
57 SbiStatement
* pCurStat
;
59 SbiSymDef
* VarDecl( SbiDimList
**,BOOL
,BOOL
);// Variablen-Deklaration
60 SbiProcDef
* ProcDecl(BOOL bDecl
);// Prozedur-Deklaration
61 void DefStatic( BOOL bPrivate
);
62 void DefProc( BOOL bStatic
, BOOL bPrivate
); // Prozedur einlesen
63 void DefVar( SbiOpcode eOp
, BOOL bStatic
); // DIM/REDIM einlesen
64 void TypeDecl( SbiSymDef
&, BOOL bAsNewAlreadyParsed
=FALSE
); // AS-Deklaration
65 void OpenBlock( SbiToken
, SbiExprNode
* = NULL
); // Block oeffnen
66 void CloseBlock(); // Block aufloesen
67 BOOL
Channel( BOOL
=FALSE
); // Kanalnummer parsen
68 void StmntBlock( SbiToken
); // Statement-Block abarbeiten
69 void DefType( BOOL bPrivate
); // Parse type declaration
70 void DefEnum( BOOL bPrivate
); // Parse enum declaration
71 void DefDeclare( BOOL bPrivate
);
72 void EnableCompatibility();
74 SbxArrayRef rTypeArray
; // das Type-Array
75 SbxArrayRef rEnumArray
; // Enum types
76 SbiStringPool aGblStrings
; // der String-Pool
77 SbiStringPool aLclStrings
; // der String-Pool
78 SbiSymPool aGlobals
; // globale Variable
79 SbiSymPool aPublics
; // modulglobale Variable
80 SbiSymPool aRtlSyms
; // Runtime-Library
81 SbiCodeGen aGen
; // Code-Generator
82 StarBASIC
* pBasic
; // StarBASIC-Instanz
83 SbiSymPool
* pPool
; // aktueller Pool
84 SbiExprType eCurExpr
; // aktueller Expr-Typ
85 short nBase
; // OPTION BASE-Wert
86 BOOL bText
; // OPTION COMPARE TEXT
87 BOOL bExplicit
; // TRUE: OPTION EXPLICIT
88 BOOL bClassModule
; // TRUE: OPTION ClassModule
89 IfaceVector aIfaceVector
; // Holds all interfaces implemented by a class module
90 SbxDataType eDefTypes
[26]; // DEFxxx-Datentypen
92 SbiParser( StarBASIC
*, SbModule
* );
93 BOOL
Parse(); // die Aktion
94 SbiExprNode
* GetWithVar(); // Innerste With-Variable liefern
96 // AB 31.3.1996, Symbol in Runtime-Library suchen
97 SbiSymDef
* CheckRTLForSym( const String
& rSym
, SbxDataType eType
);
98 void AddConstants( void );
100 BOOL
HasGlobalCode(); // Globaler Code definiert?
102 BOOL
TestToken( SbiToken
); // bestimmtes TOken?
103 BOOL
TestSymbol( BOOL
=FALSE
); // Symbol?
104 BOOL
TestComma(); // Komma oder EOLN?
105 void TestEoln(); // EOLN?
106 virtual BOOL
IsSymbol( SbiToken t
); // Process something like DIM Name as String
108 void Symbol(); // Let oder Call
109 void ErrorStmnt(); // ERROR n
110 void NotImp(); // nicht implementiert
111 void BadBlock(); // LOOP/WEND/NEXT
112 void BadSyntax(); // Falsches SbiToken
113 void NoIf(); // ELSE/ELSE IF ohne IF
114 void Assign(); // LET
115 void Attribute(); // Attribute
117 void Close(); // CLOSE
118 void Declare(); // DECLARE
119 void DefXXX(); // DEFxxx
121 void ReDim(); // ReDim();
122 void Erase(); // ERASE
124 void For(); // FOR...NEXT
125 void Goto(); // GOTO / GOSUB
127 void Implements(); // IMPLEMENTS
128 void Input(); // INPUT, INPUT #
129 void LineInput(); // LINE INPUT, LINE INPUT #
131 void Name(); // NAME .. AS ..
132 void On(); // ON ERROR/variable
133 void OnGoto(); // ON...GOTO / GOSUB
135 void Option(); // OPTION
136 void Print(); // PRINT, PRINT #
137 void SubFunc(); // SUB / FUNCTION
138 void Resume(); // RESUME
139 void Return(); // RETURN
141 void DoLoop(); // DO...LOOP
142 void Select(); // SELECT ... CASE
144 void Static(); // STATIC
145 void Stop(); // STOP/SYSTEM
146 void Type(); // TYPE...AS...END TYPE
147 void Enum(); // TYPE...END ENUM
148 void While(); // WHILE/WEND
150 void Write(); // WRITE