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
Parser Struct Reference

#include <parser.h>

+ Inheritance diagram for Parser:
+ Collaboration diagram for Parser:

Classes

struct  IncludePath
 

Public Member Functions

 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
 

Public Attributes

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
 

Detailed Description

Definition at line 14 of file parser.h.

Constructor & Destructor Documentation

◆ Parser() [1/2]

Parser::Parser ( )
inline

Definition at line 17 of file parser.h.

◆ Parser() [2/2]

Parser::Parser ( const QString & provider)
inline

Definition at line 39 of file parser.h.

Member Function Documentation

◆ addIncludeDirs()

void Parser::addIncludeDirs ( const QStringList & list)
inline

Definition at line 45 of file parser.h.

References QList< T >::append(), list, and m_includeDirs.

Referenced by main().

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

◆ addIncludesRecursive()

void Parser::addIncludesRecursive ( const QString & filename,
QStringList & includes )

Definition at line 491 of file parser.cpp.

References addIncludesRecursive(), Qt::CaseInsensitive, DEBUGPRINTF, i, includes, info, QString::isEmpty(), line, match(), qPrintable, QStringLiteral, QIODeviceBase::ReadOnly, resolveInclude(), QString::startsWith(), QIODeviceBase::Text, and QString::trimmed().

Referenced by addIncludesRecursive(), and parse().

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

◆ defaultErrorMsg()

void Parser::defaultErrorMsg ( const Symbol & sym)

Definition at line 46 of file parser.cpp.

References QByteArray::data(), Symbol::lexem(), Symbol::lineNum, and printMsg().

Referenced by error(), and error().

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

◆ error() [1/2]

void Parser::error ( const char * msg = nullptr)

Definition at line 60 of file parser.cpp.

References defaultErrorMsg(), error_msg, printMsg(), and symbol().

+ Here is the call graph for this function:

◆ error() [2/2]

void Parser::error ( const Symbol & symbol)

Definition at line 54 of file parser.cpp.

References defaultErrorMsg().

Referenced by Generator::generateCode().

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

◆ findEnumValues()

QStringList Parser::findEnumValues ( const QString & name,
const QStringList & includes )

Definition at line 237 of file parser.cpp.

References begin(), DEBUGPRINTF, i, includes, line, match(), QString::mid(), pos, qPrintable, QStringLiteral, QIODeviceBase::ReadOnly, ret, simplifyData(), QString::split(), split(), QIODeviceBase::Text, and QString::trimmed().

Referenced by parseMetadata().

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

◆ hasNext()

bool Parser::hasNext ( ) const
inline

Definition at line 34 of file parser.h.

References QList< T >::size(), and symbols.

Referenced by Moc::parse(), Preprocessor::parseDefineArguments(), Moc::parseFunctionArguments(), Moc::parseSignals(), Moc::parseSlots(), and Preprocessor::substituteUntilNewline().

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

◆ isEmpty()

bool Parser::isEmpty ( ) const
inline

Definition at line 62 of file parser.h.

References QList< T >::isEmpty(), m_functions, and m_points.

Referenced by main().

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

◆ lexem()

QByteArray Parser::lexem ( )
inline

Definition at line 44 of file parser.h.

References QList< T >::at(), Symbol::lexem(), and symbols.

Referenced by Moc::createPropertyDef(), Preprocessor::macroExpandIdentifier(), Moc::parse(), Moc::parseClassHead(), Moc::parseDeclareInterface(), Preprocessor::parseDefineArguments(), Moc::parseEnum(), Moc::parseEnumOrFlag(), Moc::parseFlag(), Moc::parseFunctionArguments(), Moc::parseInterfaces(), Moc::parsePluginData(), Moc::parsePropertyAccessor(), Moc::parsePropertyAttributes(), Moc::parseSlotInPrivate(), Moc::parseType(), Preprocessor::preprocessed(), PP_Expression::primary_expression(), and Preprocessor::tokenize().

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

◆ lineNumber()

int Parser::lineNumber ( qsizetype offset) const

Definition at line 131 of file parser.cpp.

References QString::begin(), DEBUGPRINTF, QString::end(), line, m_offsets, and QList< T >::size().

Referenced by parse(), and parseParamReplace().

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

◆ lookup()

Token Parser::lookup ( int k = 1)
inline

Definition at line 68 of file parser.h.

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

Referenced by Moc::parse(), Moc::parseClassHead(), Moc::parseEnum(), Moc::parseFunction(), Moc::parseMaybeFunction(), Moc::parseType(), PP_Expression::primary_expression_lookup(), and PP_Expression::unary_expression_lookup().

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

◆ next() [1/3]

◆ next() [2/3]

void Parser::next ( Token token)
inline

Definition at line 74 of file parser.h.

References error, test(), and token().

+ Here is the call graph for this function:

◆ next() [3/3]

void Parser::next ( Token token,
const char * msg )
inline

Definition at line 80 of file parser.h.

References error, test(), and token().

+ Here is the call graph for this function:

◆ note()

void Parser::note ( const char * msg = nullptr)

Definition at line 82 of file parser.cpp.

References displayNotes, printMsg(), and symbol().

+ Here is the call graph for this function:

◆ parse()

void Parser::parse ( QIODevice & input,
const QString & name )

Definition at line 536 of file parser.cpp.

References addIncludesRecursive(), Qt::CaseInsensitive, i, includes, QString::isEmpty(), QString::length(), line, lineNumber(), m_functions, m_offsets, m_replaces, match(), parseInstrument(), parseMetadata(), parseParamReplace(), parsePoint(), parsePrefix(), prev(), QList< T >::push_back(), QStringLiteral, resolveInclude(), simplifyData(), QString::startsWith(), and QString::trimmed().

Referenced by main(), and QQmlJSTypeDescriptionReader::operator()().

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

◆ parseInstrument()

void Parser::parseInstrument ( const QString & data,
qsizetype offset )

Definition at line 159 of file parser.cpp.

References begin(), DEBUGPRINTF, QString::indexOf(), m_functions, m_provider, QString::mid(), QList< T >::push_back(), qPrintable, QStringLiteral, and QString::simplified().

Referenced by parse().

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

◆ parseMetadata()

void Parser::parseMetadata ( const QString & data,
qsizetype offset,
const QStringList & includes )

Definition at line 367 of file parser.cpp.

References QList< T >::append(), QListSpecialMethodsBase< T >::contains(), DEBUGPRINTF, DEBUGPRINTF2, enumsToValues(), findEnumValues(), i, includes, QString::indexOf(), iter, QString::length(), m_metadata, m_provider, match(), QString::mid(), panic(), preprocessMetadata(), prev(), qPrintable, QStringLiteral, and QString::simplified().

Referenced by parse().

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

◆ parseParamReplace()

void Parser::parseParamReplace ( const QString & data,
qsizetype offset,
const QString & name )

Definition at line 142 of file parser.cpp.

References DEBUGPRINTF, QString::indexOf(), lineNumber(), m_replaces, QString::mid(), panic(), QList< T >::push_back(), and qPrintable.

Referenced by parse().

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

◆ parsePoint()

void Parser::parsePoint ( const QString & data,
qsizetype offset )

Definition at line 192 of file parser.cpp.

References DEBUGPRINTF, QString::indexOf(), m_points, m_provider, QString::mid(), Point::name, Point::parameters, QList< T >::push_back(), qPrintable, and QString::simplified().

Referenced by parse().

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

◆ parsePrefix()

void Parser::parsePrefix ( const QString & data,
qsizetype offset )

Definition at line 219 of file parser.cpp.

References QListSpecialMethodsBase< T >::contains(), DEBUGPRINTF, QString::indexOf(), m_prefixes, m_provider, QString::mid(), preprocessMetadata(), QList< T >::push_back(), qPrintable, and QString::simplified().

Referenced by parse().

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

◆ peek()

Token Parser::peek ( )
inline

Definition at line 36 of file parser.h.

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

Referenced by Moc::parsePropertyAccessor().

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

◆ prev()

void Parser::prev ( )
inline

◆ printMsg()

void Parser::printMsg ( QByteArrayView formatStringSuffix,
QByteArrayView msg,
const Symbol & sym )

Base implementation for printing diagnostic messages.

For example: "/path/to/file:line:column: error: %s\n" 's' is replaced by msg. (Currently "column" is always 1).

If sym.lineNum is -1, the line and column parts aren't printed: "/path/to/file: error: %s\n"

formatStringSuffix specifies the type of the message e.g.: "error: %s\n" "warning: %s\n" "note: %s\n" "Parse error at %s\n" (from defaultErrorMsg())

Definition at line 29 of file parser.cpp.

References currentFilenames, QByteArrayView::data(), and Symbol::lineNum.

Referenced by defaultErrorMsg(), error(), note(), and warning().

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

◆ resolveInclude()

QString Parser::resolveInclude ( const QString & filename)

Definition at line 478 of file parser.cpp.

References info, m_includeDirs, and sp.

Referenced by addIncludesRecursive(), and parse().

+ Here is the caller graph for this function:

◆ symbol()

const Symbol & Parser::symbol ( )
inline

Definition at line 46 of file parser.h.

References QList< T >::at(), and symbols.

Referenced by error(), note(), Moc::parse(), Moc::parseClassInfo(), Preprocessor::parseDefineArguments(), Moc::parseEnum(), Moc::parsePropertyAttributes(), Preprocessor::substituteUntilNewline(), and warning().

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

◆ symbol_lookup()

const Symbol & Parser::symbol_lookup ( int k = 1)
inline

Definition at line 42 of file parser.h.

References QList< T >::at(), and symbols.

+ Here is the call graph for this function:

◆ symbolAt()

const Symbol & Parser::symbolAt ( qsizetype idx)
inline

Definition at line 47 of file parser.h.

References QList< T >::at(), and symbols.

Referenced by Moc::checkProperties().

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

◆ test()

◆ token()

Token Parser::token ( )
inline

Definition at line 43 of file parser.h.

References QList< T >::at(), symbols, and Symbol::token.

Referenced by next(), next(), Moc::parseClassHead(), Preprocessor::preprocessed(), Preprocessor::substituteUntilNewline(), test(), and Preprocessor::tokenize().

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

◆ unquotedLexem()

QByteArray Parser::unquotedLexem ( )
inline

Definition at line 45 of file parser.h.

References QList< T >::at(), symbols, and Symbol::unquotedLexem().

Referenced by Moc::parse(), and Moc::parsePluginData().

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

◆ warning() [1/2]

void Parser::warning ( const char * msg = nullptr)

Definition at line 78 of file parser.cpp.

References symbol(), and warning().

Referenced by Moc::checkProperties(), Moc::checkSuperClasses(), Moc::parseFunction(), Moc::parseMaybeFunction(), Moc::parsePluginData(), Moc::parsePropertyAttributes(), Moc::parseSignals(), and warning().

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

◆ warning() [2/2]

void Parser::warning ( const Symbol & sym,
QByteArrayView msg )

Definition at line 72 of file parser.cpp.

References displayWarnings, and printMsg().

+ Here is the call graph for this function:

◆ write()

void Parser::write ( QIODevice & input) const

Definition at line 592 of file parser.cpp.

References m_functions, m_metadata, m_points, m_prefixes, out, QStringLiteral, and QList< T >::size().

Referenced by main().

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

Member Data Documentation

◆ currentFilenames

std::stack<QByteArray, QByteArrayList> Parser::currentFilenames

◆ displayNotes

bool Parser::displayNotes

Definition at line 21 of file parser.h.

Referenced by note().

◆ displayWarnings

bool Parser::displayWarnings

Definition at line 20 of file parser.h.

Referenced by warning().

◆ includes

◆ index

◆ m_functions

QList<Function> Parser::m_functions

Definition at line 67 of file parser.h.

Referenced by isEmpty(), parse(), parseInstrument(), and write().

◆ m_includeDirs

QList<QString> Parser::m_includeDirs

Definition at line 73 of file parser.h.

Referenced by addIncludeDirs(), and resolveInclude().

◆ m_metadata

QList<QString> Parser::m_metadata

Definition at line 71 of file parser.h.

Referenced by parseMetadata(), and write().

◆ m_offsets

QList<LineNumber> Parser::m_offsets

Definition at line 72 of file parser.h.

Referenced by lineNumber(), and parse().

◆ m_points

QList<Point> Parser::m_points

Definition at line 68 of file parser.h.

Referenced by isEmpty(), parsePoint(), and write().

◆ m_prefixes

QList<QString> Parser::m_prefixes

Definition at line 70 of file parser.h.

Referenced by parsePrefix(), and write().

◆ m_provider

QString Parser::m_provider

Definition at line 74 of file parser.h.

Referenced by parseInstrument(), parseMetadata(), parsePoint(), and parsePrefix().

◆ m_replaces

QList<Replace> Parser::m_replaces

Definition at line 69 of file parser.h.

Referenced by parse(), and parseParamReplace().

◆ symbols


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