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

SQL scanner. More...

#include <src/sqlcode.h>

+ Inheritance diagram for SQLCodeParser:
+ Collaboration diagram for SQLCodeParser:

Classes

struct  Private
 

Public Member Functions

 SQLCodeParser ()
 
 ~SQLCodeParser () override
 
void parseCode (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.
 
void resetCodeParserState () override
 Resets the state of the code parser.
 
- Public Member Functions inherited from CodeParserInterface

Private Attributes

std::unique_ptr< Privatep
 

Detailed Description

SQL scanner.

Only support syntax highlighting of code at the moment.

Definition at line 29 of file sqlcode.h.

Constructor & Destructor Documentation

◆ SQLCodeParser()

SQLCodeParser::SQLCodeParser ( )

Definition at line 388 of file sqlcode.l.

388 : p(std::make_unique<Private>())
389{
390 sqlcodeYYlex_init_extra(&p->state, &p->yyscanner);
391#ifdef FLEX_DEBUG
392 sqlcodeYYset_debug(Debug::isFlagSet(Debug::Lex_sqlcode)?1:0,p->yyscanner);
393#endif
395}
@ Lex_sqlcode
Definition debug.h:67
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:135
std::unique_ptr< Private > p
Definition sqlcode.h:55
void resetCodeParserState() override
Resets the state of the code parser.
Definition sqlcode.l:402

References Debug::isFlagSet(), Debug::Lex_sqlcode, p, and resetCodeParserState().

◆ ~SQLCodeParser()

SQLCodeParser::~SQLCodeParser ( )
override

Definition at line 397 of file sqlcode.l.

398{
399 sqlcodeYYlex_destroy(p->yyscanner);
400}

References p.

Member Function Documentation

◆ parseCode()

void SQLCodeParser::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 )
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]isExampleBlockTRUE iff the code is part of an example.
[in]exampleNameName of the example.
[in]fileDefFile definition to which the code is associated.
[in]startLineStarting line in case of a code fragment.
[in]endLineEnding line of the code fragment.
[in]inlineFragmentCode fragment that is to be shown inline as part of the documentation.
[in]memberDefMember definition to which the code is associated (non null in case of an inline fragment for a member).
[in]showLineNumbersif set to TRUE and also fileDef is not 0, line numbers will be added to the source fragment
[in]searchCtxcontext under which search data has to be stored.
[in]collectXRefscollect cross-reference relations.

Implements CodeParserInterface.

Definition at line 409 of file sqlcode.l.

425{
426 yyscan_t yyscanner = p->yyscanner;
427 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
428
429 if (input.isEmpty()) return;
430
431 DebugLex debugLex(Debug::Lex_sqlcode, __FILE__, fileDef ? qPrint(fileDef->fileName()): nullptr);
432 yyextra->fileName = fileDef ? fileDef->fileName():"";
433
434 yyextra->code = &codeOutIntf;
435 yyextra->inputString = input.data();
436 yyextra->inputPosition = 0;
437 yyextra->currentFontClass = nullptr;
438 yyextra->insideCodeLine = false;
439 yyextra->searchCtx=searchCtx;
440
441 if (startLine!=-1)
442 yyextra->yyLineNr = startLine;
443 else
444 yyextra->yyLineNr = 1;
445
446 if (endLine!=-1)
447 yyextra->inputLines = endLine+1;
448 else
449 yyextra->inputLines = yyextra->yyLineNr + countLines(yyscanner) - 1;
450
451 yyextra->stripCodeComments = stripCodeComments;
452 yyextra->exampleBlock = isExampleBlock;
453 yyextra->exampleName = exampleName;
454 yyextra->sourceFileDef = fileDef;
455
456 if (isExampleBlock && fileDef==0)
457 {
458 // create a dummy filedef for the example
459 yyextra->exampleFileDef = createFileDef(QCString(),!exampleName.isEmpty() ? exampleName : QCString("generated"));
460 yyextra->sourceFileDef = yyextra->exampleFileDef.get();
461 }
462
463 if (yyextra->sourceFileDef)
464 {
465 setCurrentDoc(yyscanner,"l00001");
466 }
467
468 yyextra->includeCodeFragment = inlineFragment;
469 // Starts line 1 on the output
470 startCodeLine(yyscanner);
471
472 sqlcodeYYrestart( nullptr, yyscanner );
473
474 sqlcodeYYlex(yyscanner);
475
476 if (yyextra->insideCodeLine)
477 {
478 endCodeLine(yyscanner);
479 }
480 if (yyextra->exampleFileDef)
481 {
482 // delete the temporary file definition used for this example
483 yyextra->exampleFileDef.reset();
484 yyextra->sourceFileDef=nullptr;
485 }
486}
virtual QCString fileName() const =0
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
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:159
static void endCodeLine(yyscan_t yyscanner)
Definition code.l:2487
static void startCodeLine(yyscan_t yyscanner)
Definition code.l:2418
static int countLines(yyscan_t yyscanner)
Definition code.l:3471
yyguts_t * yyscan_t
Definition code.l:24
static void setCurrentDoc(yyscan_t yyscanner, const QCString &anchor)
Definition code.l:2280
std::unique_ptr< FileDef > createFileDef(const QCString &p, const QCString &n, const QCString &ref, const QCString &dn)
Definition filedef.cpp:267
const char * qPrint(const char *s)
Definition qcstring.h:672

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

◆ resetCodeParserState()

void SQLCodeParser::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 402 of file sqlcode.l.

403{
404 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
405 yyextra->currentDefinition = nullptr;
406 yyextra->currentMemberDef = nullptr;
407}

References p.

Referenced by SQLCodeParser().

Member Data Documentation

◆ p

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

Definition at line 55 of file sqlcode.h.

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


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