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< Privatep

Detailed Description

Definition at line 22 of file vhdlcode.h.

Constructor & Destructor Documentation

◆ VHDLCodeParser()

VHDLCodeParser::VHDLCodeParser ( )

Definition at line 1634 of file vhdlcode.l.

1634 : p(std::make_unique<Private>())
1635{
1636 vhdlcodeYYlex_init_extra(&p->state,&p->yyscanner);
1637#ifdef FLEX_DEBUG
1638 vhdlcodeYYset_debug(Debug::isFlagSet(Debug::Lex_vhdlcode)?1:0,p->yyscanner);
1639#endif
1641}
@ 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:1648
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 1643 of file vhdlcode.l.

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

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 1653 of file vhdlcode.l.

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

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(), and OutputCodeList::stripCodeComments().

◆ 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 1648 of file vhdlcode.l.

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

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: