Skip to main content

The SQLCodeParser Class Reference

SQL scanner. More...

Declaration

class SQLCodeParser { ... }

Included Headers

#include <src/sqlcode.h>

Base class

classCodeParserInterface

Abstract interface for code parsers. More...

Public Constructors Index

SQLCodeParser ()

Public Destructor Index

~SQLCodeParser () override

Public Member Functions Index

voidparseCode (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. More...

voidresetCodeParserState () override

Resets the state of the code parser. More...

Private Member Attributes Index

std::unique_ptr< Private >p

Description

SQL scanner.

Only support syntax highlighting of code at the moment.

Definition at line 29 of file sqlcode.h.

Public Constructors

SQLCodeParser()

SQLCodeParser::SQLCodeParser ()

Declaration at line 32 of file sqlcode.h, definition at line 388 of file sqlcode.l.

388SQLCodeParser::SQLCodeParser() : 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}

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

Public Destructor

~SQLCodeParser()

SQLCodeParser::~SQLCodeParser ()

Declaration at line 33 of file sqlcode.h, definition at line 397 of file sqlcode.l.

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

Reference p.

Public Member Functions

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)
virtual

Parses a source file or fragment with the goal to produce highlighted and cross-referenced output.

Parameters
[in] codeOutList

interface for writing the result.

[in] scopeName

Name of scope to which the code belongs.

[in] input

Actual code in the form of a string

[in] lang

The programming language of the code fragment.

[in] stripCodeComments

signals whether or not for the code block the doxygen comments should be stripped.

[in] isExampleBlock

TRUE iff the code is part of an example.

[in] exampleName

Name of the example.

[in] fileDef

File definition to which the code is associated.

[in] startLine

Starting line in case of a code fragment.

[in] endLine

Ending line of the code fragment.

[in] inlineFragment

Code fragment that is to be shown inline as part of the documentation.

[in] memberDef

Member definition to which the code is associated (non null in case of an inline fragment for a member).

[in] showLineNumbers

if set to TRUE and also fileDef is not 0, line numbers will be added to the source fragment

[in] searchCtx

context under which search data has to be stored.

[in] collectXRefs

collect cross-reference relations.

Declaration at line 36 of file sqlcode.h, definition at line 409 of file sqlcode.l.

410 const QCString &/* scopeName */,
411 const QCString &input,
413 bool stripCodeComments,
414 bool isExampleBlock,
415 const QCString &exampleName,
416 const FileDef *fileDef,
417 int startLine,
418 int endLine,
419 bool inlineFragment,
420 const MemberDef * /* memberDef */,
421 bool /* showLineNumbers */,
422 const Definition *searchCtx,
423 bool/* collectXRefs */
424 )
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}

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

resetCodeParserState()

void SQLCodeParser::resetCodeParserState ()
virtual

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()

Declaration at line 52 of file sqlcode.h, 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}

Reference p.

Referenced by SQLCodeParser.

Private Member Attributes

p

std::unique_ptr<Private> SQLCodeParser::p

Definition at line 55 of file sqlcode.h.

55 std::unique_ptr<Private> p;

Referenced by parseCode, resetCodeParserState, SQLCodeParser and ~SQLCodeParser.


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


Generated via doxygen2docusaurus by Doxygen 1.14.0.