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

#include <src/vhdlcode.h>

Inheritance diagram for VHDLCodeParser:
Collaboration diagram for VHDLCodeParser:

Classes

struct  Private

Public Member Functions

 VHDLCodeParser ()
 ~VHDLCodeParser () override
void parseCode (OutputCodeList &codeOutIntf, const DString &scopeName, const DString &input, SrcLangExt lang, 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

Definition at line 22 of file vhdlcode.h.

Constructor & Destructor Documentation

◆ VHDLCodeParser()

VHDLCodeParser::VHDLCodeParser ( )

Definition at line 1635 of file vhdlcode.l.

1635 : p(std::make_unique<Private>())
1636{
1637 vhdlcodeYYlex_init_extra(&p->state,&p->yyscanner);
1638#ifdef FLEX_DEBUG
1639 vhdlcodeYYset_debug(Debug::isFlagSet(Debug::Lex_vhdlcode)?1:0,p->yyscanner);
1640#endif
1642}
@ Lex_vhdlcode
Definition debug.h:71
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:132
void resetCodeParserState() override
Resets the state of the code parser.
Definition vhdlcode.l:1649
std::unique_ptr< Private > p
Definition vhdlcode.h:39

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

◆ ~VHDLCodeParser()

VHDLCodeParser::~VHDLCodeParser ( )
override

Definition at line 1644 of file vhdlcode.l.

1645{
1646 vhdlcodeYYlex_destroy(p->yyscanner);
1647}

References p.

Member Function Documentation

◆ parseCode()

void VHDLCodeParser::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 1654 of file vhdlcode.l.

1661{
1662 yyscan_t yyscanner = p->yyscanner;
1663 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1664 //printf("***parseCode() exBlock=%d exName=%s fd=%p\n",exBlock,exName,fd);
1665 if (s.empty()) return;
1666 DebugLex debugLex(Debug::Lex_vhdlcode, __FILE__, options.fileDef() ? qPrint(options.fileDef()->fileName()): nullptr);
1667 yyextra->fileName = options.fileDef() ? options.fileDef()->fileName():"";
1668 if (options.memberDef())
1669 {
1670 const ClassDef *dd=options.memberDef()->getClassDef();
1671 if (dd) yyextra->currClass = dd->name();
1672 }
1673 od.stripCodeComments(stripCodeComments);
1675 yyextra->code = &od;
1676 yyextra->inputString = s.data();
1677 yyextra->inputPosition = 0;
1678 yyextra->currentFontClass = nullptr;
1679 yyextra->insideCodeLine = false;
1680 yyextra->searchCtx = options.searchCtx();
1681 yyextra->insideSpecialComment = false;
1682 yyextra->yyLineNr = options.startLine()!=-1 ? options.startLine() : 1;
1683 yyextra->inputLines = options.endLine()!=-1 ? options.endLine()+1 : yyextra->yyLineNr + countLines(yyscanner) - 1;
1684 yyextra->foldStack.clear();
1685
1686 // yyextra->theCallContext.clear();
1687 yyextra->exampleBlock = options.isExample();
1688 yyextra->exampleName = options.exampleName();
1689 yyextra->sourceFileDef = options.fileDef();
1690 yyextra->lineNumbers = options.fileDef() && options.showLineNumbers();
1691 if (options.isExample() && options.fileDef()==nullptr)
1692 {
1693 // create a dummy filedef for the example
1694 yyextra->exampleFileDef = createFileDef("",options.exampleName());
1695 yyextra->sourceFileDef = yyextra->exampleFileDef.get();
1696 }
1697 if (yyextra->sourceFileDef)
1698 {
1699 setCurrentDoc(yyscanner,"l00001");
1700 }
1701 yyextra->currentDefinition = nullptr;
1702 yyextra->currentMemberDef = nullptr;
1703 yyextra->vhdlMember = nullptr;
1704 if (!yyextra->exampleName.empty())
1705 {
1706 yyextra->exampleFile = convertNameToFile(yyextra->exampleName+"-example");
1707 }
1708 yyextra->includeCodeFragment = options.inlineFragment();
1709 startCodeLine(yyscanner);
1710 if (!yyextra->lexInit)
1711 {
1713 yyextra->lexInit=true;
1714 }
1715 vhdlcodeYYrestart( nullptr, yyscanner );
1716 BEGIN( Bases );
1717 vhdlcodeYYlex(yyscanner);
1718 if (yyextra->insideCodeLine)
1719 {
1720 endCodeLine(yyscanner);
1721 }
1722 if (Config_getBool(HTML_CODE_FOLDING))
1723 {
1724 while (!yyextra->foldStack.empty())
1725 {
1726 yyextra->code->endFold();
1727 yyextra->foldStack.pop_back();
1728 }
1729 }
1730 if (yyextra->exampleFileDef)
1731 {
1732 // delete the temporary file definition used for this example
1733 yyextra->exampleFileDef.reset();
1734 yyextra->sourceFileDef = nullptr;
1735 }
1736
1737 // write the tooltips
1738 yyextra->tooltipManager.writeTooltips(od);
1739}
virtual const DString & name() const =0
virtual DString fileName() const =0
virtual const ClassDef * getClassDef() const =0
static void init()
yyguts_t * yyscan_t
Definition code.l:25
#define yyguts_t
Definition code.l:23
#define Config_getBool(name)
Definition config.h:33
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
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
const MemberDef * memberDef() const
Definition parserintf.h:86
bool showLineNumbers() const
Definition parserintf.h:87
bool inlineFragment() const
Definition parserintf.h:85
int startLine() const
Definition parserintf.h:83
DString convertNameToFile(const DString &name, bool allowDots, bool allowUnderscore)
Definition util.cpp:2995
static void endCodeLine(yyscan_t yyscanner)
Definition vhdlcode.l:1121
static void startCodeLine(yyscan_t yyscanner)
Definition vhdlcode.l:1053
static void setCurrentDoc(yyscan_t yyscanner, const DString &anchor)
Definition vhdlcode.l:953
static int countLines(yyscan_t yyscanner)
Definition vhdlcode.l:1436

References Config_getBool, convertNameToFile(), countLines(), createFileDef(), DString::data(), DString::empty(), endCodeLine(), CodeParserOptions::endLine(), CodeParserOptions::exampleName(), CodeParserOptions::fileDef(), FileDef::fileName(), MemberDef::getClassDef(), VhdlDocGen::init(), CodeParserOptions::inlineFragment(), CodeParserOptions::isExample(), Debug::Lex_vhdlcode, CodeParserOptions::memberDef(), Definition::name(), p, qPrint(), resetCodeParserState(), CodeParserOptions::searchCtx(), setCurrentDoc(), CodeParserOptions::showLineNumbers(), startCodeLine(), CodeParserOptions::startLine(), OutputCodeList::stripCodeComments(), and yyguts_t.

◆ resetCodeParserState()

void VHDLCodeParser::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 1649 of file vhdlcode.l.

1650{
1651 p->state.vhdlKeyDict.clear();
1652}

References p.

Referenced by parseCode(), and VHDLCodeParser().

Member Data Documentation

◆ p

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

Definition at line 39 of file vhdlcode.h.

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


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