LibreOffice Module basic (master) 1
parser.hxx
Go to the documentation of this file.
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
29struct SbiParseStack;
30
31class SbiParser : public SbiTokenizer
32{
33 friend class SbiExpression;
34
39 sal_uInt32 nGblChain; // for global DIMs
40 bool bGblDefs; // true: global definitions general
41 bool bNewGblDefs; // true: globale definitions before sub
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 );
59 static bool IsUnoInterface( const OUString& sTypeName );
60public:
63 SbiStringPool aGblStrings; // string-pool
64 SbiStringPool aLclStrings; // string-pool
66 SbiSymPool aPublics; // module global
67 SbiSymPool aRtlSyms; // Runtime-Library
68 SbiCodeGen aGen; // Code-Generator
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
79 ~SbiParser( );
80 bool Parse();
81 void SetCodeCompleting( bool b );
82 bool IsCodeCompleting() const { return bCodeCompleting;}
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 BadBlock(); // LOOP/WEND/NEXT
99 void NoIf(); // ELSE/ELSE IF without IF
100 void Assign(); // LET
101 void Attribute();
102 void Call(); // CALL
103 void Close(); // CLOSE
104 void Declare(); // DECLARE
105 void DefXXX(); // DEFxxx
106 void Dim(); // DIM
107 void ReDim(); // ReDim();
108 void Erase(); // ERASE
109 void Exit(); // EXIT
110 void For(); // FOR...NEXT
111 void Goto(); // GOTO / GOSUB
112 void If(); // IF
113 void Implements(); // IMPLEMENTS
114 void Input(); // INPUT, INPUT #
115 void Line(); // LINE -> LINE INPUT [#] (#i92642)
116 void LineInput(); // LINE INPUT, LINE INPUT #
117 void LSet(); // LSET
118 void Name(); // NAME .. AS ..
119 void On(); // ON ERROR/variable
120 void OnGoto(); // ON...GOTO / GOSUB
121 void Open(); // OPEN
122 void Option(); // OPTION
123 void Print(); // PRINT, PRINT #
124 void SubFunc(); // SUB / FUNCTION
125 void Resume(); // RESUME
126 void Return(); // RETURN
127 void RSet(); // RSET
128 void DoLoop(); // DO...LOOP
129 void Select(); // SELECT ... CASE
130 void Set(); // SET
131 void Static(); // STATIC
132 void Stop(); // STOP/SYSTEM
133 void Type(); // TYPE...AS...END TYPE
134 void Enum(); // TYPE...END ENUM
135 void While(); // WHILE/WEND
136 void With(); // WITH
137 void Write(); // WRITE
138};
139
140
141/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SbiSymPool * pPool
Definition: parser.hxx:69
void Implements()
Definition: parser.cxx:713
void Declare()
Definition: dim.cxx:1038
void DefType()
Definition: dim.cxx:603
void DefEnum(bool bPrivate)
Definition: dim.cxx:721
void BadBlock()
Definition: loops.cxx:292
bool HasGlobalCode()
Definition: parser.cxx:185
void Attribute()
Definition: dim.cxx:1160
void On()
Definition: loops.cxx:471
void DefProc(bool bStatic, bool bPrivate)
Definition: dim.cxx:1200
void Set()
Definition: parser.cxx:583
void Exit()
Definition: parser.cxx:230
void LSet()
Definition: parser.cxx:633
void While()
Definition: loops.cxx:194
bool bNewGblDefs
Definition: parser.hxx:41
void Type()
Definition: dim.cxx:598
void Close()
Definition: io.cxx:288
bool TestComma()
Definition: parser.cxx:275
SbxArrayRef rTypeArray
Definition: parser.hxx:61
bool bExplicit
Definition: parser.hxx:71
void StmntBlock(SbiToken)
Definition: parser.cxx:303
bool Parse()
Definition: parser.cxx:322
void Resume()
Definition: loops.cxx:537
void Input()
Definition: io.cxx:146
bool TestToken(SbiToken)
Definition: parser.cxx:261
void TestEoln()
Definition: parser.cxx:293
void OnGoto()
Definition: loops.cxx:302
SbiExprNode * GetWithVar()
Definition: parser.cxx:472
void Select()
Definition: loops.cxx:361
void ReDim()
Definition: dim.cxx:578
SbxDataType eDefTypes[N_DEF_TYPES]
Definition: parser.hxx:76
void Option()
Definition: parser.cxx:763
bool Channel(bool bAlways=false)
Definition: io.cxx:27
static bool IsUnoInterface(const OUString &sTypeName)
Definition: dim.cxx:1349
void Stop()
Definition: parser.cxx:705
void AddConstants()
Definition: parser.cxx:850
bool bClassModule
Definition: parser.hxx:72
sal_uInt32 nGblChain
Definition: parser.hxx:39
void LineInput()
Definition: io.cxx:130
SbiSymPool aPublics
Definition: parser.hxx:66
SbiStringPool aGblStrings
Definition: parser.hxx:63
void SubFunc()
Definition: dim.cxx:1193
void OpenBlock(SbiToken, SbiExprNode *=nullptr)
Definition: parser.cxx:196
void If()
Definition: loops.cxx:28
std::vector< OUString > aRequiredTypes
Definition: parser.hxx:74
SbiSymPool aRtlSyms
Definition: parser.hxx:67
std::vector< OUString > aIfaceVector
Definition: parser.hxx:73
SbxArrayRef rEnumArray
Definition: parser.hxx:62
void For()
Definition: loops.cxx:207
void Static()
Definition: dim.cxx:1310
short nBase
Definition: parser.hxx:70
void Goto()
Definition: loops.cxx:334
void DefVar(SbiOpcode eOp, bool bStatic)
Definition: dim.cxx:202
void TypeDecl(SbiSymDef &, bool bAsNewAlreadyParsed=false)
Definition: dim.cxx:79
void ErrorStmnt()
Definition: parser.cxx:891
void DefDeclare(bool bPrivate)
Definition: dim.cxx:1043
void Erase()
Definition: dim.cxx:585
SbiSymDef * CheckRTLForSym(const OUString &rSym, SbxDataType eType)
Definition: parser.cxx:157
void Symbol(const KeywordSymbolInfo *pKeywordSymbolInfo)
Definition: parser.cxx:491
void Open()
Definition: io.cxx:170
SbiParser(StarBASIC *, SbModule *)
Definition: parser.cxx:118
SbiStringPool aLclStrings
Definition: parser.hxx:64
~SbiParser()
Definition: parser.cxx:154
void DefStatic(bool bPrivate)
Definition: dim.cxx:1315
void Name()
Definition: io.cxx:264
void EnableCompatibility()
Definition: parser.cxx:754
bool bCodeCompleting
Definition: parser.hxx:43
void Return()
Definition: loops.cxx:348
void Write()
Definition: io.cxx:79
SbiSymDef * VarDecl(SbiExprListPtr *, bool, bool)
Definition: dim.cxx:41
SbiProcDef * ProcDecl(bool bDecl)
Definition: dim.cxx:849
bool bSingleLineIf
Definition: parser.hxx:42
bool bGblDefs
Definition: parser.hxx:40
void Assign()
Definition: parser.cxx:562
SbiProcDef * pProc
Definition: parser.hxx:36
void Print()
Definition: io.cxx:48
bool IsCodeCompleting() const
Definition: parser.hxx:82
bool TestSymbol()
Definition: parser.cxx:249
void RSet()
Definition: parser.cxx:653
void Call()
Definition: dim.cxx:1184
void DoLoop()
Definition: loops.cxx:154
void CloseBlock()
Definition: parser.cxx:211
SbiExprNode * pWithVar
Definition: parser.hxx:37
void Dim()
Definition: dim.cxx:197
void NoIf()
Definition: loops.cxx:145
void SetCodeCompleting(bool b)
Definition: parser.cxx:316
SbiParseStack * pStack
Definition: parser.hxx:35
SbiToken eEndTok
Definition: parser.hxx:38
void With()
Definition: loops.cxx:268
void DefXXX()
Definition: parser.cxx:672
SbiCodeGen aGen
Definition: parser.hxx:68
void Line()
Definition: io.cxx:107
SbiSymPool aGlobals
Definition: parser.hxx:65
void Enum()
Definition: dim.cxx:716
std::unique_ptr< SbiExprList > SbiExprListPtr
Definition: expr.hxx:34
SbiOpcode
Definition: opcodes.hxx:25
#define N_DEF_TYPES
Definition: parser.hxx:75
SbxDataType
Definition: sbxdef.hxx:37
SbiToken
Definition: token.hxx:30