Skip to content

Commit

Permalink
Add more support for concepts, requires, and constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
bgeller committed Sep 2, 2022
1 parent cd824eb commit 2849fa9
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/conceptdef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void ConceptDef::writeDocumentation(OutputList &ol)

writeBriefDescription(ol);
writeIncludeFiles(ol);
writeDetailedDescription(ol, theTranslator->trDetailedDescription(), "SOME ANCHOR");
writeDetailedDescription(ol, theTranslator->trDetailedDescription(), QString());

ol.endContents();
endFileWithNavPath(self, ol);
Expand Down Expand Up @@ -228,7 +228,7 @@ void ConceptDef::writeDetailedDescription(OutputList &ol, const QString &title,

ol.pushGeneratorState();
ol.disableAllBut(OutputGenerator::Html);
ol.writeAnchor("", anchor.isEmpty() ? QString("details") : anchor);
ol.writeAnchor(QString(), anchor.isEmpty() ? QString("details") : anchor);
ol.popGeneratorState();

if (! anchor.isEmpty()) {
Expand Down
1 change: 1 addition & 0 deletions src/entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class Entry : public EnableSharedFromThis
enum Sections {
CLASS_SEC = 0x00000001,
NAMESPACE_SEC = 0x00000010,
CONCEPT_SEC = 0x00000020,
COMPOUND_MASK = CLASS_SEC,
SCOPE_MASK = COMPOUND_MASK | NAMESPACE_SEC,

Expand Down
46 changes: 43 additions & 3 deletions src/parser/code_cstyle.l
Original file line number Diff line number Diff line change
Expand Up @@ -2631,6 +2631,16 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\"
g_sharpCount = 0;
}

<Body>"concept"{BN}+ {
QString text = QString::fromUtf8(yytext);

startFontClass("keyword");
codifyLines(text);
endFontClass();

BEGIN(ConceptName);
}

<Body>"using"{BN}+"namespace"{BN}+ {
QString text = QString::fromUtf8(yytext);

Expand All @@ -2641,15 +2651,37 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\"
BEGIN(UsingName);
}

<UsingName>{ID}("::"{ID})* {
<Body>"using"{BN}+ {
QString text = QString::fromUtf8(yytext);

startFontClass("keyword");
codifyLines(text);
endFontClass();

BEGIN(UsingName);
}

<ConceptName>{ID}("::"{ID})* {
QString text = QString::fromUtf8(yytext);
addUsingDirective(text);
generateClassOrGlobalLink(*g_code, text);
}

DBG_CTX((stderr,"** scope stack push CLASSBLOCK\n"));
<ConceptName>"=" {
QString text = QString::fromUtf8(yytext);

codifyLines(text);
BEGIN(Body);
}

<UsingName>{ID}("::"{ID})* {
QString text = QString::fromUtf8(yytext);

addUsingDirective(substitute(text, ".", "::"));
generateClassOrGlobalLink(*g_code, text);

g_scopeStack.push(CLASSBLOCK);
pushScope(text);

BEGIN(Body);
}

Expand Down Expand Up @@ -3832,6 +3864,14 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\"
g_inFunctionTryBlock = true;
}

<CallEnd>"requires" {
QString text = QString::fromUtf8(yytext);

startFontClass("keyword");
g_code->codify(text);
endFontClass();
}

<CallEnd>{ID} {
QString text = QString::fromUtf8(yytext);

Expand Down
2 changes: 1 addition & 1 deletion src/parser/commentscan.l
Original file line number Diff line number Diff line change
Expand Up @@ -3379,10 +3379,10 @@ static bool handleClass(const QString &str, const QStringList &list)

static bool handleConcept(const QString &str, const QStringList &list)
{
(void) str;
(void) list;

bool stop = makeStructuralIndicator(Entry::CONCEPTDOC_SEC);
s_currentCommand = str;
BEGIN( ConceptDocArg1 );

return stop;
Expand Down
22 changes: 19 additions & 3 deletions src/parser/parse_cstyle.l
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ static bool insideCpp = true; // processing C/C++ code

static bool insideCppQuote = false;
static bool insideProtocolList = false;
static bool insideConstraint = false;
static bool s_doxyComment = false;

static int argRoundCount;
Expand Down Expand Up @@ -4507,7 +4508,7 @@ CS_MACRO ("CS_OBJECT_MULTIPLE"|"CS_OBJECT_INTERNAL"|"CS_GADGET"|"CS_GADGET
s_squareGEnum = EntryKey::Initial_Value;
squareCount = 0;

current->appendData(EntryKey::Initial_Value, text[0]);
current->appendData(EntryKey::Initial_Value, text[0]);

BEGIN(GCopySquare);
}
Expand All @@ -4521,7 +4522,7 @@ CS_MACRO ("CS_OBJECT_MULTIPLE"|"CS_OBJECT_INTERNAL"|"CS_GADGET"|"CS_GADGET
s_curlyGEnum = EntryKey::Initial_Value;
curlyCount = 0;

current->appendData(EntryKey::Initial_Value, text[0]);
current->appendData(EntryKey::Initial_Value, text[0]);

BEGIN(GCopyCurly);
}
Expand Down Expand Up @@ -4555,6 +4556,13 @@ CS_MACRO ("CS_OBJECT_MULTIPLE"|"CS_OBJECT_INTERNAL"|"CS_GADGET"|"CS_GADGET
current->setData(EntryKey::Initial_Value, QString());
}

if (insideConstraint) {
current->setData(EntryKey::Constraint, current->getData(EntryKey::Initial_Value));
current->setData(EntryKey::Initial_Value, QString());

insideConstraint = false;
}

BEGIN(lastInitializerContext);

} else if (text[0] == ',' && initBracketCount == 0) {
Expand All @@ -4566,6 +4574,13 @@ CS_MACRO ("CS_OBJECT_MULTIPLE"|"CS_OBJECT_INTERNAL"|"CS_GADGET"|"CS_GADGET
current->setData(EntryKey::Initial_Value, QString());
}

if (insideConstraint) {
current->setData(EntryKey::Constraint, current->getData(EntryKey::Initial_Value));
current->setData(EntryKey::Initial_Value, QString());

insideConstraint = false;
}

BEGIN(lastInitializerContext);

} else {
Expand Down Expand Up @@ -8431,10 +8446,11 @@ CS_MACRO ("CS_OBJECT_MULTIPLE"|"CS_OBJECT_INTERNAL"|"CS_GADGET"|"CS_GADGET

<ConceptName>"=" {
current->startBodyLine = yyLineNr;
current->setData(EntryKey::Initial_Value, "");

current->setData(EntryKey::Initial_Value, QString());
lastInitializerContext = FindMembers;
initBracketCount = 0;
insideConstraint = true;

BEGIN(ReadInitializer);
}
Expand Down

0 comments on commit 2849fa9

Please sign in to comment.