JUCE: CppTokeniserFunctions Struct Reference

JUCE

Classes | Static Public Member Functions | List of all members
CppTokeniserFunctions Struct Reference
juce_gui_extra » code_editor

Class containing some basic functions for simple tokenising of C++ code. More...

`#include <juce_CPlusPlusCodeTokeniserFunctions.h>`

## Classes
struct | StringIterator
| A class that can be passed to the CppTokeniserFunctions functions in order to parse a String. More...

## Static Public Member Functions
static bool | isIdentifierStart (const juce_wchar c) noexcept
static bool | isIdentifierBody (const juce_wchar c) noexcept
static bool | isReservedKeyword (String::CharPointerType token, const int tokenLength) noexcept
template<typename Iterator >
static int | parseIdentifier (Iterator &source) noexcept
template<typename Iterator >
static bool | skipNumberSuffix (Iterator &source)
static bool | isHexDigit (const juce_wchar c) noexcept
template<typename Iterator >
static bool | parseHexLiteral (Iterator &source) noexcept
static bool | isOctalDigit (const juce_wchar c) noexcept
template<typename Iterator >
static bool | parseOctalLiteral (Iterator &source) noexcept
static bool | isDecimalDigit (const juce_wchar c) noexcept
template<typename Iterator >
static bool | parseDecimalLiteral (Iterator &source) noexcept
template<typename Iterator >
static bool | parseFloatLiteral (Iterator &source) noexcept
template<typename Iterator >
static int | parseNumber (Iterator &source)
template<typename Iterator >
static void | skipQuotedString (Iterator &source) noexcept
template<typename Iterator >
static void | skipComment (Iterator &source) noexcept
template<typename Iterator >
static void | skipPreprocessorLine (Iterator &source) noexcept
template<typename Iterator >
static void | skipIfNextCharMatches (Iterator &source, const juce_wchar c) noexcept
template<typename Iterator >
static void | skipIfNextCharMatches (Iterator &source, const juce_wchar c1, const juce_wchar c2) noexcept
template<typename Iterator >
static int | readNextToken (Iterator &source)
static void | writeEscapeChars (OutputStream &out, const char *utf8, const int numBytesToRead, const int maxCharsOnLine, const bool breakAtNewLines, const bool replaceSingleQuotes, const bool allowStringBreaks)
| Takes a UTF8 string and writes it to a stream using standard C++ escape sequences for any non-ascii bytes. More...
static String | addEscapeChars (const String &s)
| Takes a string and returns a version of it where standard C++ escape sequences have been used to replace any non-ascii bytes. More...

## Detailed Description

Class containing some basic functions for simple tokenising of C++ code.

## Member Function Documentation

## ◆ isIdentifierStart()

static bool CppTokeniserFunctions::isIdentifierStart | ( | const juce_wchar | c | ) |
| staticnoexcept

References gl::c, and CharacterFunctions::isLetter().

Referenced by readNextToken().

## ◆ isIdentifierBody()

static bool CppTokeniserFunctions::isIdentifierBody | ( | const juce_wchar | c | ) |
| staticnoexcept

References gl::c, and CharacterFunctions::isLetterOrDigit().

Referenced by parseIdentifier().

## ◆ isReservedKeyword()

static bool CppTokeniserFunctions::isReservedKeyword | ( | String::CharPointerType | token,
|  | const int | tokenLength
| ) |  |
| staticnoexcept

Referenced by parseIdentifier().

## ◆ parseIdentifier()

template<typename Iterator >

static int CppTokeniserFunctions::parseIdentifier | ( | Iterator & | source | ) |
| staticnoexcept

References gl::c, isIdentifierBody(), isReservedKeyword(), gl::source, CPlusPlusCodeTokeniser::tokenType_identifier, CPlusPlusCodeTokeniser::tokenType_keyword, CharPointer_UTF8::write(), and CharPointer_UTF8::writeNull().

Referenced by readNextToken().

## ◆ skipNumberSuffix()

template<typename Iterator >

static bool CppTokeniserFunctions::skipNumberSuffix | ( | Iterator & | source | ) |
| static

References gl::c, CharacterFunctions::isLetterOrDigit(), and gl::source.

Referenced by parseDecimalLiteral(), parseHexLiteral(), and parseOctalLiteral().

## ◆ isHexDigit()

static bool CppTokeniserFunctions::isHexDigit | ( | const juce_wchar | c | ) |
| staticnoexcept

References gl::c.

Referenced by parseHexLiteral().

## ◆ parseHexLiteral()

template<typename Iterator >

static bool CppTokeniserFunctions::parseHexLiteral | ( | Iterator & | source | ) |
| staticnoexcept

References gl::c, isHexDigit(), skipNumberSuffix(), and gl::source.

Referenced by parseNumber().

## ◆ isOctalDigit()

static bool CppTokeniserFunctions::isOctalDigit | ( | const juce_wchar | c | ) |
| staticnoexcept

References gl::c.

Referenced by parseOctalLiteral().

## ◆ parseOctalLiteral()

template<typename Iterator >

static bool CppTokeniserFunctions::parseOctalLiteral | ( | Iterator & | source | ) |
| staticnoexcept

References isOctalDigit(), skipNumberSuffix(), and gl::source.

Referenced by parseNumber().

## ◆ isDecimalDigit()

static bool CppTokeniserFunctions::isDecimalDigit | ( | const juce_wchar | c | ) |
| staticnoexcept

References gl::c.

Referenced by parseDecimalLiteral(), and parseFloatLiteral().

## ◆ parseDecimalLiteral()

template<typename Iterator >

static bool CppTokeniserFunctions::parseDecimalLiteral | ( | Iterator & | source | ) |
| staticnoexcept

References isDecimalDigit(), skipNumberSuffix(), and gl::source.

Referenced by parseNumber().

## ◆ parseFloatLiteral()

template<typename Iterator >

static bool CppTokeniserFunctions::parseFloatLiteral | ( | Iterator & | source | ) |
| staticnoexcept

References gl::c, isDecimalDigit(), and gl::source.

Referenced by parseNumber().

## ◆ parseNumber()

template<typename Iterator >

static int CppTokeniserFunctions::parseNumber | ( | Iterator & | source | ) |
| static

References parseDecimalLiteral(), parseFloatLiteral(), parseHexLiteral(), parseOctalLiteral(), gl::source, CPlusPlusCodeTokeniser::tokenType_error, CPlusPlusCodeTokeniser::tokenType_float, and CPlusPlusCodeTokeniser::tokenType_integer.

Referenced by readNextToken().

## ◆ skipQuotedString()

template<typename Iterator >

static void CppTokeniserFunctions::skipQuotedString | ( | Iterator & | source | ) |
| staticnoexcept

References gl::c, and gl::source.

Referenced by readNextToken(), and skipPreprocessorLine().

## ◆ skipComment()

template<typename Iterator >

static void CppTokeniserFunctions::skipComment | ( | Iterator & | source | ) |
| staticnoexcept

References gl::c, and gl::source.

Referenced by readNextToken().

## ◆ skipPreprocessorLine()

template<typename Iterator >

static void CppTokeniserFunctions::skipPreprocessorLine | ( | Iterator & | source | ) |
| staticnoexcept

References gl::c, skipPreprocessorLine(), skipQuotedString(), and gl::source.

Referenced by readNextToken(), and skipPreprocessorLine().

## ◆ skipIfNextCharMatches() [1/2]

template<typename Iterator >

static void CppTokeniserFunctions::skipIfNextCharMatches | ( | Iterator & | source,
|  | const juce_wchar | c
| ) |  |
| staticnoexcept

References gl::c, and gl::source.

Referenced by readNextToken().

## ◆ skipIfNextCharMatches() [2/2]

template<typename Iterator >

static void CppTokeniserFunctions::skipIfNextCharMatches | ( | Iterator & | source,
|  | const juce_wchar | c1,
|  | const juce_wchar | c2
| ) |  |
| staticnoexcept

References gl::c, and gl::source.

## ◆ readNextToken()

template<typename Iterator >

static int CppTokeniserFunctions::readNextToken | ( | Iterator & | source | ) |
| static

References isIdentifierStart(), parseIdentifier(), parseNumber(), gl::result, skipComment(), skipIfNextCharMatches(), skipPreprocessorLine(), skipQuotedString(), gl::source, CPlusPlusCodeTokeniser::tokenType_bracket, CPlusPlusCodeTokeniser::tokenType_comment, CPlusPlusCodeTokeniser::tokenType_error, CPlusPlusCodeTokeniser::tokenType_operator, CPlusPlusCodeTokeniser::tokenType_preprocessor, CPlusPlusCodeTokeniser::tokenType_punctuation, and CPlusPlusCodeTokeniser::tokenType_string.

## ◆ writeEscapeChars()

static void CppTokeniserFunctions::writeEscapeChars | ( | OutputStream & | out,
|  | const char * | utf8,
|  | const int | numBytesToRead,
|  | const int | maxCharsOnLine,
|  | const bool | breakAtNewLines,
|  | const bool | replaceSingleQuotes,
|  | const bool | allowStringBreaks
| ) |  |
| static

Takes a UTF8 string and writes it to a stream using standard C++ escape sequences for any non-ascii bytes.

Although not strictly a tokenising function, this is still a function that often comes in handy when working with C++ code!

Note that addEscapeChars() is easier to use than this function if you're working with Strings.

See also
  addEscapeChars

References gl::c, CharacterFunctions::getHexDigitValue(), JUCE_FALLTHROUGH, newLine, and String::toHexString().

Referenced by addEscapeChars().

## ◆ addEscapeChars()

static String CppTokeniserFunctions::addEscapeChars | ( | const String & | s | ) |
| static

Takes a string and returns a version of it where standard C++ escape sequences have been used to replace any non-ascii bytes.

Although not strictly a tokenising function, this is still a function that often comes in handy when working with C++ code!

See also
  writeEscapeChars

References gl::s, MemoryOutputStream::toString(), and writeEscapeChars().

The documentation for this struct was generated from the following file:

- juce_CPlusPlusCodeTokeniserFunctions.h