Doxygen
Loading...
Searching...
No Matches
LexCodeParser Class Reference

LEX code scanner. More...

#include <src/lexcode.h>

Inheritance diagram for LexCodeParser:
Collaboration diagram for LexCodeParser:

Classes

struct  Private

Public Member Functions

 LexCodeParser ()
 ~LexCodeParser () override
void parseCode (OutputCodeList &codeOutIntf, const QCString &scopeName, const QCString &input, SrcLangExt, 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.

Private Attributes

std::unique_ptr< Privatep

Detailed Description

LEX code scanner.

Definition at line 29 of file lexcode.h.

Constructor & Destructor Documentation

◆ LexCodeParser()

LexCodeParser::LexCodeParser ( )

Definition at line 1173 of file lexcode.l.

1173 : p(std::make_unique<Private>())
1174{
1175 lexcodeYYlex_init_extra(&p->state, &p->yyscanner);
1176#ifdef FLEX_DEBUG
1177 lexcodeYYset_debug(Debug::isFlagSet(Debug::Lex_lexcode)?1:0,p->yyscanner);
1178#endif
1180}
@ Lex_lexcode
Definition debug.h:62
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:132
std::unique_ptr< Private > p
Definition lexcode.h:46
void resetCodeParserState() override
Resets the state of the code parser.
Definition lexcode.l:1187

References Debug::isFlagSet(), Debug::Lex_lexcode, and p.

◆ ~LexCodeParser()

LexCodeParser::~LexCodeParser ( )
override

Definition at line 1182 of file lexcode.l.

1183{
1184 lexcodeYYlex_destroy(p->yyscanner);
1185}

References p.

Member Function Documentation

◆ parseCode()

void LexCodeParser::parseCode ( OutputCodeList & codeOutList,
const QCString & scopeName,
const QCString & 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 1194 of file lexcode.l.

1201{
1202 yyscan_t yyscanner = p->yyscanner;
1203 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1204
1205 if (input.isEmpty()) return;
1206
1207 DebugLex debugLex(Debug::Lex_lexcode, __FILE__, options.fileDef() ? qPrint(options.fileDef()->fileName()) : nullptr);
1208
1209 yyextra->code = &codeOutIntf;
1210 yyextra->inputString = input.data();
1211 yyextra->inputPosition = 0;
1212 yyextra->fileName = options.fileDef() ? options.fileDef()->fileName():"";
1213 yyextra->currentFontClass = nullptr;
1214 yyextra->insideCodeLine = false;
1215 yyextra->classScope = scopeName;
1216 yyextra->currentMemberDef = options.memberDef();
1217 yyextra->searchCtx = options.searchCtx();
1218 yyextra->collectXRefs = options.collectXRefs();
1219 yyextra->yyLineNr = options.startLine()!=1 ? options.startLine() : 1;
1220 yyextra->inputLines = options.endLine()!=-1 ? options.endLine()+1 : yyextra->yyLineNr + countLines(yyscanner) - 1;
1221 yyextra->startCCodeLine = yyextra->yyLineNr;
1222 yyextra->stripCodeComments = stripCodeComments;
1223 yyextra->exampleBlock = options.isExample();
1224 yyextra->exampleName = options.exampleName();
1225 yyextra->sourceFileDef = options.fileDef();
1226 yyextra->lineNumbers = options.fileDef()!=nullptr && options.showLineNumbers();
1227
1228 if (options.isExample() && options.fileDef()==nullptr)
1229 {
1230 // create a dummy filedef for the example
1231 yyextra->exampleFileDef = createFileDef(QCString(),!options.exampleName().isEmpty() ? options.exampleName() : QCString("generated"));
1232 yyextra->sourceFileDef = yyextra->exampleFileDef.get();
1233 }
1234
1235 if (yyextra->sourceFileDef)
1236 {
1237 setCurrentDoc(yyscanner,"l00001");
1238 }
1239
1240 yyextra->includeCodeFragment = options.inlineFragment();
1241 // Starts line 1 on the output
1242 startCodeLine(yyscanner);
1243
1244 lexcodeYYrestart( nullptr, yyscanner );
1245 BEGIN( DefSection );
1246 lexcodeYYlex(yyscanner);
1247
1248 if (yyextra->insideCodeLine)
1249 {
1250 endCodeLine(yyscanner);
1251 }
1252 if (yyextra->exampleFileDef)
1253 {
1254 // delete the temporary file definition used for this example
1255 yyextra->exampleFileDef.reset();
1256 yyextra->sourceFileDef=0;
1257 }
1258}
virtual QCString fileName() const =0
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:163
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition qcstring.h:172
static void endCodeLine(yyscan_t yyscanner)
Definition code.l:2478
static void startCodeLine(yyscan_t yyscanner)
Definition code.l:2409
static int countLines(yyscan_t yyscanner)
Definition code.l:3462
yyguts_t * yyscan_t
Definition code.l:24
static void setCurrentDoc(yyscan_t yyscanner, const QCString &anchor)
Definition code.l:2277
std::unique_ptr< FileDef > createFileDef(const QCString &p, const QCString &n, const QCString &ref, const QCString &dn)
Definition filedef.cpp:268
const char * qPrint(const char *s)
Definition qcstring.h:687
bool isExample() const
Definition parserintf.h:81
const Definition * searchCtx() const
Definition parserintf.h:89
const FileDef * fileDef() const
Definition parserintf.h:83
int endLine() const
Definition parserintf.h:85
const MemberDef * memberDef() const
Definition parserintf.h:87
bool showLineNumbers() const
Definition parserintf.h:88
bool inlineFragment() const
Definition parserintf.h:86
QCString exampleName() const
Definition parserintf.h:82
int startLine() const
Definition parserintf.h:84
bool collectXRefs() const
Definition parserintf.h:90

References CodeParserOptions::collectXRefs(), countLines(), createFileDef(), QCString::data(), endCodeLine(), CodeParserOptions::endLine(), CodeParserOptions::exampleName(), CodeParserOptions::fileDef(), FileDef::fileName(), CodeParserOptions::inlineFragment(), QCString::isEmpty(), CodeParserOptions::isExample(), Debug::Lex_lexcode, CodeParserOptions::memberDef(), p, qPrint(), CodeParserOptions::searchCtx(), setCurrentDoc(), CodeParserOptions::showLineNumbers(), startCodeLine(), and CodeParserOptions::startLine().

◆ resetCodeParserState()

void LexCodeParser::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 1187 of file lexcode.l.

1188{
1189 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
1190 yyextra->currentDefinition = nullptr;
1191 yyextra->currentMemberDef = nullptr;
1192}

References p.

Member Data Documentation

◆ p

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

Definition at line 46 of file lexcode.h.

Referenced by LexCodeParser(), parseCode(), resetCodeParserState(), and ~LexCodeParser().


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