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, 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 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:47

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

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

1485{
1486 yyscan_t yyscanner = p->yyscanner;
1487 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
1488 if (input.isEmpty()) return;
1489 DebugLex debugLex(Debug::Lex_fortrancode, __FILE__, options.fileDef() ? qPrint(options.fileDef()->fileName()): nullptr);
1490 codeOutIntf.stripCodeComments(stripCodeComments);
1491 yyextra->code = &codeOutIntf;
1492 yyextra->inputString = input.data();
1493 yyextra->inputPosition = 0;
1494 yyextra->fileName = options.fileDef() ? options.fileDef()->fileName():"";
1495 yyextra->isFixedForm = recognizeFixedForm(input,p->format);
1496 yyextra->contLineNr = 1;
1497 yyextra->hasContLine = nullptr;
1498 if (yyextra->isFixedForm)
1499 {
1500 checkContLines(yyscanner,yyextra->inputString);
1501 yyextra->fixedCommentAfter = Config_getInt(FORTRAN_COMMENT_AFTER);
1502 }
1503 yyextra->currentFontClass = nullptr;
1504 yyextra->insideCodeLine = FALSE;
1505 yyextra->searchCtx = options.searchCtx();
1506 yyextra->collectXRefs = options.collectXRefs();
1507 yyextra->yyLineNr = options.startLine()!=-1 ? options.startLine() : 1;
1508 yyextra->inputLines = options.endLine()!=-1 ? options.endLine()+1 : yyextra->yyLineNr + countLines(yyscanner) - 1;
1509 yyextra->exampleBlock = options.isExample();
1510 yyextra->exampleName = options.exampleName();
1511 yyextra->sourceFileDef = options.fileDef();
1512 yyextra->foldStack.clear();
1513 yyextra->insideSpecialComment = false;
1514 if (options.isExample() && options.fileDef()==nullptr)
1515 {
1516 // create a dummy filedef for the example
1517 yyextra->exampleFileDef = createFileDef(QCString(),options.exampleName());
1518 yyextra->sourceFileDef = yyextra->exampleFileDef.get();
1519 }
1520 if (yyextra->sourceFileDef)
1521 {
1522 setCurrentDoc(yyscanner,QCString("l00001"));
1523 }
1524 yyextra->currentDefinition = nullptr;
1525 yyextra->currentMemberDef = nullptr;
1526 if (!yyextra->exampleName.isEmpty())
1527 {
1528 yyextra->exampleFile = convertNameToFile(yyextra->exampleName+"-example");
1529 }
1530 yyextra->includeCodeFragment = options.inlineFragment();
1531 startCodeLine(yyscanner);
1532 fortrancodeYYrestart(nullptr, yyscanner);
1533 BEGIN( Start );
1534 fortrancodeYYlex(yyscanner);
1535 if (yyextra->insideCodeLine)
1536 {
1537 endCodeLine(yyscanner);
1538 }
1539 if (Config_getBool(HTML_CODE_FOLDING))
1540 {
1541 while (!yyextra->foldStack.empty())
1542 {
1543 yyextra->code->endFold();
1544 yyextra->foldStack.pop_back();
1545 }
1546 }
1547 if (yyextra->exampleFileDef)
1548 {
1549 // delete the temporary file definition used for this example
1550 yyextra->exampleFileDef.reset();
1551 yyextra->sourceFileDef=nullptr;
1552 }
1553 if (yyextra->hasContLine) free(yyextra->hasContLine);
1554 yyextra->hasContLine = nullptr;
1555
1556 // write the tooltips
1557 yyextra->tooltipManager.writeTooltips(codeOutIntf);
1558}
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:3462
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 isExample() const
Definition parserintf.h:81
const Definition * searchCtx() const
Definition parserintf.h:89
const FileDef * fileDef() const
Definition parserintf.h:83
int endLine() const
Definition parserintf.h:85
bool inlineFragment() const
Definition parserintf.h:86
QCString exampleName() const
Definition parserintf.h:82
int startLine() const
Definition parserintf.h:84
bool collectXRefs() const
Definition parserintf.h:90
bool recognizeFixedForm(const QCString &contents, FortranFormat format)
Definition util.cpp:6293
QCString convertNameToFile(const QCString &name, bool allowDots, bool allowUnderscore)
Definition util.cpp:3446

References checkContLines(), CodeParserOptions::collectXRefs(), Config_getBool, Config_getInt, convertNameToFile(), countLines(), createFileDef(), QCString::data(), endCodeLine(), CodeParserOptions::endLine(), CodeParserOptions::exampleName(), FALSE, CodeParserOptions::fileDef(), FileDef::fileName(), CodeParserOptions::inlineFragment(), QCString::isEmpty(), CodeParserOptions::isExample(), Debug::Lex_fortrancode, p, qPrint(), recognizeFixedForm(), CodeParserOptions::searchCtx(), setCurrentDoc(), startCodeLine(), CodeParserOptions::startLine(), 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.

Member Data Documentation

◆ p

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

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