| 1 |
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 |
/* |
| 3 |
* This file is part of the LibreOffice project. |
| 4 |
* |
| 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/. |
| 8 |
* |
| 9 |
* This file incorporates work covered by the following license notice: |
| 10 |
* |
| 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 . |
| 18 |
*/ |
| 19 |
|
| 20 |
#pragma once |
| 21 |
|
| 22 |
#include "expr.hxx" |
| 23 |
#include "codegen.hxx" |
| 24 |
#include "symtbl.hxx" |
| 25 |
#include <basic/sbx.hxx> |
| 26 |
|
| 27 |
#include <vector> |
| 28 |
|
| 29 |
struct SbiParseStack; |
| 30 |
|
| 31 |
class SbiParser : public SbiTokenizer |
| 32 |
{ |
| 33 |
friend class SbiExpression; |
| 34 |
|
| 35 |
SbiParseStack* pStack; |
| 36 |
SbiProcDef* pProc; |
| 37 |
SbiExprNode* pWithVar; |
| 38 |
SbiToken eEndTok; |
| 39 |
sal_uInt32 nGblChain; // for global DIMs |
| 40 |
bool bGblDefs; // true: global definitions general |
| 41 |
bool bNewGblDefs; // true: globale definitions before sub |
| 42 |
bool bSingleLineIf; |
| 43 |
bool bCodeCompleting; |
| 44 |
|
| 45 |
SbiSymDef* VarDecl( SbiExprListPtr*, bool, bool ); |
| 46 |
SbiProcDef* ProcDecl(bool bDecl); |
| 47 |
void DefStatic( bool bPrivate ); |
| 48 |
void DefProc( bool bStatic, bool bPrivate ); // read in procedure |
| 49 |
void DefVar( SbiOpcode eOp, bool bStatic ); // read in DIM/REDIM |
| 50 |
void TypeDecl( SbiSymDef&, bool bAsNewAlreadyParsed=false ); // AS-declaration |
| 51 |
void OpenBlock( SbiToken, SbiExprNode* = nullptr ); |
| 52 |
void CloseBlock(); |
| 53 |
bool Channel( bool bAlways=false ); // parse channel number |
| 54 |
void StmntBlock( SbiToken ); |
| 55 |
void DefType(); // Parse type declaration |
| 56 |
void DefEnum( bool bPrivate ); // Parse enum declaration |
| 57 |
void DefDeclare( bool bPrivate ); |
| 58 |
void EnableCompatibility(); |
| 59 |
static bool IsUnoInterface( const OUString& sTypeName ); |
| 60 |
public: |
| 61 |
SbxArrayRef rTypeArray; |
| 62 |
SbxArrayRef rEnumArray; |
| 63 |
SbiStringPool aGblStrings; // string-pool |
| 64 |
SbiStringPool aLclStrings; // string-pool |
| 65 |
SbiSymPool aGlobals; |
| 66 |
SbiSymPool aPublics; // module global |
| 67 |
SbiSymPool aRtlSyms; // Runtime-Library |
| 68 |
SbiCodeGen aGen; // Code-Generator |
| 69 |
SbiSymPool* pPool; |
| 70 |
short nBase; // OPTION BASE-value |
| 71 |
bool bExplicit; // true: OPTION EXPLICIT |
| 72 |
bool bClassModule; // true: OPTION ClassModule |
| 73 |
std::vector<OUString> aIfaceVector; // Holds all interfaces implemented by a class module |
| 74 |
std::vector<OUString> aRequiredTypes; // Types used in Dim As New <type> outside subs |
| 75 |
# define N_DEF_TYPES 26 |
| 76 |
SbxDataType eDefTypes[N_DEF_TYPES]; // DEFxxx data types |
| 77 |
|
| 78 |
SbiParser( StarBASIC*, SbModule* ); |
| 79 |
~SbiParser( ); |
| 80 |
bool Parse(); |
| 81 |
void SetCodeCompleting( bool b ); |
| 82 |
bool IsCodeCompleting() const { return bCodeCompleting;} |
| 83 |
SbiExprNode* GetWithVar(); |
| 84 |
|
| 85 |
// from 31.3.1996, search symbol in the runtime-library |
| 86 |
SbiSymDef* CheckRTLForSym( const OUString& rSym, SbxDataType eType ); |
| 87 |
void AddConstants(); |
| 88 |
|
| 89 |
bool HasGlobalCode(); |
| 90 |
|
| 91 |
bool TestToken( SbiToken ); |
| 92 |
bool TestSymbol(); |
| 93 |
bool TestComma(); |
| 94 |
void TestEoln(); |
| 95 |
|
| 96 |
void Symbol( const KeywordSymbolInfo* pKeywordSymbolInfo ); // let or call |
| 97 |
void ErrorStmnt(); // ERROR n |
| 98 |
void NoIf(); // ELSE/ELSE IF without IF |
| 99 |
void Assign(); // LET |
| 100 |
void Attribute(); |
| 101 |
void Call(); // CALL |
| 102 |
void Close(); // CLOSE |
| 103 |
void Declare(); // DECLARE |
| 104 |
void DefXXX(); // DEFxxx |
| 105 |
void Dim(); // DIM |
| 106 |
void ReDim(); // ReDim(); |
| 107 |
void Erase(); // ERASE |
| 108 |
void Exit(); // EXIT |
| 109 |
void For(); // FOR...NEXT |
| 110 |
void Goto(); // GOTO / GOSUB |
| 111 |
void If(); // IF |
| 112 |
void Implements(); // IMPLEMENTS |
| 113 |
void Input(); // INPUT, INPUT # |
| 114 |
void Line(); // LINE -> LINE INPUT [#] (#i92642) |
| 115 |
void LineInput(); // LINE INPUT, LINE INPUT # |
| 116 |
void LSet(); // LSET |
| 117 |
void Name(); // NAME .. AS .. |
| 118 |
void On(); // ON ERROR/variable |
| 119 |
void OnGoto(); // ON...GOTO / GOSUB |
| 120 |
void Open(); // OPEN |
| 121 |
void Option(); // OPTION |
| 122 |
void Print(); // PRINT, PRINT # |
| 123 |
void SubFunc(); // SUB / FUNCTION |
| 124 |
void Resume(); // RESUME |
| 125 |
void Return(); // RETURN |
| 126 |
void RSet(); // RSET |
| 127 |
void DoLoop(); // DO...LOOP |
| 128 |
void Select(); // SELECT ... CASE |
| 129 |
void Set(); // SET |
| 130 |
void Static(); // STATIC |
| 131 |
void Stop(); // STOP/SYSTEM |
| 132 |
void Type(); // TYPE...AS...END TYPE |
| 133 |
void Enum(); // TYPE...END ENUM |
| 134 |
void While(); // WHILE/WEND |
| 135 |
void With(); // WITH |
| 136 |
void Write(); // WRITE |
| 137 |
}; |
| 138 |
|
| 139 |
|
| 140 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |