LibreOffice Module basic (master) 1
scanner.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 <basic/sbxdef.hxx>
24
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.
29
30class StarBASIC;
31
33{
34 OUString aBuf; // input buffer
35 OUString aLine;
36 OUString aSaveLine;
37 sal_Int32 nLineIdx;
38 sal_Int32 nSaveLineIdx;
39 StarBASIC* pBasic; // instance for error callbacks
40
41 void scanAlphanumeric();
42 void scanGoto();
43 bool readLine();
44protected:
45 OUString aSym;
46 OUString aError;
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 "... _"
65 bool bClosingUnderscore; // true: Closing underscore followed by end of line
66 bool bLineEndsWithWhitespace; // true: Line ends with whitespace (BasicCharClass::isWhitespace)
67
69 void GenError( ErrCode );
70public:
71 SbiScanner( OUString , StarBASIC* = nullptr );
72
73 void EnableErrors() { bError = false; }
74 bool IsHash() const { return bHash; }
75 bool IsCompatible() const { return bCompatible; }
76 void SetCompatible( bool b ) { bCompatible = b; } // #118206
77 bool IsVBASupportOn() const { return bVBASupportOn; }
78 bool WhiteSpace() const { return bSpaces; }
79 sal_Int32 GetErrors() const { return nErrors; }
80 sal_Int32 GetLine() const { return nLine; }
81 sal_Int32 GetCol1() const { return nCol1; }
82 void SetCol1( sal_Int32 n ) { nCol1 = n; }
83 StarBASIC* GetBasic() { return pBasic; }
86 void LockColumn();
87 void UnlockColumn();
88 bool DoesColonFollow();
89
90 bool NextSym();
91 const OUString& GetSym() const { return aSym; }
92 SbxDataType GetType() const { return eScanType; }
93 double GetDbl() const { return nVal; }
94};
95
96/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsHash() const
Definition: scanner.hxx:74
bool bInStatement
Definition: scanner.hxx:68
OUString aLine
Definition: scanner.hxx:35
OUString aError
Definition: scanner.hxx:46
void UnlockColumn()
Definition: scanner.cxx:69
sal_Int32 nErrors
Definition: scanner.hxx:51
bool bHash
Definition: scanner.hxx:60
bool bSpaces
Definition: scanner.hxx:58
OUString aBuf
Definition: scanner.hxx:34
bool bSymbol
Definition: scanner.hxx:56
void SetCompatible(bool b)
Definition: scanner.hxx:76
void SetCol1(sal_Int32 n)
Definition: scanner.hxx:82
StarBASIC * pBasic
Definition: scanner.hxx:39
bool bClosingUnderscore
Definition: scanner.hxx:65
bool bAbort
Definition: scanner.hxx:59
bool bVBASupportOn
Definition: scanner.hxx:63
double GetDbl() const
Definition: scanner.hxx:93
bool DoesColonFollow()
Definition: scanner.cxx:110
double nVal
Definition: scanner.hxx:48
bool IsVBASupportOn() const
Definition: scanner.hxx:77
sal_Int32 nColLock
Definition: scanner.hxx:52
SbxDataType GetType() const
Definition: scanner.hxx:92
void EnableErrors()
Definition: scanner.hxx:73
void scanGoto()
Definition: scanner.cxx:158
sal_Int32 nCol
Definition: scanner.hxx:50
sal_Int32 nSavedCol1
Definition: scanner.hxx:49
bool WhiteSpace() const
Definition: scanner.hxx:78
const OUString & GetSym() const
Definition: scanner.hxx:91
void RestoreLine()
Definition: scanner.hxx:85
sal_Int32 nSaveLineIdx
Definition: scanner.hxx:38
sal_Int32 GetCol1() const
Definition: scanner.hxx:81
void scanAlphanumeric()
Definition: scanner.cxx:147
SbiScanner(OUString, StarBASIC *=nullptr)
Definition: scanner.cxx:33
sal_Int32 nBufPos
Definition: scanner.hxx:53
bool bError
Definition: scanner.hxx:61
OUString aSym
Definition: scanner.hxx:45
bool IsCompatible() const
Definition: scanner.hxx:75
bool bPrevLineExtentsComment
Definition: scanner.hxx:64
sal_Int32 GetLine() const
Definition: scanner.hxx:80
sal_Int32 nCol2
Definition: scanner.hxx:55
bool bCompatible
Definition: scanner.hxx:62
StarBASIC * GetBasic()
Definition: scanner.hxx:83
SbxDataType eScanType
Definition: scanner.hxx:47
void GenError(ErrCode)
Definition: scanner.cxx:75
sal_Int32 GetErrors() const
Definition: scanner.hxx:79
bool bLineEndsWithWhitespace
Definition: scanner.hxx:66
sal_Int32 nCol1
Definition: scanner.hxx:55
bool NextSym()
Definition: scanner.cxx:212
bool readLine()
Definition: scanner.cxx:176
OUString aSaveLine
Definition: scanner.hxx:36
void SaveLine()
Definition: scanner.hxx:84
void LockColumn()
Definition: scanner.cxx:63
bool bNumber
Definition: scanner.hxx:57
sal_Int32 nLine
Definition: scanner.hxx:54
sal_Int32 nLineIdx
Definition: scanner.hxx:37
sal_Int64 n
SbxDataType
Definition: sbxdef.hxx:37