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

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 DString &scopeName, const DString &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 26 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:70
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:133
std::unique_ptr< Private > p
Definition sqlcode.h:43
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 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 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.empty()) 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(DString(),!options.exampleName().empty() ? options.exampleName() : DString("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}
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:152
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition dstring.h:161
virtual DString fileName() const =0
yyguts_t * yyscan_t
Definition code.l:24
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
static void endCodeLine(yyscan_t yyscanner)
Definition sqlcode.l:288
static void startCodeLine(yyscan_t yyscanner)
Definition sqlcode.l:231
static void setCurrentDoc(yyscan_t yyscanner, const DString &anchor)
Definition sqlcode.l:211
static int countLines(yyscan_t yyscanner)
Definition sqlcode.l:345
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
bool showLineNumbers() const
Definition parserintf.h:87
bool inlineFragment() const
Definition parserintf.h:85
int startLine() const
Definition parserintf.h:83

References countLines(), createFileDef(), DString::data(), DString::empty(), endCodeLine(), CodeParserOptions::endLine(), CodeParserOptions::exampleName(), CodeParserOptions::fileDef(), FileDef::fileName(), CodeParserOptions::inlineFragment(), 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.

Referenced by SQLCodeParser().

Member Data Documentation

◆ p

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

Definition at line 43 of file sqlcode.h.

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


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