Skip to main content

The LexCodeParser Class Reference

LEX code scanner. More...

Declaration

class LexCodeParser { ... }

Included Headers

#include <src/lexcode.h>

Base class

classCodeParserInterface

Abstract interface for code parsers. More...

Public Constructors Index

LexCodeParser ()

Public Destructor Index

~LexCodeParser () override

Public Member Functions Index

voidparseCode (OutputCodeList &codeOutIntf, const QCString &scopeName, const QCString &input, SrcLangExt, bool stripCodeComments, bool isExampleBlock, const QCString &exampleName=QCString(), const FileDef *fileDef=nullptr, int startLine=-1, int endLine=-1, bool inlineFragment=FALSE, const MemberDef *memberDef=nullptr, bool showLineNumbers=TRUE, const Definition *searchCtx=nullptr, bool collectXRefs=TRUE) override

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

voidresetCodeParserState () override

Resets the state of the code parser. More...

Private Member Attributes Index

std::unique_ptr< Private >p

Description

LEX code scanner.

Definition at line 29 of file lexcode.h.

Public Constructors

LexCodeParser()

LexCodeParser::LexCodeParser ()

Declaration at line 32 of file lexcode.h, definition at line 1176 of file lexcode.l.

1176LexCodeParser::LexCodeParser() : p(std::make_unique<Private>())
1177{
1178 lexcodeYYlex_init_extra(&p->state, &p->yyscanner);
1179#ifdef FLEX_DEBUG
1180 lexcodeYYset_debug(Debug::isFlagSet(Debug::Lex_lexcode)?1:0,p->yyscanner);
1181#endif
1183}

References Debug::isFlagSet, Debug::Lex_lexcode, p and resetCodeParserState.

Public Destructor

~LexCodeParser()

LexCodeParser::~LexCodeParser ()

Declaration at line 33 of file lexcode.h, definition at line 1185 of file lexcode.l.

1186{
1187 lexcodeYYlex_destroy(p->yyscanner);
1188}

Reference p.

Public Member Functions

parseCode()

void LexCodeParser::parseCode (OutputCodeList & codeOutList, const QCString & scopeName, const QCString & input, SrcLangExt lang, bool stripCodeComments, bool isExampleBlock, const QCString & exampleName=QCString(), const FileDef * fileDef=nullptr, int startLine=-1, int endLine=-1, bool inlineFragment=FALSE, const MemberDef * memberDef=nullptr, bool showLineNumbers=TRUE, const Definition * searchCtx=nullptr, bool collectXRefs=TRUE)
virtual

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

Parameters
[in] codeOutList

interface for writing the result.

[in] scopeName

Name of scope to which the code belongs.

[in] input

Actual code in the form of a string

[in] lang

The programming language of the code fragment.

[in] stripCodeComments

signals whether or not for the code block the doxygen comments should be stripped.

[in] isExampleBlock

TRUE iff the code is part of an example.

[in] exampleName

Name of the example.

[in] fileDef

File definition to which the code is associated.

[in] startLine

Starting line in case of a code fragment.

[in] endLine

Ending line of the code fragment.

[in] inlineFragment

Code fragment that is to be shown inline as part of the documentation.

[in] memberDef

Member definition to which the code is associated (non null in case of an inline fragment for a member).

[in] showLineNumbers

if set to TRUE and also fileDef is not 0, line numbers will be added to the source fragment

[in] searchCtx

context under which search data has to be stored.

[in] collectXRefs

collect cross-reference relations.

Declaration at line 36 of file lexcode.h, definition at line 1197 of file lexcode.l.

1198 const QCString &scopeName,
1199 const QCString &input,
1201 bool stripCodeComments,
1202 bool isExampleBlock,
1203 const QCString &exampleName,
1204 const FileDef *fileDef,
1205 int startLine,
1206 int endLine,
1207 bool inlineFragment,
1208 const MemberDef *memberDef,
1209 bool showLineNumbers,
1210 const Definition *searchCtx,
1211 bool collectXRefs
1212 )
1213{
1214 yyscan_t yyscanner = p->yyscanner;
1215 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1216
1217 if (input.isEmpty()) return;
1218
1219 DebugLex debugLex(Debug::Lex_lexcode, __FILE__, fileDef ? qPrint(fileDef->fileName()) : nullptr);
1220
1221 yyextra->code = &codeOutIntf;
1222 yyextra->inputString = input.data();
1223 yyextra->inputPosition = 0;
1224 yyextra->fileName = fileDef ? fileDef->fileName():"";
1225 yyextra->currentFontClass = nullptr;
1226 yyextra->insideCodeLine = false;
1227
1228 yyextra->classScope=scopeName;
1229 yyextra->currentMemberDef=memberDef;
1230 yyextra->searchCtx=searchCtx;
1231 yyextra->collectXRefs=collectXRefs;
1232
1233 if (startLine!=-1)
1234 yyextra->yyLineNr = startLine;
1235 else
1236 yyextra->yyLineNr = 1;
1237
1238 if (endLine!=-1)
1239 yyextra->inputLines = endLine+1;
1240 else
1241 yyextra->inputLines = yyextra->yyLineNr + countLines(yyscanner) - 1;
1242
1243 yyextra->startCCodeLine = yyextra->yyLineNr;
1244 yyextra->stripCodeComments = stripCodeComments;
1245 yyextra->exampleBlock = isExampleBlock;
1246 yyextra->exampleName = exampleName;
1247 yyextra->sourceFileDef = fileDef;
1248 yyextra->lineNumbers = fileDef!=0 && showLineNumbers;
1249
1250 if (isExampleBlock && fileDef==0)
1251 {
1252 // create a dummy filedef for the example
1253 yyextra->exampleFileDef = createFileDef(QCString(),!exampleName.isEmpty() ? exampleName : QCString("generated"));
1254 yyextra->sourceFileDef = yyextra->exampleFileDef.get();
1255 }
1256
1257 if (yyextra->sourceFileDef)
1258 {
1259 setCurrentDoc(yyscanner,"l00001");
1260 }
1261
1262 yyextra->includeCodeFragment = inlineFragment;
1263 // Starts line 1 on the output
1264 startCodeLine(yyscanner);
1265
1266 lexcodeYYrestart( nullptr, yyscanner );
1267 BEGIN( DefSection );
1268 lexcodeYYlex(yyscanner);
1269
1270 if (yyextra->insideCodeLine)
1271 {
1272 endCodeLine(yyscanner);
1273 }
1274 if (yyextra->exampleFileDef)
1275 {
1276 // delete the temporary file definition used for this example
1277 yyextra->exampleFileDef.reset();
1278 yyextra->sourceFileDef=0;
1279 }
1280}

References countLines, createFileDef, QCString::data, endCodeLine, FileDef::fileName, QCString::isEmpty, Debug::Lex_lexcode, p, qPrint, setCurrentDoc and startCodeLine.

resetCodeParserState()

void LexCodeParser::resetCodeParserState ()
virtual

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()

Declaration at line 52 of file lexcode.h, definition at line 1190 of file lexcode.l.

1191{
1192 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
1193 yyextra->currentDefinition = nullptr;
1194 yyextra->currentMemberDef = nullptr;
1195}

Reference p.

Referenced by LexCodeParser.

Private Member Attributes

p

std::unique_ptr<Private> LexCodeParser::p

Definition at line 55 of file lexcode.h.

55 std::unique_ptr<Private> p;

Referenced by LexCodeParser, parseCode, resetCodeParserState and ~LexCodeParser.


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


Generated via doxygen2docusaurus by Doxygen 1.14.0.