bool parseOctalLiteral (CodeDocument::Iterator& source) noexcept { if (source.nextChar() != '0') return false; if (! isOctalDigit (source.nextChar())) return false; while (isOctalDigit (source.peekNextChar())) source.skip(); return skipNumberSuffix (source); }
void skipQuotedString (CodeDocument::Iterator& source) noexcept { const juce_wchar quote = source.nextChar(); for (;;) { const juce_wchar c = source.nextChar(); if (c == quote || c == 0) break; if (c == '\\') source.skip(); } }
int parseIdentifier (CodeDocument::Iterator& source) noexcept { int tokenLength = 0; String::CharPointerType::CharType possibleIdentifier [100]; String::CharPointerType possible (possibleIdentifier); while (isIdentifierBody (source.peekNextChar())) { const juce_wchar c = source.nextChar(); if (tokenLength < 20) possible.write (c); ++tokenLength; } if (tokenLength > 1 && tokenLength <= 16) { possible.writeNull(); if (isReservedKeyword (String::CharPointerType (possibleIdentifier), tokenLength)) return CPlusPlusCodeTokeniser::tokenType_builtInKeyword; } return CPlusPlusCodeTokeniser::tokenType_identifier; }
bool parseHexLiteral (CodeDocument::Iterator& source) noexcept { if (source.nextChar() != '0') return false; juce_wchar c = source.nextChar(); if (c != 'x' && c != 'X') return false; int numDigits = 0; while (isHexDigit (source.peekNextChar())) { ++numDigits; source.skip(); } if (numDigits == 0) return false; return skipNumberSuffix (source); }
void skipComment (CodeDocument::Iterator& source) noexcept { bool lastWasStar = false; for (;;) { const juce_wchar c = source.nextChar(); if (c == 0 || (c == '/' && lastWasStar)) break; lastWasStar = (c == '*'); } }
static void skipComment (CodeDocument::Iterator& source) throw() { bool lastWasStar = false; for (;;) { const juce_wchar c = source.nextChar(); if (c == 0 || (c == T('/') && lastWasStar)) break; lastWasStar = (c == '*'); } }
static int parseIdentifier (CodeDocument::Iterator& source) throw() { static const tchar* keywords2Char[] = { T("if"), T("do"), T("or"), 0 }; static const tchar* keywords3Char[] = { T("for"), T("int"), T("new"), T("try"), T("xor"), T("and"), T("asm"), T("not"), 0 }; static const tchar* keywords4Char[] = { T("bool"), T("void"), T("this"), T("true"), T("long"), T("else"), T("char"), T("enum"), T("case"), T("goto"), T("auto"), 0 }; static const tchar* keywords5Char[] = { T("while"), T("bitor"), T("break"), T("catch"), T("class"), T("compl"), T("const"), T("false"), T("float"), T("short"), T("throw"), T("union"), T("using"), T("or_eq"), 0 }; static const tchar* keywords6Char[] = { T("return"), T("struct"), T("and_eq"), T("bitand"), T("delete"), T("double"), T("extern"), T("friend"), T("inline"), T("not_eq"), T("public"), T("sizeof"), T("static"), T("signed"), T("switch"), T("typeid"), T("wchar_t"), T("xor_eq"), 0}; static const tchar* keywordsOther[] = { T("const_cast"), T("continue"), T("default"), T("explicit"), T("mutable"), T("namespace"), T("operator"), T("private"), T("protected"), T("register"), T("reinterpret_cast"), T("static_cast"), T("template"), T("typedef"), T("typename"), T("unsigned"), T("virtual"), T("volatile"), T("@implementation"), T("@interface"), T("@end"), T("@synthesize"), T("@dynamic"), T("@public"), T("@private"), T("@property"), T("@protected"), T("@class"), 0 }; int tokenLength = 0; tchar possibleIdentifier [19]; while (isIdentifierBody (source.peekNextChar())) { const tchar c = source.nextChar(); if (tokenLength < numElementsInArray (possibleIdentifier) - 1) possibleIdentifier [tokenLength] = c; ++tokenLength; } if (tokenLength > 1 && tokenLength <= 16) { possibleIdentifier [tokenLength] = 0; const tchar** k; switch (tokenLength) { case 2: k = keywords2Char; break; case 3: k = keywords3Char; break; case 4: k = keywords4Char; break; case 5: k = keywords5Char; break; case 6: k = keywords6Char; break; default: k = keywordsOther; break; } int i = 0; while (k[i] != 0) { if (k[i][0] == possibleIdentifier[0] && CharacterFunctions::compare (k[i], possibleIdentifier) == 0) return CPlusPlusCodeTokeniser::tokenType_builtInKeyword; ++i; } } return CPlusPlusCodeTokeniser::tokenType_identifier; }