/* -*- 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 .
*/
// For decompilation. Numbers and symbols return an empty string.
const OUString& SbiTokenizer::Symbol( SbiToken t )
{ // character token? if( t < FIRSTKWD )
{
aSym = OUString(sal::static_int_cast<sal_Unicode>(t)); return aSym;
} switch( t )
{ case NEG :
aSym = u"-"_ustr; return aSym; case EOS :
aSym = u":/CRLF"_ustr; return aSym; case EOLN :
aSym = u"CRLF"_ustr; return aSym; default: break;
} for( auto& rTok : aTokTable_Basic )
{ if( rTok.t == t )
{
aSym = OStringToOUString(rTok.s, RTL_TEXTENCODING_ASCII_US); return aSym;
}
} const sal_Unicode *p = aSym.getStr(); if (*p <= ' ')
{
aSym = u"???"_ustr;
} return aSym;
}
// Reading in the next token and put it down. // Tokens that don't appear in the token table // are directly returned as a character. // Some words are treated in a special way.
if( bNumber )
{
eCurTok = NUMBER; return eCurTok;
} elseif( ( eScanType == SbxDATE || eScanType == SbxSTRING ) && !bSymbol )
{
eCurTok = FIXSTRING; return eCurTok;
} elseif( aSym.isEmpty() )
{ //something went wrong
bEof = bEos = true;
eCurTok = EOLN; return eCurTok;
} // Special cases of characters that are between "Z" and "a". ICompare() // evaluates the position of these characters in different ways. elseif( aSym[0] == '^' )
{
eCurTok = EXPON; return eCurTok;
} elseif( aSym[0] == '\\' )
{
eCurTok = IDIV; return eCurTok;
} else
{ if( eScanType != SbxVARIANT )
{
eCurTok = SYMBOL; return eCurTok;
} // valid token? short lb = 0; short ub = std::size(aTokTable_Basic)-1; short delta; do
{
delta = (ub - lb) >> 1;
tp = &aTokTable_Basic[ lb + delta ];
sal_Int32 res = aSym.compareToIgnoreAsciiCaseAscii( tp->s );
if( res == 0 )
{ goto special;
} if( res < 0 )
{ if ((ub - lb) == 2)
{
ub = lb;
} else
{
ub = ub - delta;
}
} else
{ if ((ub -lb) == 2)
{
lb = ub;
} else
{
lb = lb + delta;
}
}
} while( delta ); // Symbol? if not >= token
sal_Unicode ch = aSym[0]; if( !BasicCharClass::isAlpha( ch, bCompatible ) && !bSymbol )
{
eCurTok = static_cast<SbiToken>(ch & 0x00FF); return eCurTok;
}
eCurTok = SYMBOL; return eCurTok;
}
special: // #i92642 bool bStartOfLine = (eCurTok == NIL || eCurTok == REM || eCurTok == EOLN ||
eCurTok == THEN || eCurTok == ELSE); // single line If if( !bStartOfLine && (tp->t == NAME || tp->t == LINE) )
{
eCurTok = SYMBOL; return eCurTok;
} elseif( tp->t == TEXT )
{
eCurTok = SYMBOL; return eCurTok;
} // maybe we can expand this for other statements that have parameters // that are keywords ( and those keywords are only used within such // statements ) // what's happening here is that if we come across 'append' ( and we are // not in the middle of parsing a special statement ( like 'Open') // we just treat keyword 'append' as a normal 'SYMBOL'. // Also we accept Dim APPEND elseif ( ( !bInStatement || eCurTok == DIM ) && tp->t == APPEND )
{
eCurTok = SYMBOL; return eCurTok;
} // #i92642: Special LINE token handling -> SbiParser::Line()
// END IF, CASE, SUB, DEF, FUNCTION, TYPE, CLASS, WITH if( tp->t == END )
{ // from 15.3.96, special treatment for END, at Peek() the current // time is lost, so memorize everything and restore after
sal_Int32 nOldLine = nLine;
sal_Int32 nOldCol = nCol;
sal_Int32 nOldCol1 = nCol1;
sal_Int32 nOldCol2 = nCol2;
OUString aOldSym = aSym;
SaveLine(); // save pLine in the scanner
eCurTok = Peek(); switch( eCurTok )
{ caseIF: Next(); eCurTok = ENDIF; break; case SELECT: Next(); eCurTok = ENDSELECT; break; case SUB: Next(); eCurTok = ENDSUB; break; case FUNCTION: Next(); eCurTok = ENDFUNC; break; case PROPERTY: Next(); eCurTok = ENDPROPERTY; break; case TYPE: Next(); eCurTok = ENDTYPE; break; caseENUM: Next(); eCurTok = ENDENUM; break; case WITH: Next(); eCurTok = ENDWITH; break; default : eCurTok = END; break;
}
nCol1 = nOldCol1; if( eCurTok == END )
{ // reset everything so that token is read completely newly after END
ePush = NIL;
nLine = nOldLine;
nCol = nOldCol;
nCol2 = nOldCol2;
aSym = aOldSym;
RestoreLine();
} return eCurTok;
} // are data types keywords? // there is ERROR(), DATA(), STRING() etc.
eCurTok = tp->t; // AS: data types are keywords if( tp->t == AS )
{
bAs = true;
} else
{ if( bAs )
{
bAs = false;
} elseif( eCurTok >= DATATYPE1 && eCurTok <= DATATYPE2 && (bErrorIsSymbol || eCurTok != ERROR_) )
{
eCurTok = SYMBOL;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.