Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
Preprocessor Class Reference

#include <preprocessor.h>

+ Inheritance diagram for Preprocessor:
+ Collaboration diagram for Preprocessor:

Public Types

enum  TokenizeMode {
  TokenizeCpp , TokenizePreprocessor , PreparePreprocessorStatement , TokenizePreprocessorStatement ,
  TokenizeInclude , PrepareDefine , TokenizeDefine
}
 

Public Member Functions

 Preprocessor ()
 
QByteArray resolveInclude (const QByteArray &filename, const QByteArray &relativeTo)
 
Symbols preprocessed (const QByteArray &filename, QFile *device)
 
void parseDefineArguments (Macro *m)
 
void skipUntilEndif ()
 
bool skipBranch ()
 
void substituteUntilNewline (Symbols &substituted)
 
int evaluateCondition ()
 
void setDebugIncludes (bool value)
 
- Public Member Functions inherited from Parser
 Parser ()
 
bool hasNext () const
 
Token next ()
 
Token peek ()
 
bool test (Token)
 
void next (Token)
 
void next (Token, const char *msg)
 
void prev ()
 
Token lookup (int k=1)
 
const Symbolsymbol_lookup (int k=1)
 
Token token ()
 
QByteArray lexem ()
 
QByteArray unquotedLexem ()
 
const Symbolsymbol ()
 
const SymbolsymbolAt (qsizetype idx)
 
Q_NORETURN void error (const Symbol &symbol)
 
Q_NORETURN void error (const char *msg=nullptr)
 
void warning (const char *=nullptr)
 
void warning (const Symbol &sym, QByteArrayView msg)
 
void note (const char *=nullptr)
 
void defaultErrorMsg (const Symbol &sym)
 
void printMsg (QByteArrayView formatStringSuffix, QByteArrayView msg, const Symbol &sym)
 
 Parser (const QString &provider)
 
void addIncludeDirs (const QStringList &list)
 
QString resolveInclude (const QString &filename)
 
void addIncludesRecursive (const QString &filename, QStringList &includes)
 
QStringList findEnumValues (const QString &name, const QStringList &includes)
 
void parseParamReplace (const QString &data, qsizetype offset, const QString &name)
 
void parseInstrument (const QString &data, qsizetype offset)
 
void parsePoint (const QString &data, qsizetype offset)
 
void parsePrefix (const QString &data, qsizetype offset)
 
void parseMetadata (const QString &data, qsizetype offset, const QStringList &includes)
 
int lineNumber (qsizetype offset) const
 
void parse (QIODevice &input, const QString &name)
 
void write (QIODevice &input) const
 
bool isEmpty () const
 

Static Public Member Functions

static Symbols macroExpandIdentifier (Preprocessor *that, SymbolStack &symbols, int lineNum, QByteArray *macroName)
 
static void macroExpand (Symbols *into, Preprocessor *that, const Symbols &toExpand, qsizetype &index, int lineNum, bool one, const QSet< QByteArray > &excludeSymbols=QSet< QByteArray >())
 
static Symbols tokenize (const QByteArray &input, int lineNum=1, TokenizeMode mode=TokenizeCpp)
 

Public Attributes

QList< QByteArrayframeworks
 
QSet< QByteArraypreprocessedIncludes
 
QHash< QByteArray, QByteArraynonlocalIncludePathResolutionCache
 
Macros macros
 
- Public Attributes inherited from Parser
Symbols symbols
 
qsizetype index
 
bool displayWarnings
 
bool displayNotes
 
QList< IncludePathincludes
 
std::stack< QByteArray, QByteArrayListcurrentFilenames
 
QList< Functionm_functions
 
QList< Pointm_points
 
QList< Replacem_replaces
 
QList< QStringm_prefixes
 
QList< QStringm_metadata
 
QList< LineNumberm_offsets
 
QList< QStringm_includeDirs
 
QString m_provider
 

Static Public Attributes

static bool preprocessOnly = false
 

Detailed Description

Definition at line 28 of file preprocessor.h.

Member Enumeration Documentation

◆ TokenizeMode

Enumerator
TokenizeCpp 
TokenizePreprocessor 
PreparePreprocessorStatement 
TokenizePreprocessorStatement 
TokenizeInclude 
PrepareDefine 
TokenizeDefine 

Definition at line 53 of file preprocessor.h.

Constructor & Destructor Documentation

◆ Preprocessor()

Preprocessor::Preprocessor ( )
inline

Definition at line 31 of file preprocessor.h.

Member Function Documentation

◆ evaluateCondition()

int Preprocessor::evaluateCondition ( )

Definition at line 949 of file preprocessor.cpp.

References Parser::currentFilenames, substituteUntilNewline(), Parser::symbols, and PP_Expression::value().

+ Here is the call graph for this function:

◆ macroExpand()

void Preprocessor::macroExpand ( Symbols * into,
Preprocessor * that,
const Symbols & toExpand,
qsizetype & index,
int lineNum,
bool one,
const QSet< QByteArray > & excludeSymbols = QSet<QByteArray>() )
static

Definition at line 509 of file preprocessor.cpp.

References Parser::index, macroExpandIdentifier(), QList< T >::size(), Parser::symbols, and SafeSymbols::symbols.

Referenced by macroExpandIdentifier(), and substituteUntilNewline().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ macroExpandIdentifier()

Symbols Preprocessor::macroExpandIdentifier ( Preprocessor * that,
SymbolStack & symbols,
int lineNum,
QByteArray * macroName )
static

Definition at line 550 of file preprocessor.cpp.

References QByteArray::append(), arg, argument, arguments, QList< T >::at(), QSet< T >::cbegin(), QList< T >::cend(), it, Parser::lexem(), Symbol::lexem(), macroExpand(), Parser::next(), Normal, PP_COMMA, PP_IDENTIFIER, PP_LPAREN, PP_RPAREN, PP_WHITESPACE, QByteArray::prepend(), QByteArray(), QByteArray::replace(), QList< T >::size(), Parser::symbols, and Symbol::token.

Referenced by macroExpand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseDefineArguments()

void Preprocessor::parseDefineArguments ( Macro * m)

Definition at line 1275 of file preprocessor.cpp.

References arg, arguments, QByteArray::constData(), QListSpecialMethodsBase< T >::contains(), error, Parser::hasNext(), is_identifier(), Parser::lexem(), Parser::next(), PP_COMMA, PP_IDENTIFIER, PP_RPAREN, PP_WHITESPACE, QByteArray::size(), Parser::symbol(), and Parser::test().

+ Here is the call graph for this function:

◆ preprocessed()

Symbols Preprocessor::preprocessed ( const QByteArray & filename,
QFile * device )

Definition at line 1233 of file preprocessor.cpp.

References cleaned(), file, j, Parser::lexem(), mergeStringLiterals(), readOrMapFile(), QList< T >::size(), QFile::size(), Parser::symbols, Parser::token(), and tokenize().

+ Here is the call graph for this function:

◆ resolveInclude()

QByteArray Preprocessor::resolveInclude ( const QByteArray & filename,
const QByteArray & relativeTo )

Definition at line 1049 of file preprocessor.cpp.

References dir, QHash< Key, T >::end(), QHash< Key, T >::find(), QString::fromLocal8Bit(), Parser::includes, QHash< Key, T >::insert(), it, nonlocalIncludePathResolutionCache, searchIncludePaths(), and QFileInfo::setFile().

+ Here is the call graph for this function:

◆ setDebugIncludes()

void Preprocessor::setDebugIncludes ( bool value)

Definition at line 1329 of file preprocessor.cpp.

◆ skipBranch()

bool Preprocessor::skipBranch ( )

Definition at line 106 of file preprocessor.cpp.

References QList< T >::at(), Parser::index, QList< T >::size(), skipUntilEndif(), Parser::symbols, and Symbol::token.

+ Here is the call graph for this function:

◆ skipUntilEndif()

void Preprocessor::skipUntilEndif ( )

Definition at line 89 of file preprocessor.cpp.

References QList< T >::at(), Parser::index, QList< T >::size(), skipUntilEndif(), Parser::symbols, and Symbol::token.

Referenced by skipBranch(), and skipUntilEndif().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ substituteUntilNewline()

void Preprocessor::substituteUntilNewline ( Symbols & substituted)

Definition at line 701 of file preprocessor.cpp.

References QHash< Key, T >::contains(), Parser::hasNext(), macroExpand(), macros, Parser::next(), PP_IDENTIFIER, PP_LPAREN, PP_NEWLINE, PP_RPAREN, Parser::symbol(), Parser::symbols, Parser::test(), and Parser::token().

Referenced by evaluateCondition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tokenize()

Member Data Documentation

◆ frameworks

QList<QByteArray> Preprocessor::frameworks

Definition at line 33 of file preprocessor.h.

◆ macros

Macros Preprocessor::macros

Definition at line 36 of file preprocessor.h.

Referenced by substituteUntilNewline().

◆ nonlocalIncludePathResolutionCache

QHash<QByteArray, QByteArray> Preprocessor::nonlocalIncludePathResolutionCache

Definition at line 35 of file preprocessor.h.

Referenced by resolveInclude().

◆ preprocessedIncludes

QSet<QByteArray> Preprocessor::preprocessedIncludes

Definition at line 34 of file preprocessor.h.

◆ preprocessOnly

bool Preprocessor::preprocessOnly = false
static

Definition at line 32 of file preprocessor.h.

Referenced by tokenize().


The documentation for this class was generated from the following files: