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, 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

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:68
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:132
std::unique_ptr< Private > p
Definition sqlcode.h:46
void resetCodeParserState() override
Resets the state of the code parser.
Definition sqlcode.l:402

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

◆ ~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,
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 409 of file sqlcode.l.

416{
417 yyscan_t yyscanner = p->yyscanner;
418 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
419
420 if (input.isEmpty()) return;
421
422 DebugLex debugLex(Debug::Lex_sqlcode, __FILE__, options.fileDef() ? qPrint(options.fileDef()->fileName()): nullptr);
423 yyextra->fileName = options.fileDef() ? options.fileDef()->fileName():"";
424 yyextra->code = &codeOutIntf;
425 yyextra->inputString = input.data();
426 yyextra->inputPosition = 0;
427 yyextra->currentFontClass = nullptr;
428 yyextra->insideCodeLine = false;
429 yyextra->searchCtx = options.searchCtx();
430 yyextra->yyLineNr = options.startLine()!=-1 ? options.startLine() : 1;
431 yyextra->inputLines = options.endLine()!=-1 ? options.endLine()+1 : yyextra->yyLineNr + countLines(yyscanner) - 1;
432 yyextra->stripCodeComments = stripCodeComments;
433 yyextra->exampleBlock = options.isExample();
434 yyextra->exampleName = options.exampleName();
435 yyextra->sourceFileDef = options.fileDef();
436 yyextra->lineNumbers = options.fileDef() && options.showLineNumbers();
437
438 if (options.isExample() && options.fileDef()==0)
439 {
440 // create a dummy filedef for the example
441 yyextra->exampleFileDef = createFileDef(QCString(),!options.exampleName().isEmpty() ? options.exampleName() : QCString("generated"));
442 yyextra->sourceFileDef = yyextra->exampleFileDef.get();
443 }
444
445 if (yyextra->sourceFileDef)
446 {
447 setCurrentDoc(yyscanner,"l00001");
448 }
449
450 yyextra->includeCodeFragment = options.inlineFragment();
451 // Starts line 1 on the output
452 startCodeLine(yyscanner);
453
454 sqlcodeYYrestart( nullptr, yyscanner );
455
456 sqlcodeYYlex(yyscanner);
457
458 if (yyextra->insideCodeLine)
459 {
460 endCodeLine(yyscanner);
461 }
462 if (yyextra->exampleFileDef)
463 {
464 // delete the temporary file definition used for this example
465 yyextra->exampleFileDef.reset();
466 yyextra->sourceFileDef=nullptr;
467 }
468}
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:2489
static void startCodeLine(yyscan_t yyscanner)
Definition code.l:2420
static int countLines(yyscan_t yyscanner)
Definition code.l:3473
yyguts_t * yyscan_t
Definition code.l:24
static void setCurrentDoc(yyscan_t yyscanner, const QCString &anchor)
Definition code.l:2288
std::unique_ptr< FileDef > createFileDef(const QCString &p, const QCString &n, const QCString &ref, const QCString &dn)
Definition filedef.cpp:269
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
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

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

◆ 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.

Member Data Documentation

◆ p

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

Definition at line 46 of file sqlcode.h.

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


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