Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / basic / source / inc / scanner.hxx
blob9b03b0adc568b971ca838fa99c145ecd135fa455
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_BASIC_SOURCE_INC_SCANNER_HXX
21 #define INCLUDED_BASIC_SOURCE_INC_SCANNER_HXX
23 #include <basic/sbxdef.hxx>
24 #include <vcl/errcode.hxx>
26 // The scanner is stand-alone, i. e. it can be used from everywhere.
27 // A BASIC-instance is necessary for error messages. Without BASIC
28 // the errors are only counted. Also the BASIC is necessary when an
29 // advanced SBX-variable shall be used for data type recognition etc.
31 class StarBASIC;
33 class SbiScanner
35 OUString aBuf; // input buffer
36 OUString aLine;
37 sal_Int32 nLineIdx;
38 sal_Int32 nSaveLineIdx;
39 StarBASIC* pBasic; // instance for error callbacks
41 void scanAlphanumeric();
42 void scanGoto();
43 bool readLine();
44 protected:
45 OUString aSym;
46 OUString aError;
47 SbxDataType eScanType;
48 double nVal; // numeric value
49 sal_Int32 nSavedCol1;
50 sal_Int32 nCol;
51 sal_Int32 nErrors;
52 sal_Int32 nColLock; // lock counter for Col1
53 sal_Int32 nBufPos;
54 sal_Int32 nLine;
55 sal_Int32 nCol1, nCol2;
56 bool bSymbol; // true: symbol scanned
57 bool bNumber; // true: number scanned
58 bool bSpaces; // true: whitespace before token
59 bool bAbort;
60 bool bHash; // true: # has been read in
61 bool bError; // true: generate error
62 bool bCompatible; // true: OPTION compatible
63 bool bVBASupportOn; // true: OPTION VBASupport 1 otherwise default False
64 bool bPrevLineExtentsComment; // true: Previous line is comment and ends on "... _"
66 bool bInStatement;
67 void GenError( ErrCode );
68 public:
69 SbiScanner( const OUString&, StarBASIC* = nullptr );
71 void EnableErrors() { bError = false; }
72 bool IsHash() const { return bHash; }
73 bool IsCompatible() const { return bCompatible; }
74 void SetCompatible( bool b ) { bCompatible = b; } // #118206
75 bool IsVBASupportOn() const { return bVBASupportOn; }
76 bool WhiteSpace() { return bSpaces; }
77 sal_Int32 GetErrors() const { return nErrors; }
78 sal_Int32 GetLine() const { return nLine; }
79 sal_Int32 GetCol1() const { return nCol1; }
80 void SetCol1( sal_Int32 n ) { nCol1 = n; }
81 StarBASIC* GetBasic() { return pBasic; }
82 void SaveLine() { nSaveLineIdx = nLineIdx; }
83 void RestoreLine() { nLineIdx = nSaveLineIdx; }
84 void LockColumn();
85 void UnlockColumn();
86 bool DoesColonFollow();
88 bool NextSym();
89 const OUString& GetSym() const { return aSym; }
90 SbxDataType GetType() const { return eScanType; }
91 double GetDbl() const { return nVal; }
94 #endif
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */