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< Private > p

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 389 of file sqlcode.l.

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

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

◆ ~SQLCodeParser()

SQLCodeParser::~SQLCodeParser ( )
override

Definition at line 398 of file sqlcode.l.

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

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 410 of file sqlcode.l.

417{
418 yyscan_t yyscanner = p->yyscanner;
419 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
420
421 if (input.empty()) return;
422
423 DebugLex debugLex(Debug::Lex_sqlcode, __FILE__, options.fileDef() ? qPrint(options.fileDef()->fileName()): nullptr);
424 yyextra->fileName = options.fileDef() ? options.fileDef()->fileName():"";
425 yyextra->code = &codeOutIntf;
426 yyextra->inputString = input.data();
427 yyextra->inputPosition = 0;
428 yyextra->currentFontClass = nullptr;
429 yyextra->insideCodeLine = false;
430 yyextra->searchCtx = options.searchCtx();
431 yyextra->yyLineNr = options.startLine()!=-1 ? options.startLine() : 1;
432 yyextra->inputLines = options.endLine()!=-1 ? options.endLine()+1 : yyextra->yyLineNr + countLines(yyscanner) - 1;
433 yyextra->stripCodeComments = stripCodeComments;
434 yyextra->exampleBlock = options.isExample();
435 yyextra->exampleName = options.exampleName();
436 yyextra->sourceFileDef = options.fileDef();
437 yyextra->lineNumbers = options.fileDef() && options.showLineNumbers();
438
439 if (options.isExample() && options.fileDef()==0)
440 {
441 // create a dummy filedef for the example
442 yyextra->exampleFileDef = createFileDef(DString(),!options.exampleName().empty() ? options.exampleName() : DString("generated"));
443 yyextra->sourceFileDef = yyextra->exampleFileDef.get();
444 }
445
446 if (yyextra->sourceFileDef)
447 {
448 setCurrentDoc(yyscanner,"l00001");
449 }
450
451 yyextra->includeCodeFragment = options.inlineFragment();
452 // Starts line 1 on the output
453 startCodeLine(yyscanner);
454
455 sqlcodeYYrestart( nullptr, yyscanner );
456
457 sqlcodeYYlex(yyscanner);
458
459 if (yyextra->insideCodeLine)
460 {
461 endCodeLine(yyscanner);
462 }
463 if (yyextra->exampleFileDef)
464 {
465 // delete the temporary file definition used for this example
466 yyextra->exampleFileDef.reset();
467 yyextra->sourceFileDef=nullptr;
468 }
469}
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:148
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:157
virtual DString fileName() const =0
yyguts_t * yyscan_t
Definition code.l:25
#define yyguts_t
Definition code.l:23
const char * qPrint(const char *s)
Definition dstring.h:783
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:289
static void startCodeLine(yyscan_t yyscanner)
Definition sqlcode.l:232
static void setCurrentDoc(yyscan_t yyscanner, const DString &anchor)
Definition sqlcode.l:212
static int countLines(yyscan_t yyscanner)
Definition sqlcode.l:346
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(), CodeParserOptions::startLine(), and yyguts_t.

◆ 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 403 of file sqlcode.l.

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

References p, and yyguts_t.

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: