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.
 
- Public Member Functions inherited from CodeParserInterface

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 1458 of file fortrancode.l.

1458 : p(std::make_unique<Private>())
1459{
1460 p->format = format;
1461 fortrancodeYYlex_init_extra(&p->state,&p->yyscanner);
1462#ifdef FLEX_DEBUG
1463 fortrancodeYYset_debug(Debug::isFlagSet(Debug::Lex_fortrancode)?1:0,p->yyscanner);
1464#endif
1466}
@ Lex_fortrancode
Definition debug.h:59
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:135
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 1468 of file fortrancode.l.

1469{
1470 fortrancodeYYlex_destroy(p->yyscanner);
1471}

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 1483 of file fortrancode.l.

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

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 1473 of file fortrancode.l.

1474{
1475 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
1476 yyextra->currentDefinition = nullptr;
1477 yyextra->currentMemberDef = nullptr;
1478 yyextra->currentFontClass = nullptr;
1479 yyextra->insideCodeLine = FALSE;
1480 BEGIN( Start );
1481}

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: