Doxygen
Loading...
Searching...
No Matches
CCodeParser Class Referencefinal

#include <src/code.h>

Inheritance diagram for CCodeParser:
Collaboration diagram for CCodeParser:

Classes

struct  Private

Public Member Functions

 CCodeParser ()
 ~CCodeParser () override
void parseCode (OutputCodeList &codeOutIntf, const DString &scopeName, const DString &input, SrcLangExt lang, bool stripCodeComments, const CodeParserOptions &options) override
 Parses a source file or fragment with the goal to produce highlighted and cross-referenced output.
void resetCodeParserState () override
 Resets the state of the code parser.
void setInsideCodeLine (bool inp)
bool insideCodeLine () const

Private Attributes

std::unique_ptr< Privatep

Detailed Description

Definition at line 24 of file code.h.

Constructor & Destructor Documentation

◆ CCodeParser()

CCodeParser::CCodeParser ( )

Definition at line 4056 of file code.l.

4056 : p(std::make_unique<CCodeParser::Private>())
4057{
4058 codeYYlex_init_extra(&p->state,&p->yyscanner);
4059#ifdef FLEX_DEBUG
4060 codeYYset_debug(Debug::isFlagSet(Debug::Lex_code)?1:0,p->yyscanner);
4061#endif
4063}
void resetCodeParserState() override
Resets the state of the code parser.
Definition code.l:4070
std::unique_ptr< Private > p
Definition code.h:42
@ Lex_code
Definition debug.h:54
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:133

References CCodeParser(), Debug::isFlagSet(), Debug::Lex_code, p, and resetCodeParserState().

Referenced by CCodeParser().

◆ ~CCodeParser()

CCodeParser::~CCodeParser ( )
override

Definition at line 4065 of file code.l.

4066{
4067 codeYYlex_destroy(p->yyscanner);
4068}

References p.

Member Function Documentation

◆ insideCodeLine()

bool CCodeParser::insideCodeLine ( ) const

Definition at line 4088 of file code.l.

4089{
4090 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
4091 return yyextra->insideCodeLine;
4092}

References p.

◆ parseCode()

void CCodeParser::parseCode ( OutputCodeList & codeOutList,
const DString & scopeName,
const DString & input,
SrcLangExt lang,
bool stripCodeComments,
const CodeParserOptions & options )
overridevirtual

Parses a source file or fragment with the goal to produce highlighted and cross-referenced output.

Parameters
[in]codeOutListinterface for writing the result.
[in]scopeNameName of scope to which the code belongs.
[in]inputActual code in the form of a string
[in]langThe programming language of the code fragment.
[in]stripCodeCommentssignals whether or not for the code block the doxygen comments should be stripped.
[in]optionsAdditional options to configure the parser.

Implements CodeParserInterface.

Definition at line 4094 of file code.l.

4096{
4097 yyscan_t yyscanner = p->yyscanner;
4098 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4099 DBG_CTX((stderr,"***parseCode() exBlock=%d exName=%s fd=%p scopeName=%s searchCtx=%s\n",
4100 options.isExample(),qPrint(options.exampleName()),(void*)options.fileDef(),
4101 qPrint(scopeName),options.searchCtx()?qPrint(options.searchCtx()->name()):"<none>"));
4102
4103 if (s.empty()) return;
4104
4105 DebugLex debugLex(Debug::Lex_code, __FILE__, options.fileDef() ? qPrint(options.fileDef()->fileName()) :
4106 !options.exampleName().empty() ? qPrint(options.exampleName()) : nullptr);
4107
4108 od.stripCodeComments(stripCodeComments);
4109 yyextra->code = &od;
4110 yyextra->inputString = s.data();
4111 yyextra->fileName = options.fileDef() ? options.fileDef()->fileName():"";
4112 yyextra->absFileName = options.fileDef() ? options.fileDef()->absFilePath():"";
4113 yyextra->inputPosition = 0;
4114 codeYYrestart(nullptr,yyscanner);
4115 yyextra->currentFontClass = nullptr;
4116 yyextra->searchCtx = options.searchCtx();
4117 yyextra->collectXRefs = options.collectXRefs();
4118 yyextra->inFunctionTryBlock = false;
4119 yyextra->symbolResolver.setFileScope(options.fileDef());
4120 yyextra->foldStack.clear();
4121 yyextra->insideSpecialComment = false;
4122 yyextra->yyLineNr = options.startLine()!=-1 ? options.startLine() : 1;
4123 yyextra->inputLines = options.endLine()!=-1 ? options.endLine()+1 : yyextra->yyLineNr + countLines(yyscanner) - 1;
4124 yyextra->curlyCount = 0;
4125 yyextra->bodyCurlyCount = 0;
4126 yyextra->bracketCount = 0;
4127 yyextra->sharpCount = 0;
4128 yyextra->insideTemplate = false;
4129 yyextra->theCallContext.clear();
4130 while (!yyextra->scopeStack.empty()) yyextra->scopeStack.pop();
4131 yyextra->scopeName = scopeName;
4132 DBG_CTX((stderr,"parseCCode %s\n",qPrint(scopeName)));
4133 yyextra->exampleBlock = options.isExample();
4134 yyextra->exampleName = options.exampleName();
4135 yyextra->sourceFileDef = options.fileDef();
4136 yyextra->lineNumbers = options.fileDef() && options.showLineNumbers();
4137 if (options.fileDef()==nullptr)
4138 {
4139 // create a dummy filedef for the example
4140 yyextra->exampleFileDef = createFileDef(DString(),(!options.exampleName().empty()?options.exampleName():"generated"));
4141 yyextra->sourceFileDef = yyextra->exampleFileDef.get();
4142 }
4143 yyextra->lang = lang;
4144 yyextra->insideObjC = lang==SrcLangExt::ObjC;
4145 if (yyextra->sourceFileDef)
4146 {
4147 setCurrentDoc(yyscanner,"l00001");
4148 }
4149 yyextra->currentDefinition = options.searchCtx() ? options.searchCtx() : getResolvedNamespace(scopeName);
4150 yyextra->currentMemberDef = nullptr;
4151 yyextra->searchingForBody = options.isExample();
4152 yyextra->insideBody = false;
4153 yyextra->bracketCount = 0;
4154 if (!yyextra->exampleName.empty())
4155 {
4156 yyextra->exampleFile = convertNameToFile(yyextra->exampleName+"-example",false,true);
4157 DBG_CTX((stderr,"yyextra->exampleFile=%s\n",qPrint(yyextra->exampleFile)));
4158 }
4159 yyextra->includeCodeFragment = options.inlineFragment();
4160 DBG_CTX((stderr,"** exBlock=%d exName=%s include=%d\n",options.isExample(),qPrint(options.exampleName()),options.inlineFragment()));
4161 if (!yyextra->insideCodeLine)
4162 {
4163 startCodeLine(yyscanner);
4164 }
4165 yyextra->type.clear();
4166 yyextra->name.clear();
4167 yyextra->args.clear();
4168 yyextra->parmName.clear();
4169 yyextra->parmType.clear();
4170 if (options.memberDef()) setParameterList(yyscanner,options.memberDef());
4171 BEGIN( Body );
4172 codeYYlex(yyscanner);
4173 yyextra->lexInit=true;
4174 if (yyextra->insideCodeLine)
4175 {
4176 endCodeLine(yyscanner);
4177 }
4178 if (Config_getBool(HTML_CODE_FOLDING))
4179 {
4180 while (!yyextra->foldStack.empty())
4181 {
4182 yyextra->code->endFold();
4183 yyextra->foldStack.pop_back();
4184 }
4185 }
4186 if (yyextra->exampleFileDef)
4187 {
4188 // delete the temporary file definition used for this example
4189 yyextra->exampleFileDef.reset();
4190 yyextra->sourceFileDef=nullptr;
4191 }
4192 // write the tooltips
4193 yyextra->tooltipManager.writeTooltips(od);
4194}
DString()=default
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:152
virtual const DString & name() const =0
virtual DString fileName() const =0
virtual DString absFilePath() const =0
static void endCodeLine(yyscan_t yyscanner)
Definition code.l:2490
#define DBG_CTX(x)
Definition code.l:74
static void startCodeLine(yyscan_t yyscanner)
Definition code.l:2421
static void setCurrentDoc(yyscan_t yyscanner, const DString &anchor)
Definition code.l:2289
static int countLines(yyscan_t yyscanner)
Definition code.l:3476
yyguts_t * yyscan_t
Definition code.l:24
static void setParameterList(yyscan_t yyscanner, const MemberDef *md)
Definition code.l:2635
#define Config_getBool(name)
Definition config.h:33
const char * qPrint(const char *s)
Definition dstring.h:787
std::unique_ptr< FileDef > createFileDef(const DString &p, const DString &n, const DString &ref, const DString &dn)
Definition filedef.cpp:270
NamespaceDef * getResolvedNamespace(const DString &name)
bool isExample() const
Definition parserintf.h:80
const Definition * searchCtx() const
Definition parserintf.h:88
DString exampleName() const
Definition parserintf.h:81
const FileDef * fileDef() const
Definition parserintf.h:82
int endLine() const
Definition parserintf.h:84
const MemberDef * memberDef() const
Definition parserintf.h:86
bool showLineNumbers() const
Definition parserintf.h:87
bool inlineFragment() const
Definition parserintf.h:85
int startLine() const
Definition parserintf.h:83
bool collectXRefs() const
Definition parserintf.h:89
DString convertNameToFile(const DString &name, bool allowDots, bool allowUnderscore)
Definition util.cpp:2865

References FileDef::absFilePath(), CodeParserOptions::collectXRefs(), Config_getBool, convertNameToFile(), countLines(), createFileDef(), DString::data(), DBG_CTX, DString::DString(), DString::empty(), endCodeLine(), CodeParserOptions::endLine(), CodeParserOptions::exampleName(), CodeParserOptions::fileDef(), FileDef::fileName(), getResolvedNamespace(), CodeParserOptions::inlineFragment(), CodeParserOptions::isExample(), Debug::Lex_code, CodeParserOptions::memberDef(), Definition::name(), p, qPrint(), CodeParserOptions::searchCtx(), setCurrentDoc(), setParameterList(), CodeParserOptions::showLineNumbers(), startCodeLine(), CodeParserOptions::startLine(), and OutputCodeList::stripCodeComments().

◆ resetCodeParserState()

void CCodeParser::resetCodeParserState ( )
overridevirtual

Resets the state of the code parser.

Since multiple code fragments can together form a single example, an explicit function is used to reset the code parser state.

See also
parseCode()

Implements CodeParserInterface.

Definition at line 4070 of file code.l.

4071{
4072 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
4073 DBG_CTX((stderr,"***CodeParser::reset()\n"));
4074 yyextra->theVarContext.clear();
4075 while (!yyextra->scopeNameLengthStack.empty()) yyextra->scopeNameLengthStack.pop_back();
4076 yyextra->codeClassMap.clear();
4077 yyextra->curClassBases.clear();
4078 yyextra->anchorCount = 0;
4079 yyextra->insideCodeLine = false;
4080}

References DBG_CTX, and p.

Referenced by CCodeParser().

◆ setInsideCodeLine()

void CCodeParser::setInsideCodeLine ( bool inp)

Definition at line 4082 of file code.l.

4083{
4084 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
4085 yyextra->insideCodeLine = inp;
4086}

References p.

Member Data Documentation

◆ p

std::unique_ptr<Private> CCodeParser::p
private

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