예제 #1
0
bool CWordBase::IsQuote(const Wtroka& str)
{
    return IsSingleQuote(str) || IsDoubleQuote(str);
}
예제 #2
0
void Scanner::getString()
{
    bool OldIgnoreNewLines;
    tokenString = "";
    nextChar();

    ftoken = CodeTypes::tStringToken;
    while (fch != EOFCHAR)
    {
        // Check for escape characters
        if (fch == '\\')
        {
            nextChar();
            switch (fch)
            {
                case '\\':
                    tokenString = tokenString + '\\';
                    break;
                case 'n':
                    tokenString = tokenString + CR + LF;
                    break;
                case 'r':
                    tokenString = tokenString + CR;
                    break;
                case 'f':
                    tokenString = tokenString + LF;
                    break;
                case 't':
                    tokenString = tokenString + string(' ', 6);
                    break;
                default:
                    throw new ScannerException("Syntax error: Unrecognised control code in string");
            }
            nextChar();
        }
        else
        {
            OldIgnoreNewLines = IgnoreNewLines;
            if (IsDoubleQuote(fch))
            {
                // Just in case the double quote is at the end of a line and another string
                // start immediately in the next line, if we ignore newlines we'll
                // pick up a double quote rather than the end of a string
                IgnoreNewLines = false;
                nextChar();
                if (IsDoubleQuote(fch))
                {
                    tokenString = tokenString + fch;
                    nextChar();
                }
                else
                {
                    if (OldIgnoreNewLines)
                    {
                        while (fch == CR)
                        {
                            nextChar();
                            while (fch == LF)
                                nextChar();
                        }
                    }
                    IgnoreNewLines = OldIgnoreNewLines;
                    return;
                }
            }
            else
            {
                tokenString = tokenString + fch;
                nextChar();
            }
            IgnoreNewLines = OldIgnoreNewLines;
        }
    }
    if (fch == EOFCHAR)
        throw new ScannerException("Syntax error: String without terminating quotation mark");
}
예제 #3
0
bool CWordBase::IsQuote() const
{
    return IsDoubleQuote() || IsSingleQuote();
}