37class CppSyntaxHighlighter :
public QSyntaxHighlighter {
41 explicit CppSyntaxHighlighter(QTextDocument *parent);
44 void highlightBlock(
const QString &text)
override;
49 InBlockCommentState = 1,
52 QTextCharFormat commentFormat_;
53 QTextCharFormat stringFormat_;
54 QTextCharFormat keywordFormat_;
55 QTextCharFormat functionFormat_;
56 QTextCharFormat preprocessorFormat_;
58 std::vector<QRegularExpression> keywordPatterns_;
59 QRegularExpression functionPattern_;
60 QSet<QString> nonFunctionWords_;
62 void markCommentRange(
const QString &text,
int start,
int length,
63 std::vector<bool> *masked);
64 void markStringOrCharLiteral(
const QString &text,
int start,
65 std::vector<bool> *masked,
int *nextIndex);
66 bool isUnmaskedRange(
const std::vector<bool> &masked,
int start,
68 void applyKeywordRules(
const QString &text,
const std::vector<bool> &masked);
69 void applyFunctionRules(
const QString &text,
const std::vector<bool> &masked);
70 void applyPreprocessorRules(
const QString &text, std::vector<bool> *masked);