Doxygen
Loading...
Searching...
No Matches
FortranCodeParser Class Reference

#include <src/fortrancode.h>

Inheritance diagram for FortranCodeParser:
Collaboration diagram for FortranCodeParser:

Classes

struct  Private

Public Member Functions

 FortranCodeParser (FortranFormat format=FortranFormat::Unknown)
 ~FortranCodeParser () override
void parseCode (OutputCodeList &codeOutIntf, 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) 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 29 of file fortrancode.h.

Constructor & Destructor Documentation

◆ FortranCodeParser()

FortranCodeParser::FortranCodeParser ( FortranFormat format = FortranFormat::Unknown)

Definition at line 1453 of file fortrancode.l.

1453 : p(std::make_unique<Private>())
1454{
1455 p->format = format;
1456 fortrancodeYYlex_init_extra(&p->state,&p->yyscanner);
1457#ifdef FLEX_DEBUG
1458 fortrancodeYYset_debug(Debug::isFlagSet(Debug::Lex_fortrancode)?1:0,p->yyscanner);
1459#endif
1461}
@ Lex_fortrancode
Definition debug.h:60
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:132
void resetCodeParserState() override
Resets the state of the code parser.
std::unique_ptr< Private > p
Definition fortrancode.h:56

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

Referenced by FortranCodeParserFixed::FortranCodeParserFixed(), and FortranCodeParserFree::FortranCodeParserFree().

◆ ~FortranCodeParser()

FortranCodeParser::~FortranCodeParser ( )
override

Definition at line 1463 of file fortrancode.l.

1464{
1465 fortrancodeYYlex_destroy(p->yyscanner);
1466}

References p.

Member Function Documentation

◆ parseCode()

void FortranCodeParser::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 )
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]isExampleBlockTRUE iff the code is part of an example.
[in]exampleNameName of the example.
[in]fileDefFile definition to which the code is associated.
[in]startLineStarting line in case of a code fragment.
[in]endLineEnding line of the code fragment.
[in]inlineFragmentCode fragment that is to be shown inline as part of the documentation.
[in]memberDefMember definition to which the code is associated (non null in case of an inline fragment for a member).
[in]showLineNumbersif set to TRUE and also fileDef is not 0, line numbers will be added to the source fragment
[in]searchCtxcontext under which search data has to be stored.
[in]collectXRefscollect cross-reference relations.

Implements CodeParserInterface.

Definition at line 1478 of file fortrancode.l.

1494{
1495 yyscan_t yyscanner = p->yyscanner;
1496 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
1497 //::parseFortranCode(codeOutIntf,scopeName,input,isExampleBlock,exampleName,
1498 // fileDef,startLine,endLine,inlineFragment,memberDef,
1499 // showLineNumbers,searchCtx,collectXRefs,m_format);
1500 // parseFortranCode(OutputCodeList &od,const char *,const QCString &s,
1501 // bool exBlock, const char *exName,FileDef *fd,
1502 // int startLine,int endLine,bool inlineFragment,
1503 // const MemberDef *,bool,const Definition *searchCtx,
1504 // bool collectXRefs, FortranFormat format)
1505 if (input.isEmpty()) return;
1506 DebugLex debugLex(Debug::Lex_fortrancode, __FILE__, fileDef ? qPrint(fileDef->fileName()): nullptr);
1507 codeOutIntf.stripCodeComments(stripCodeComments);
1508 yyextra->code = &codeOutIntf;
1509 yyextra->inputString = input.data();
1510 yyextra->inputPosition = 0;
1511 yyextra->fileName = fileDef ? fileDef->fileName():"";
1512 yyextra->isFixedForm = recognizeFixedForm(input,p->format);
1513 yyextra->contLineNr = 1;
1514 yyextra->hasContLine = nullptr;
1515 if (yyextra->isFixedForm)
1516 {
1517 checkContLines(yyscanner,yyextra->inputString);
1518 yyextra->fixedCommentAfter = Config_getInt(FORTRAN_COMMENT_AFTER);
1519 }
1520 yyextra->currentFontClass = nullptr;
1521 yyextra->insideCodeLine = FALSE;
1522 yyextra->searchCtx = searchCtx;
1523 yyextra->collectXRefs = collectXRefs;
1524 if (startLine!=-1)
1525 yyextra->yyLineNr = startLine;
1526 else
1527 yyextra->yyLineNr = 1;
1528
1529 if (endLine!=-1)
1530 yyextra->inputLines = endLine+1;
1531 else
1532 yyextra->inputLines = yyextra->yyLineNr + countLines(yyscanner) - 1;
1533
1534 yyextra->exampleBlock = isExampleBlock;
1535 yyextra->exampleName = exampleName;
1536 yyextra->sourceFileDef = fileDef;
1537 yyextra->foldStack.clear();
1538 yyextra->insideSpecialComment = false;
1539 if (isExampleBlock && fileDef==nullptr)
1540 {
1541 // create a dummy filedef for the example
1542 yyextra->exampleFileDef = createFileDef(QCString(),exampleName);
1543 yyextra->sourceFileDef = yyextra->exampleFileDef.get();
1544 }
1545 if (yyextra->sourceFileDef)
1546 {
1547 setCurrentDoc(yyscanner,QCString("l00001"));
1548 }
1549 yyextra->currentDefinition = nullptr;
1550 yyextra->currentMemberDef = nullptr;
1551 if (!yyextra->exampleName.isEmpty())
1552 {
1553 yyextra->exampleFile = convertNameToFile(yyextra->exampleName+"-example");
1554 }
1555 yyextra->includeCodeFragment = inlineFragment;
1556 startCodeLine(yyscanner);
1557 fortrancodeYYrestart(nullptr, yyscanner);
1558 BEGIN( Start );
1559 fortrancodeYYlex(yyscanner);
1560 if (yyextra->insideCodeLine)
1561 {
1562 endCodeLine(yyscanner);
1563 }
1564 if (Config_getBool(HTML_CODE_FOLDING))
1565 {
1566 while (!yyextra->foldStack.empty())
1567 {
1568 yyextra->code->endFold();
1569 yyextra->foldStack.pop_back();
1570 }
1571 }
1572 if (!fileDef && isExampleBlock && yyextra->sourceFileDef)
1573 {
1574 // delete the temporary file definition used for this example
1575 yyextra->exampleFileDef.reset();
1576 yyextra->sourceFileDef=nullptr;
1577 }
1578 if (yyextra->hasContLine) free(yyextra->hasContLine);
1579 yyextra->hasContLine = nullptr;
1580
1581 // write the tooltips
1582 yyextra->tooltipManager.writeTooltips(codeOutIntf);
1583}
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:3454
yyguts_t * yyscan_t
Definition code.l:24
static void setCurrentDoc(yyscan_t yyscanner, const QCString &anchor)
Definition code.l:2277
#define Config_getInt(name)
Definition config.h:34
#define Config_getBool(name)
Definition config.h:33
std::unique_ptr< FileDef > createFileDef(const QCString &p, const QCString &n, const QCString &ref, const QCString &dn)
Definition filedef.cpp:268
static void checkContLines(yyscan_t yyscanner, const char *s)
const char * qPrint(const char *s)
Definition qcstring.h:687
#define FALSE
Definition qcstring.h:34
bool recognizeFixedForm(const QCString &contents, FortranFormat format)
Definition util.cpp:6860
QCString convertNameToFile(const QCString &name, bool allowDots, bool allowUnderscore)
Definition util.cpp:4020

References checkContLines(), Config_getBool, Config_getInt, convertNameToFile(), countLines(), createFileDef(), QCString::data(), endCodeLine(), FALSE, FileDef::fileName(), QCString::isEmpty(), Debug::Lex_fortrancode, p, qPrint(), recognizeFixedForm(), setCurrentDoc(), startCodeLine(), and OutputCodeList::stripCodeComments().

◆ resetCodeParserState()

void FortranCodeParser::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 1468 of file fortrancode.l.

1469{
1470 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
1471 yyextra->currentDefinition = nullptr;
1472 yyextra->currentMemberDef = nullptr;
1473 yyextra->currentFontClass = nullptr;
1474 yyextra->insideCodeLine = FALSE;
1475 BEGIN( Start );
1476}

References FALSE, and p.

Referenced by FortranCodeParser().

Member Data Documentation

◆ p

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

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