Skip to main content

The FortranCodeParser Class Reference

Declaration

class FortranCodeParser { ... }

Included Headers

#include <src/fortrancode.h>

Base class

classCodeParserInterface

Abstract interface for code parsers. More...

Derived Classes

classFortranCodeParserFixed
classFortranCodeParserFree

Public Constructors Index

FortranCodeParser (FortranFormat format=FortranFormat::Unknown)

Public Destructor Index

~FortranCodeParser () override

Public Member Functions Index

voidparseCode (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. More...

voidresetCodeParserState () override

Resets the state of the code parser. More...

Private Member Attributes Index

std::unique_ptr< Private >p

Definition at line 29 of file fortrancode.h.

Public Constructors

FortranCodeParser()

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

Declaration at line 32 of file fortrancode.h, definition at line 1460 of file fortrancode.l.

1461{
1462 p->format = format;
1463 fortrancodeYYlex_init_extra(&p->state,&p->yyscanner);
1464#ifdef FLEX_DEBUG
1465 fortrancodeYYset_debug(Debug::isFlagSet(Debug::Lex_fortrancode)?1:0,p->yyscanner);
1466#endif
1468}

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

Referenced by FortranCodeParserFixed::FortranCodeParserFixed and FortranCodeParserFree::FortranCodeParserFree.

Public Destructor

~FortranCodeParser()

FortranCodeParser::~FortranCodeParser ()

Declaration at line 33 of file fortrancode.h, definition at line 1470 of file fortrancode.l.

1471{
1472 fortrancodeYYlex_destroy(p->yyscanner);
1473}

Reference p.

Public Member Functions

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)
virtual

Parses a source file or fragment with the goal to produce highlighted and cross-referenced output.

Parameters
[in] codeOutList

interface for writing the result.

[in] scopeName

Name of scope to which the code belongs.

[in] input

Actual code in the form of a string

[in] lang

The programming language of the code fragment.

[in] stripCodeComments

signals whether or not for the code block the doxygen comments should be stripped.

[in] isExampleBlock

TRUE iff the code is part of an example.

[in] exampleName

Name of the example.

[in] fileDef

File definition to which the code is associated.

[in] startLine

Starting line in case of a code fragment.

[in] endLine

Ending line of the code fragment.

[in] inlineFragment

Code fragment that is to be shown inline as part of the documentation.

[in] memberDef

Member definition to which the code is associated (non null in case of an inline fragment for a member).

[in] showLineNumbers

if set to TRUE and also fileDef is not 0, line numbers will be added to the source fragment

[in] searchCtx

context under which search data has to be stored.

[in] collectXRefs

collect cross-reference relations.

Declaration at line 36 of file fortrancode.h, definition at line 1485 of file fortrancode.l.

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

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 ()
virtual

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()

Declaration at line 52 of file fortrancode.h, definition at line 1475 of file fortrancode.l.

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

References FALSE and p.

Referenced by FortranCodeParser.

Private Member Attributes

p

std::unique_ptr<Private> FortranCodeParser::p

Definition at line 56 of file fortrancode.h.

56 std::unique_ptr<Private> p;

Referenced by FortranCodeParser, parseCode, resetCodeParserState and ~FortranCodeParser.


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


Generated via doxygen2docusaurus by Doxygen 1.14.0.