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

387 : p(std::make_unique<Private>())
388{
389 sqlcodeYYlex_init_extra(&p->state, &p->yyscanner);
390#ifdef FLEX_DEBUG
391 sqlcodeYYset_debug(Debug::isFlagSet(Debug::Lex_sqlcode)?1:0,p->yyscanner);
392#endif
394}
@ 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:401

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

◆ ~SQLCodeParser()

SQLCodeParser::~SQLCodeParser ( )
override

Definition at line 396 of file sqlcode.l.

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

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

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

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

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: