LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / basic / source / inc / scanner.hxx
blobcc3cbb5d7b41c2fbddcfb7bb968d3a05396cef84
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 #pragma once
22 #include <basic/sbxdef.hxx>
23 #include <vcl/errcode.hxx>
25 // The scanner is stand-alone, i. e. it can be used from everywhere.
26 // A BASIC-instance is necessary for error messages. Without BASIC
27 // the errors are only counted. Also the BASIC is necessary when an
28 // advanced SBX-variable shall be used for data type recognition etc.
30 class StarBASIC;
32 class SbiScanner
34 OUString aBuf; // input buffer
35 OUString aLine;
36 sal_Int32 nLineIdx;
37 sal_Int32 nSaveLineIdx;
38 StarBASIC* pBasic; // instance for error callbacks
40 void scanAlphanumeric();
41 void scanGoto();
42 bool readLine();
43 protected:
44 OUString aSym;
45 OUString aError;
46 SbxDataType eScanType;
47 double nVal; // numeric value
48 sal_Int32 nSavedCol1;
49 sal_Int32 nCol;
50 sal_Int32 nErrors;
51 sal_Int32 nColLock; // lock counter for Col1
52 sal_Int32 nBufPos;
53 sal_Int32 nLine;
54 sal_Int32 nCol1, nCol2;
55 bool bSymbol; // true: symbol scanned
56 bool bNumber; // true: number scanned
57 bool bSpaces; // true: whitespace before token
58 bool bAbort;
59 bool bHash; // true: # has been read in
60 bool bError; // true: generate error
61 bool bCompatible; // true: OPTION compatible
62 bool bVBASupportOn; // true: OPTION VBASupport 1 otherwise default False
63 bool bPrevLineExtentsComment; // true: Previous line is comment and ends on "... _"
64 bool bClosingUnderscore; // true: Closing underscore followed by end of line
65 bool bLineEndsWithWhitespace; // true: Line ends with whitespace (BasicCharClass::isWhitespace)
67 bool bInStatement;
68 void GenError( ErrCode );
69 public:
70 SbiScanner( const OUString&, StarBASIC* = nullptr );
72 void EnableErrors() { bError = false; }
73 bool IsHash() const { return bHash; }
74 bool IsCompatible() const { return bCompatible; }
75 void SetCompatible( bool b ) { bCompatible = b; } // #118206
76 bool IsVBASupportOn() const { return bVBASupportOn; }
77 bool WhiteSpace() const { return bSpaces; }
78 sal_Int32 GetErrors() const { return nErrors; }
79 sal_Int32 GetLine() const { return nLine; }
80 sal_Int32 GetCol1() const { return nCol1; }
81 void SetCol1( sal_Int32 n ) { nCol1 = n; }
82 StarBASIC* GetBasic() { return pBasic; }
83 void SaveLine() { nSaveLineIdx = nLineIdx; }
84 void RestoreLine() { nLineIdx = nSaveLineIdx; }
85 void LockColumn();
86 void UnlockColumn();
87 bool DoesColonFollow();
89 bool NextSym();
90 const OUString& GetSym() const { return aSym; }
91 SbxDataType GetType() const { return eScanType; }
92 double GetDbl() const { return nVal; }
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */