Files
libreoffice/basic/source/comp/scanner.cxx

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

675 lines
20 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2000-09-18 15:18:56 +00:00
#include <basiccharclass.hxx>
#include <scanner.hxx>
#include <sbintern.hxx>
#include <runtime.hxx>
2000-09-18 15:18:56 +00:00
#include <i18nlangtag/lang.h>
#include <svl/zforlist.hxx>
2011-11-17 23:06:47 -05:00
#include <vcl/svapp.hxx>
#include <rtl/character.hxx>
2000-09-18 15:18:56 +00:00
SbiScanner::SbiScanner( const OUString& rBuf, StarBASIC* p ) : aBuf( rBuf )
2000-09-18 15:18:56 +00:00
{
pBasic = p;
nLineIdx = -1;
2000-09-18 15:18:56 +00:00
nVal = 0;
eScanType = SbxVARIANT;
nErrors = 0;
nBufPos = 0;
nSavedCol1 = 0;
nColLock = 0;
nLine = 0;
nCol1 = 0;
nCol2 = 0;
2000-09-18 15:18:56 +00:00
nCol = 0;
bError =
bAbort =
bSpaces =
bNumber =
bSymbol =
bCompatible =
bVBASupportOn =
bInStatement =
bPrevLineExtentsComment = false;
bHash = true;
nSaveLineIdx = -1;
2000-09-18 15:18:56 +00:00
}
void SbiScanner::LockColumn()
{
if( !nColLock++ )
nSavedCol1 = nCol1;
}
void SbiScanner::UnlockColumn()
{
if( nColLock )
nColLock--;
}
void SbiScanner::GenError( ErrCode code )
2000-09-18 15:18:56 +00:00
{
if( GetSbData()->bBlockCompilerError )
{
2011-11-18 01:53:30 -05:00
bAbort = true;
return;
}
if( !bError )
2000-09-18 15:18:56 +00:00
{
2011-11-18 01:53:30 -05:00
bool bRes = true;
// report only one error per statement
2011-11-18 01:53:30 -05:00
bError = true;
2000-09-18 15:18:56 +00:00
if( pBasic )
{
// in case of EXPECTED or UNEXPECTED it always refers
// to the last token, so take the Col1 over
2011-12-05 17:41:28 -05:00
sal_Int32 nc = nColLock ? nSavedCol1 : nCol1;
if ( code.anyOf(
ERRCODE_BASIC_EXPECTED,
ERRCODE_BASIC_UNEXPECTED,
ERRCODE_BASIC_SYMBOL_EXPECTED,
ERRCODE_BASIC_LABEL_EXPECTED) )
2000-09-18 15:18:56 +00:00
{
nc = nCol1;
if( nc > nCol2 ) nCol2 = nc;
}
bRes = pBasic->CError( code, aError, nLine, nc, nCol2 );
}
bAbort = bAbort || !bRes || ( code == ERRCODE_BASIC_NO_MEMORY || code == ERRCODE_BASIC_PROG_TOO_LARGE );
2000-09-18 15:18:56 +00:00
}
nErrors++;
2000-09-18 15:18:56 +00:00
}
// used by SbiTokenizer::MayBeLabel() to detect a label
2011-11-18 01:53:30 -05:00
bool SbiScanner::DoesColonFollow()
2000-09-18 15:18:56 +00:00
{
2012-01-07 20:18:35 -05:00
if(nCol < aLine.getLength() && aLine[nCol] == ':')
2000-09-18 15:18:56 +00:00
{
++nLineIdx; ++nCol;
2011-11-18 01:53:30 -05:00
return true;
2000-09-18 15:18:56 +00:00
}
2011-11-18 01:53:30 -05:00
else
return false;
2000-09-18 15:18:56 +00:00
}
// test for legal suffix
2000-09-18 15:18:56 +00:00
static SbxDataType GetSuffixType( sal_Unicode c )
{
2011-11-18 01:20:36 -05:00
switch (c)
2000-09-18 15:18:56 +00:00
{
2011-11-18 01:20:36 -05:00
case '%':
return SbxINTEGER;
2011-11-18 01:20:36 -05:00
case '&':
return SbxLONG;
2011-11-18 01:20:36 -05:00
case '!':
return SbxSINGLE;
2011-11-18 01:20:36 -05:00
case '#':
return SbxDOUBLE;
2011-11-18 01:20:36 -05:00
case '@':
return SbxCURRENCY;
2011-11-18 01:20:36 -05:00
case '$':
return SbxSTRING;
2011-11-18 01:20:36 -05:00
default:
return SbxVARIANT;
2000-09-18 15:18:56 +00:00
}
}
// reading the next symbol into the variables aSym, nVal and eType
// return value is sal_False at EOF or errors
2000-09-18 15:18:56 +00:00
#define BUF_SIZE 80
2011-12-04 22:13:24 -05:00
void SbiScanner::scanAlphanumeric()
{
2011-12-05 17:41:28 -05:00
sal_Int32 n = nCol;
while(nCol < aLine.getLength() && (BasicCharClass::isAlphaNumeric(aLine[nCol], bCompatible) || aLine[nCol] == '_'))
2011-12-04 22:13:24 -05:00
{
++nLineIdx;
2012-01-09 00:24:54 -05:00
++nCol;
2011-12-04 22:13:24 -05:00
}
aSym = aLine.copy(n, nCol - n);
}
2011-11-18 21:27:44 -05:00
void SbiScanner::scanGoto()
{
2012-01-07 18:32:47 -05:00
sal_Int32 n = nCol;
while(n < aLine.getLength() && BasicCharClass::isWhitespace(aLine[n]))
2012-01-07 18:32:47 -05:00
++n;
2011-11-18 21:27:44 -05:00
2012-01-07 18:32:47 -05:00
if(n + 1 < aLine.getLength())
2011-11-18 21:27:44 -05:00
{
OUString aTemp = aLine.copy(n, 2);
if(aTemp.equalsIgnoreAsciiCase("to"))
2011-11-18 21:27:44 -05:00
{
aSym = "goto";
nLineIdx += n + 2 - nCol;
2012-01-07 18:32:47 -05:00
nCol = n + 2;
2011-11-18 21:27:44 -05:00
}
}
}
2012-01-07 18:23:45 -05:00
bool SbiScanner::readLine()
{
if(nBufPos >= aBuf.getLength())
return false;
sal_Int32 n = nBufPos;
sal_Int32 nLen = aBuf.getLength();
while(n < nLen && aBuf[n] != '\r' && aBuf[n] != '\n')
++n;
// Trim trailing whitespace
sal_Int32 nEnd = n;
while(nBufPos < nEnd && BasicCharClass::isWhitespace(aBuf[nEnd - 1]))
2012-01-07 18:23:45 -05:00
--nEnd;
aLine = aBuf.copy(nBufPos, nEnd - nBufPos);
// Fast-forward past the line ending
if(n + 1 < nLen && aBuf[n] == '\r' && aBuf[n + 1] == '\n')
n += 2;
else if(n < nLen)
2012-01-09 00:24:54 -05:00
++n;
2012-01-07 18:23:45 -05:00
nBufPos = n;
nLineIdx = 0;
2012-01-07 18:23:45 -05:00
++nLine;
nCol = nCol1 = nCol2 = 0;
nColLock = 0;
return true;
}
2011-11-18 01:53:30 -05:00
bool SbiScanner::NextSym()
2000-09-18 15:18:56 +00:00
{
// memorize for the EOLN-case
2011-12-05 17:41:28 -05:00
sal_Int32 nOldLine = nLine;
sal_Int32 nOldCol1 = nCol1;
sal_Int32 nOldCol2 = nCol2;
2000-09-18 15:18:56 +00:00
sal_Unicode buf[ BUF_SIZE ], *p = buf;
eScanType = SbxVARIANT;
aSym.clear();
2012-01-09 00:27:16 -05:00
bHash = bSymbol = bNumber = bSpaces = false;
bool bCompilerDirective = false;
2000-09-18 15:18:56 +00:00
// read in line?
if (nLineIdx == -1)
2000-09-18 15:18:56 +00:00
{
2012-01-07 18:23:45 -05:00
if(!readLine())
2011-11-18 01:53:30 -05:00
return false;
2000-09-18 15:18:56 +00:00
2012-01-07 18:23:45 -05:00
nOldLine = nLine;
nOldCol1 = nOldCol2 = 0;
}
const sal_Int32 nLineIdxScanStart = nLineIdx;
if(nCol < aLine.getLength() && BasicCharClass::isWhitespace(aLine[nCol]))
2012-01-09 00:33:45 -05:00
{
bSpaces = true;
while(nCol < aLine.getLength() && BasicCharClass::isWhitespace(aLine[nCol]))
{
++nLineIdx;
++nCol;
}
2012-01-09 00:33:45 -05:00
}
2000-09-18 15:18:56 +00:00
nCol1 = nCol;
// only blank line?
2012-01-07 20:18:35 -05:00
if(nCol >= aLine.getLength())
goto eoln;
2000-09-18 15:18:56 +00:00
if( bPrevLineExtentsComment )
goto PrevLineCommentLbl;
2012-01-07 20:18:35 -05:00
if(nCol < aLine.getLength() && aLine[nCol] == '#')
{
sal_Int32 nLineTempIdx = nLineIdx;
do
{
nLineTempIdx++;
} while (nLineTempIdx < aLine.getLength() && !BasicCharClass::isWhitespace(aLine[nLineTempIdx]) && aLine[nLineTempIdx] != '#');
// leave it if it is a date literal - it will be handled later
if (nLineTempIdx >= aLine.getLength() || aLine[nLineTempIdx] != '#')
{
++nLineIdx;
++nCol;
//ignore compiler directives (# is first non-space character)
if (nOldCol2 == 0)
bCompilerDirective = true;
else
bHash = true;
}
}
2000-09-18 15:18:56 +00:00
// copy character if symbol
if(nCol < aLine.getLength() && (BasicCharClass::isAlpha(aLine[nCol], bCompatible) || aLine[nCol] == '_'))
2000-09-18 15:18:56 +00:00
{
// if there's nothing behind '_' , it's the end of a line!
2012-01-09 00:33:45 -05:00
if(nCol + 1 == aLine.getLength() && aLine[nCol] == '_')
{
// Note that nCol is not incremented here...
++nLineIdx;
2012-01-09 00:33:45 -05:00
goto eoln;
}
2011-11-18 01:53:30 -05:00
bSymbol = true;
2011-12-04 22:13:24 -05:00
scanAlphanumeric();
// Special handling for "go to"
if(nCol < aLine.getLength() && bCompatible && aSym.equalsIgnoreAsciiCase("go"))
2011-11-18 21:27:44 -05:00
scanGoto();
// replace closing '_' by space when end of line is following
// (wrong line continuation otherwise)
if (nCol == aLine.getLength() && aLine[nCol - 1] == '_')
{
// We are going to modify a potentially shared string, so force
// a copy, so that aSym is not modified by the following operation
OUString aSymCopy( aSym.getStr(), aSym.getLength() );
aSym = aSymCopy;
// HACK: modifying a potentially shared string here!
const_cast<sal_Unicode*>(aLine.getStr())[nLineIdx - 1] = ' ';
}
2012-01-09 00:33:45 -05:00
// type recognition?
// don't test the exclamation mark
// if there's a symbol behind it
2012-01-09 00:33:45 -05:00
else if((nCol >= aLine.getLength() || aLine[nCol] != '!') ||
(nCol + 1 >= aLine.getLength() || !BasicCharClass::isAlpha(aLine[nCol + 1], bCompatible)))
2000-09-18 15:18:56 +00:00
{
2012-01-09 00:33:45 -05:00
if(nCol < aLine.getLength())
2000-09-18 15:18:56 +00:00
{
2012-01-14 15:18:39 -05:00
SbxDataType t(GetSuffixType(aLine[nCol]));
2012-01-09 00:33:45 -05:00
if( t != SbxVARIANT )
{
eScanType = t;
++nLineIdx;
2012-01-09 00:33:45 -05:00
++nCol;
}
2000-09-18 15:18:56 +00:00
}
}
}
// read in and convert if number
else if((nCol < aLine.getLength() && rtl::isAsciiDigit(aLine[nCol])) ||
(nCol + 1 < aLine.getLength() && aLine[nCol] == '.' && rtl::isAsciiDigit(aLine[nCol + 1])))
2000-09-18 15:18:56 +00:00
{
short exp = 0;
short dec = 0;
2000-09-18 15:18:56 +00:00
eScanType = SbxDOUBLE;
bool bScanError = false;
2011-11-18 01:53:30 -05:00
bool bBufOverflow = false;
// All this because of 'D' or 'd' floating point type, sigh...
while(!bScanError && nCol < aLine.getLength() && strchr("0123456789.DEde", aLine[nCol]))
2000-09-18 15:18:56 +00:00
{
// from 4.1.1996: buffer full? -> go on scanning empty
2000-09-18 15:18:56 +00:00
if( (p-buf) == (BUF_SIZE-1) )
{
2011-11-18 01:53:30 -05:00
bBufOverflow = true;
++nLineIdx;
++nCol;
2000-09-18 15:18:56 +00:00
continue;
}
// point or exponent?
2012-01-14 18:39:17 -05:00
if(aLine[nCol] == '.')
2000-09-18 15:18:56 +00:00
{
if( ++dec > 1 )
bScanError = true;
2012-01-14 18:39:17 -05:00
else
*p++ = '.';
2000-09-18 15:18:56 +00:00
}
2012-01-14 18:39:17 -05:00
else if(strchr("DdEe", aLine[nCol]))
2000-09-18 15:18:56 +00:00
{
if (++exp > 1)
bScanError = true;
else
2000-09-18 15:18:56 +00:00
{
*p++ = 'E';
if (nCol + 1 < aLine.getLength() && (aLine[nCol+1] == '+' || aLine[nCol+1] == '-'))
{
++nLineIdx;
++nCol;
if( (p-buf) == (BUF_SIZE-1) )
{
bBufOverflow = true;
continue;
}
*p++ = aLine[nCol];
}
2012-01-14 18:39:17 -05:00
}
2000-09-18 15:18:56 +00:00
}
else
{
*p++ = aLine[nCol];
2000-09-18 15:18:56 +00:00
}
++nLineIdx;
++nCol;
2000-09-18 15:18:56 +00:00
}
*p = 0;
2011-11-18 01:53:30 -05:00
aSym = p; bNumber = true;
// For bad characters, scan and parse errors generate only one error.
ErrCode nError = ERRCODE_NONE;
if (bScanError)
{
--nLineIdx;
--nCol;
aError = OUString( aLine[nCol]);
nError = ERRCODE_BASIC_BAD_CHAR_IN_NUMBER;
}
2000-09-18 15:18:56 +00:00
rtl_math_ConversionStatus eStatus = rtl_math_ConversionStatus_Ok;
const sal_Unicode* pParseEnd = buf;
nVal = rtl_math_uStringToDouble( buf, buf+(p-buf), '.', ',', &eStatus, &pParseEnd );
if (pParseEnd != buf+(p-buf))
{
// e.g. "12e" or "12e+", or with bScanError "12d"+"E".
sal_Int32 nChars = buf+(p-buf) - pParseEnd;
nLineIdx -= nChars;
nCol -= nChars;
// For bScanError, nLineIdx and nCol were already decremented, just
// add that character to the parse end.
if (bScanError)
++nChars;
// Copy error position from original string, not the buffer
// replacement where "12dE" => "12EE".
aError = aLine.copy( nCol, nChars);
nError = ERRCODE_BASIC_BAD_CHAR_IN_NUMBER;
}
else if (eStatus != rtl_math_ConversionStatus_Ok)
{
// Keep the scan error and character at position, if any.
if (!nError)
nError = ERRCODE_BASIC_MATH_OVERFLOW;
}
if (nError)
GenError( nError );
2000-09-18 15:18:56 +00:00
if( !dec && !exp )
2000-09-18 15:18:56 +00:00
{
if( nVal >= SbxMININT && nVal <= SbxMAXINT )
eScanType = SbxINTEGER;
else if( nVal >= SbxMINLNG && nVal <= SbxMAXLNG )
eScanType = SbxLONG;
2000-09-18 15:18:56 +00:00
}
2000-09-18 15:18:56 +00:00
if( bBufOverflow )
GenError( ERRCODE_BASIC_MATH_OVERFLOW );
2000-09-18 15:18:56 +00:00
// type recognition?
if( nCol < aLine.getLength() )
2000-09-18 15:18:56 +00:00
{
SbxDataType t(GetSuffixType(aLine[nCol]));
if( t != SbxVARIANT )
{
eScanType = t;
++nLineIdx;
++nCol;
}
}
2000-09-18 15:18:56 +00:00
}
// Hex/octal number? Read in and convert:
else if(aLine.getLength() - nCol > 1 && aLine[nCol] == '&')
2000-09-18 15:18:56 +00:00
{
++nLineIdx; ++nCol;
2000-09-18 15:18:56 +00:00
sal_Unicode base = 16;
sal_Unicode xch = aLine[nCol];
++nLineIdx; ++nCol;
switch( rtl::toAsciiUpperCase( xch ) )
2000-09-18 15:18:56 +00:00
{
case 'O':
base = 8;
break;
2000-09-18 15:18:56 +00:00
case 'H':
break;
default :
// treated as an operator
--nLineIdx; --nCol; nCol1 = nCol-1;
aSym = "&";
return true;
2000-09-18 15:18:56 +00:00
}
2011-11-18 01:53:30 -05:00
bNumber = true;
// Hex literals are signed Integers ( as defined by basic
// e.g. -2,147,483,648 through 2,147,483,647 (signed)
sal_uInt64 lu = 0;
bool bOverflow = false;
while(nCol < aLine.getLength() && BasicCharClass::isAlphaNumeric(aLine[nCol], false))
2000-09-18 15:18:56 +00:00
{
sal_Unicode ch = rtl::toAsciiUpperCase(aLine[nCol]);
++nLineIdx; ++nCol;
if( ((base == 16 ) && rtl::isAsciiHexDigit( ch ) ) ||
((base == 8) && rtl::isAsciiOctalDigit( ch )))
{
int i = ch - '0';
if( i > 9 ) i -= 7;
lu = ( lu * base ) + i;
if( lu > SAL_MAX_UINT32 )
{
bOverflow = true;
}
}
2000-09-18 15:18:56 +00:00
else
{
aError = OUString(ch);
GenError( ERRCODE_BASIC_BAD_CHAR_IN_NUMBER );
2000-09-18 15:18:56 +00:00
}
}
if(nCol < aLine.getLength() && aLine[nCol] == '&')
{
++nLineIdx;
++nCol;
}
// tdf#62326 - If the value of the hex string lies within the range of 0x8000 (SbxMAXINT + 1)
// and 0xFFFF (SbxMAXUINT) inclusive, cast the value to 16 bit in order to get
// signed integers, e.g., SbxMININT through SbxMAXINT
sal_Int32 ls = (lu > SbxMAXINT && lu <= SbxMAXUINT) ? static_cast<sal_Int16>(lu) : static_cast<sal_Int32>(lu);
nVal = static_cast<double>(ls);
eScanType = ( ls >= SbxMININT && ls <= SbxMAXINT ) ? SbxINTEGER : SbxLONG;
if( bOverflow )
GenError( ERRCODE_BASIC_MATH_OVERFLOW );
2000-09-18 15:18:56 +00:00
}
// Strings:
else if (nLineIdx < aLine.getLength() && (aLine[nLineIdx] == '"' || aLine[nLineIdx] == '['))
2000-09-18 15:18:56 +00:00
{
sal_Unicode cSep = aLine[nLineIdx];
2000-09-18 15:18:56 +00:00
if( cSep == '[' )
{
bSymbol = true;
cSep = ']';
}
2011-12-05 17:41:28 -05:00
sal_Int32 n = nCol + 1;
while (nLineIdx < aLine.getLength())
2000-09-18 15:18:56 +00:00
{
do
{
nLineIdx++;
nCol++;
}
while (nLineIdx < aLine.getLength() && (aLine[nLineIdx] != cSep));
if (nLineIdx < aLine.getLength() && aLine[nLineIdx] == cSep)
2000-09-18 15:18:56 +00:00
{
nLineIdx++; nCol++;
if (nLineIdx >= aLine.getLength() || aLine[nLineIdx] != cSep || cSep == ']')
{
// If VBA Interop then doesn't eat the [] chars
if ( cSep == ']' && bVBASupportOn )
aSym = aLine.copy( n - 1, nCol - n + 1);
else
aSym = aLine.copy( n, nCol - n - 1 );
// get out duplicate string delimiters
OUStringBuffer aSymBuf(aSym.getLength());
for ( sal_Int32 i = 0, len = aSym.getLength(); i < len; ++i )
{
aSymBuf.append( aSym[i] );
if ( aSym[i] == cSep && ( i+1 < len ) && aSym[i+1] == cSep )
++i;
}
aSym = aSymBuf.makeStringAndClear();
if( cSep != ']' )
eScanType = SbxSTRING;
break;
}
}
else
{
aError = OUString(cSep);
GenError( ERRCODE_BASIC_EXPECTED );
}
2000-09-18 15:18:56 +00:00
}
}
// Date:
else if (nLineIdx < aLine.getLength() && aLine[nLineIdx] == '#')
{
sal_Int32 n = nCol + 1;
do
{
nLineIdx++;
nCol++;
}
while (nLineIdx < aLine.getLength() && (aLine[nLineIdx] != '#'));
if (nLineIdx < aLine.getLength() && aLine[nLineIdx] == '#')
{
nLineIdx++; nCol++;
aSym = aLine.copy( n, nCol - n - 1 );
// parse date literal
std::shared_ptr<SvNumberFormatter> pFormatter;
if (GetSbData()->pInst)
{
pFormatter = GetSbData()->pInst->GetNumberFormatter();
}
else
{
sal_uInt32 nDummy;
pFormatter = SbiInstance::PrepareNumberFormatter( nDummy, nDummy, nDummy );
}
sal_uInt32 nIndex = pFormatter->GetStandardIndex( LANGUAGE_ENGLISH_US);
bool bSuccess = pFormatter->IsNumberFormat(aSym, nIndex, nVal);
if( bSuccess )
{
SvNumFormatType nType_ = pFormatter->GetType(nIndex);
if( !(nType_ & SvNumFormatType::DATE) )
bSuccess = false;
}
if (!bSuccess)
GenError( ERRCODE_BASIC_CONVERSION );
bNumber = true;
eScanType = SbxDOUBLE;
}
else
{
aError = OUString('#');
GenError( ERRCODE_BASIC_EXPECTED );
}
}
// invalid characters:
else if (nLineIdx < aLine.getLength() && aLine[nLineIdx] >= 0x7F)
2000-09-18 15:18:56 +00:00
{
GenError( ERRCODE_BASIC_SYNTAX ); nLineIdx++; nCol++;
2000-09-18 15:18:56 +00:00
}
// other groups:
2000-09-18 15:18:56 +00:00
else
{
2011-12-05 17:41:28 -05:00
sal_Int32 n = 1;
auto nChar = nLineIdx < aLine.getLength() ? aLine[nLineIdx] : 0;
++nLineIdx;
if (nLineIdx < aLine.getLength())
2000-09-18 15:18:56 +00:00
{
switch (nChar)
{
case '<': if( aLine[nLineIdx] == '>' || aLine[nLineIdx] == '=' ) n = 2; break;
case '>': if( aLine[nLineIdx] == '=' ) n = 2; break;
case ':': if( aLine[nLineIdx] == '=' ) n = 2; break;
}
2000-09-18 15:18:56 +00:00
}
aSym = aLine.copy(nCol, std::min(n, aLine.getLength() - nCol));
nLineIdx += n-1; nCol = nCol + n;
2000-09-18 15:18:56 +00:00
}
nCol2 = nCol-1;
PrevLineCommentLbl:
if( bPrevLineExtentsComment || (eScanType != SbxSTRING &&
( bCompilerDirective ||
aSym.startsWith("'") ||
aSym.equalsIgnoreAsciiCase( "REM" ) ) ) )
2000-09-18 15:18:56 +00:00
{
2011-11-18 01:53:30 -05:00
bPrevLineExtentsComment = false;
aSym = "REM";
sal_Int32 nLen = aLine.getLength() - nLineIdx;
if( bCompatible && aLine[nLineIdx + nLen - 1] == '_' && aLine[nLineIdx + nLen - 2] == ' ' )
2011-11-18 01:53:30 -05:00
bPrevLineExtentsComment = true;
nCol2 = nCol2 + nLen;
nLineIdx = -1;
2000-09-18 15:18:56 +00:00
}
if (nLineIdx == nLineIdxScanStart)
{
GenError( ERRCODE_BASIC_SYMBOL_EXPECTED );
return false;
}
2011-11-18 01:53:30 -05:00
return true;
2000-09-18 15:18:56 +00:00
2000-09-18 15:18:56 +00:00
eoln:
if( nCol && aLine[--nLineIdx] == '_' )
2000-09-18 15:18:56 +00:00
{
nLineIdx = -1;
bool bRes = NextSym();
if( aSym.startsWith(".") )
{
// object _
// .Method
// ^^^ <- spaces is legal in MSO VBA
2011-11-18 01:53:30 -05:00
bSpaces = false;
}
return bRes;
2000-09-18 15:18:56 +00:00
}
else
{
nLineIdx = -1;
2000-09-18 15:18:56 +00:00
nLine = nOldLine;
nCol1 = nOldCol1;
nCol2 = nOldCol2;
aSym = "\n";
2000-09-18 15:18:56 +00:00
nColLock = 0;
2011-11-18 01:53:30 -05:00
return true;
2000-09-18 15:18:56 +00:00
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */