Doxygen
Loading...
Searching...
No Matches
commentscan.l
Go to the documentation of this file.
1/*****************************************************************************
2 *
3 * Copyright (C) 1997-2020 by Dimitri van Heesch.
4 *
5 * Permission to use, copy, modify, and distribute this software and its
6 * documentation under the terms of the GNU General Public License is hereby
7 * granted. No representations are made about the suitability of this software
8 * for any purpose. It is provided "as is" without express or implied warranty.
9 * See the GNU General Public License for more details.
10 *
11 * Documents produced by Doxygen are derivative works derived from the
12 * input used in their production; they are not affected by this license.
13 *
14 */
15
16%option never-interactive
17%option prefix="commentscanYY"
18%option reentrant
19%option extra-type="struct commentscanYY_state *"
20%top{
21#include <stdint.h>
22// forward declare yyscan_t to improve typesafety
23#define YY_TYPEDEF_YY_SCANNER_T
24struct yyguts_t;
25typedef yyguts_t *yyscan_t;
yyguts_t * yyscan_t
Definition code.l:24
26}
27
28%{
29
30/*
31 * includes
32 */
33
34#include <map>
35#include <stack>
36#include <string>
37#include <mutex>
38#include <functional>
39#include <unordered_map>
40#include <algorithm>
41
42#include <stdio.h>
43#include <stdlib.h>
44#include <assert.h>
45#include <ctype.h>
46
47#include "qcstring.h"
48#include "fileinfo.h"
49#include "cite.h"
50#include "commentscan.h"
51#include "condparser.h"
52#include "config.h"
53#include "debug.h"
54#include "docgroup.h"
55#include "doxygen.h"
56#include "entry.h"
57#include "formula.h"
58#include "language.h"
59#include "message.h"
60#include "parserintf.h"
61#include "reflist.h"
62#include "section.h"
63#include "regex.h"
64#include "util.h"
65#include "reflist.h"
66#include "trace.h"
67#include "debug.h"
68#include "stringutil.h"
69
70// forward declarations
71static bool handleBrief(yyscan_t yyscanner,const QCString &, const StringVector &);
72static bool handleFn(yyscan_t yyscanner,const QCString &, const StringVector &);
73static bool handleDef(yyscan_t yyscanner,const QCString &, const StringVector &);
74static bool handleOverload(yyscan_t yyscanner,const QCString &, const StringVector &);
75static bool handleEnum(yyscan_t yyscanner,const QCString &, const StringVector &);
76static bool handleDefGroup(yyscan_t yyscanner,const QCString &, const StringVector &);
77static bool handleAddToGroup(yyscan_t yyscanner,const QCString &, const StringVector &);
78static bool handleWeakGroup(yyscan_t yyscanner,const QCString &, const StringVector &);
79static bool handleNamespace(yyscan_t yyscanner,const QCString &, const StringVector &);
80static bool handlePackage(yyscan_t yyscanner,const QCString &, const StringVector &);
81static bool handleConcept(yyscan_t yyscanner,const QCString &, const StringVector &);
82static bool handleClass(yyscan_t yyscanner,const QCString &, const StringVector &);
83static bool handleHeaderFile(yyscan_t yyscanner,const QCString &, const StringVector &);
84static bool handleProtocol(yyscan_t yyscanner,const QCString &, const StringVector &);
85static bool handleCategory(yyscan_t yyscanner,const QCString &, const StringVector &);
86static bool handleUnion(yyscan_t yyscanner,const QCString &, const StringVector &);
87static bool handleStruct(yyscan_t yyscanner,const QCString &, const StringVector &);
88static bool handleInterface(yyscan_t yyscanner,const QCString &, const StringVector &);
89static bool handleIdlException(yyscan_t yyscanner,const QCString &, const StringVector &);
90static bool handlePage(yyscan_t yyscanner,const QCString &, const StringVector &);
91static bool handleMainpage(yyscan_t yyscanner,const QCString &, const StringVector &);
92static bool handleFile(yyscan_t yyscanner,const QCString &, const StringVector &);
93static bool handleDir(yyscan_t yyscanner,const QCString &, const StringVector &);
94static bool handleExample(yyscan_t yyscanner,const QCString &, const StringVector &);
95static bool handleDetails(yyscan_t yyscanner,const QCString &, const StringVector &);
96static bool handleRaiseWarning(yyscan_t yyscanner,const QCString &, const StringVector &);
97static bool handleNoop(yyscan_t yyscanner,const QCString &, const StringVector &);
98static bool handleName(yyscan_t yyscanner,const QCString &, const StringVector &);
99static bool handleTodo(yyscan_t yyscanner,const QCString &, const StringVector &);
100static bool handleTest(yyscan_t yyscanner,const QCString &, const StringVector &);
101static bool handleBug(yyscan_t yyscanner,const QCString &, const StringVector &);
102static bool handleSubpage(yyscan_t yyscanner,const QCString &s, const StringVector &);
103static bool handleDeprecated(yyscan_t yyscanner,const QCString &, const StringVector &);
104static bool handleXRefItem(yyscan_t yyscanner,const QCString &, const StringVector &);
105static bool handleRelated(yyscan_t yyscanner,const QCString &, const StringVector &);
106static bool handleRelatedAlso(yyscan_t yyscanner,const QCString &, const StringVector &);
107static bool handleMemberOf(yyscan_t yyscanner,const QCString &, const StringVector &);
108static bool handleRefItem(yyscan_t yyscanner,const QCString &, const StringVector &);
109static bool handleSection(yyscan_t yyscanner,const QCString &, const StringVector &);
110static bool handleAnchor(yyscan_t yyscanner,const QCString &, const StringVector &);
111static bool handleImage(yyscan_t yyscanner,const QCString &, const StringVector &);
112static bool handleCite(yyscan_t yyscanner,const QCString &, const StringVector &);
113static bool handleFormatBlock(yyscan_t yyscanner,const QCString &, const StringVector &);
114static bool handleAddIndex(yyscan_t yyscanner,const QCString &, const StringVector &);
115static bool handleIf(yyscan_t yyscanner,const QCString &, const StringVector &);
116static bool handleIfNot(yyscan_t yyscanner,const QCString &, const StringVector &);
117static bool handleElseIf(yyscan_t yyscanner,const QCString &, const StringVector &);
118static bool handleElse(yyscan_t yyscanner,const QCString &, const StringVector &);
119static bool handleEndIf(yyscan_t yyscanner,const QCString &, const StringVector &);
120static bool handleIngroup(yyscan_t yyscanner,const QCString &, const StringVector &);
121static bool handleNoSubGrouping(yyscan_t yyscanner,const QCString &, const StringVector &);
122static bool handleShowInitializer(yyscan_t yyscanner,const QCString &, const StringVector &);
123static bool handleHideInitializer(yyscan_t yyscanner,const QCString &, const StringVector &);
124static bool handleCallgraph(yyscan_t yyscanner,const QCString &, const StringVector &);
125static bool handleHideCallgraph(yyscan_t yyscanner,const QCString &, const StringVector &);
126static bool handleCallergraph(yyscan_t yyscanner,const QCString &, const StringVector &);
127static bool handleHideCallergraph(yyscan_t yyscanner,const QCString &, const StringVector &);
128static bool handleIncludegraph(yyscan_t yyscanner,const QCString &, const StringVector &);
129static bool handleIncludedBygraph(yyscan_t yyscanner,const QCString &, const StringVector &);
130static bool handleShowEnumValues(yyscan_t yyscanner,const QCString &, const StringVector &);
131static bool handleHideEnumValues(yyscan_t yyscanner,const QCString &, const StringVector &);
132static bool handleShowInlineSource(yyscan_t yyscanner,const QCString &, const StringVector &);
133static bool handleHideInlineSource(yyscan_t yyscanner,const QCString &, const StringVector &);
134static bool handleHideIncludegraph(yyscan_t yyscanner,const QCString &, const StringVector &);
135static bool handleHideIncludedBygraph(yyscan_t yyscanner,const QCString &, const StringVector &);
136static bool handleDirectoryGraph(yyscan_t yyscanner,const QCString &, const StringVector &);
137static bool handleHideDirectoryGraph(yyscan_t yyscanner,const QCString &, const StringVector &);
138static bool handleCollaborationgraph(yyscan_t yyscanner,const QCString &, const StringVector &);
139static bool handleHideCollaborationgraph(yyscan_t yyscanner,const QCString &, const StringVector &);
140static bool handleInheritanceGraph(yyscan_t yyscanner,const QCString &, const StringVector &);
141static bool handleHideInheritanceGraph(yyscan_t yyscanner,const QCString &, const StringVector &);
142static bool handleReferencedByRelation(yyscan_t yyscanner,const QCString &, const StringVector &);
143static bool handleHideReferencedByRelation(yyscan_t yyscanner,const QCString &, const StringVector &);
144static bool handleReferencesRelation(yyscan_t yyscanner,const QCString &, const StringVector &);
145static bool handleHideReferencesRelation(yyscan_t yyscanner,const QCString &, const StringVector &);
146static bool handleGroupgraph(yyscan_t yyscanner,const QCString &, const StringVector &);
147static bool handleHideGroupgraph(yyscan_t yyscanner,const QCString &, const StringVector &);
148static bool handleInternal(yyscan_t yyscanner,const QCString &, const StringVector &);
149static bool handleStatic(yyscan_t yyscanner,const QCString &, const StringVector &);
150static bool handlePure(yyscan_t yyscanner,const QCString &, const StringVector &);
151static bool handlePrivate(yyscan_t yyscanner,const QCString &, const StringVector &);
152static bool handlePrivateSection(yyscan_t yyscanner,const QCString &, const StringVector &);
153static bool handleProtected(yyscan_t yyscanner,const QCString &, const StringVector &);
154static bool handleProtectedSection(yyscan_t yyscanner,const QCString &, const StringVector &);
155static bool handlePublic(yyscan_t yyscanner,const QCString &s, const StringVector &);
156static bool handlePublicSection(yyscan_t yyscanner,const QCString &s, const StringVector &);
157static bool handleQualifier(yyscan_t yyscanner,const QCString &, const StringVector &);
158static bool handleToc(yyscan_t yyscanner,const QCString &s, const StringVector &);
159static bool handleInherit(yyscan_t yyscanner,const QCString &, const StringVector &);
160static bool handleExtends(yyscan_t yyscanner,const QCString &, const StringVector &);
161static bool handleCopyDoc(yyscan_t yyscanner,const QCString &, const StringVector &);
162static bool handleCopyBrief(yyscan_t yyscanner,const QCString &, const StringVector &);
163static bool handleCopyDetails(yyscan_t yyscanner,const QCString &, const StringVector &);
164static bool handleParBlock(yyscan_t yyscanner,const QCString &, const StringVector &);
165static bool handleEndParBlock(yyscan_t yyscanner,const QCString &, const StringVector &);
166static bool handleParam(yyscan_t yyscanner,const QCString &, const StringVector &);
167static bool handleRetval(yyscan_t yyscanner,const QCString &, const StringVector &);
168static bool handleFileInfo(yyscan_t yyscanner,const QCString &cmdName, const StringVector &optList);
169static bool handleFileInfoSection(yyscan_t yyscanner,const QCString &cmdName, const StringVector &optList);
170static bool handleFileInfoResult(yyscan_t yyscanner,const QCString &, const StringVector &optList, bool isSection);
171static bool handleLineInfo(yyscan_t yyscanner,const QCString &, const StringVector &);
172static bool handleModule(yyscan_t yyscanner,const QCString &, const StringVector &);
173static bool handleIFile(yyscan_t yyscanner,const QCString &, const StringVector &);
174static bool handleILine(yyscan_t yyscanner,const QCString &, const StringVector &);
175static bool handleIRaise(yyscan_t yyscanner,const QCString &, const StringVector &);
176static bool handleIPrefix(yyscan_t yyscanner,const QCString &, const StringVector &);
177
178[[maybe_unused]] static const char *stateToString(int state);
179
180typedef bool (*DocCmdFunc)(yyscan_t yyscanner,const QCString &name, const StringVector &optList);
182
184{
185 Invisible, //!< command sets some property but does not appear in the output.
186 Inline, //!< command appears inline in the output which can be a brief description.
187 Block, //!< command starts a new paragraphs / ends a brief description.
188 XRef //!< command is a cross reference (todo, bug, test, deprecated, xrefitem).
189};
190
192{
193 Allowed, //!< command is allowed without restrictions in section title
194 Replace, //!< command will be handled in here / needs special handling here
195 Escape, //!< command is not-allowed in section title, it will be escaped
196 Break //!< command is not-allowed in section title, it will end the section title
197};
198
206
207// map of command to handler function
208static const std::map< std::string, DocCmdMap > docCmdMap =
209{
210 // command name handler function command spacing section handling
215 { "arg", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
216 { "attention", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
217 { "author", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
218 { "authors", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
233 { "copyright", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
234 { "showdate", { nullptr, CommandSpacing::Inline, SectionHandling::Allowed }},
235 { "date", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
240 { "diafile", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
243 { "docbookinclude", { nullptr, CommandSpacing::Inline, SectionHandling::Break }},
246 { "dotfile", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
253 { "exception", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
272 { "htmlinclude", { nullptr, CommandSpacing::Inline, SectionHandling::Break }},
279 { "important", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
280 { "include", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
283 { "includelineno", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
289 { "invariant", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
290 { "latexinclude", { nullptr, CommandSpacing::Inline, SectionHandling::Break }},
292 { "li", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
293 { "line", { nullptr, CommandSpacing::Invisible, SectionHandling::Escape }},
295 { "maninclude", { nullptr, CommandSpacing::Inline, SectionHandling::Break }},
300 { "mscfile", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
305 { "note", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
309 { "par", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
313 { "post", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
314 { "pre", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
331 { "remark", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
332 { "remarks", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
333 { "result", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
334 { "return", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
335 { "returns", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
337 { "rtfinclude", { nullptr, CommandSpacing::Inline, SectionHandling::Break }},
339 { "sa", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
341 { "see", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
348 { "since", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
349 { "snippet", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
350 { "snippetlineno", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
361 { "throw", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
362 { "throws", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
364 { "tparam", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
367 { "until", { nullptr, CommandSpacing::Block, SectionHandling::Escape }},
371 { "verbinclude", { nullptr, CommandSpacing::Inline, SectionHandling::Break }},
372 { "version", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
373 { "warning", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
375 { "xmlinclude", { nullptr, CommandSpacing::Inline, SectionHandling::Break }},
381 { "secreflist", { nullptr, CommandSpacing::Invisible, SectionHandling::Break }},
382 { "endsecreflist", { nullptr, CommandSpacing::Invisible, SectionHandling::Escape }},
383 { "dontinclude", { nullptr, CommandSpacing::Invisible, SectionHandling::Break }},
384 { "line", { nullptr, CommandSpacing::Invisible, SectionHandling::Escape }},
385 { "skip", { nullptr, CommandSpacing::Invisible, SectionHandling::Escape }},
386 { "skipline", { nullptr, CommandSpacing::Invisible, SectionHandling::Escape }},
387 { "until", { nullptr, CommandSpacing::Invisible, SectionHandling::Escape }},
388 { "vhdlflow", { nullptr, CommandSpacing::Block, SectionHandling::Break }},
389 { "enddot", { nullptr, CommandSpacing::Invisible, SectionHandling::Escape }},
390 { "endmsc", { nullptr, CommandSpacing::Invisible, SectionHandling::Escape }},
391 { "enduml", { nullptr, CommandSpacing::Invisible, SectionHandling::Escape }},
392 { "endicode", { nullptr, CommandSpacing::Invisible, SectionHandling::Escape }},
393 { "endcode", { nullptr, CommandSpacing::Invisible, SectionHandling::Escape }},
394 { "endverbatim", { nullptr, CommandSpacing::Invisible, SectionHandling::Escape }},
395 { "enddocbookonly", { nullptr, CommandSpacing::Invisible, SectionHandling::Escape }},
396 { "endhtmlonly", { nullptr, CommandSpacing::Invisible, SectionHandling::Escape }},
397 { "endlatexonly", { nullptr, CommandSpacing::Invisible, SectionHandling::Escape }},
398 { "endmanonly", { nullptr, CommandSpacing::Invisible, SectionHandling::Escape }},
399 { "endrtfonly", { nullptr, CommandSpacing::Invisible, SectionHandling::Escape }},
400 { "endxmlonly", { nullptr, CommandSpacing::Invisible, SectionHandling::Escape }},
402 { "endlink", { nullptr, CommandSpacing::Invisible, SectionHandling::Escape }},
407 { "plantumlfile", { nullptr, CommandSpacing::Block, SectionHandling::Break }}
408};
409
410#define YY_NO_INPUT 1
411#define YY_NO_UNISTD_H 1
412#define YY_NEVER_INTERACTIVE 1
413
414
424
432
439
440/* -----------------------------------------------------------------
441 *
442 * statics
443 */
444
451
452using HtmlContextStack = std::vector<HtmlContextInfo>;
453
455{
456 OutlineParserInterface *langParser = nullptr; // the language parser that is calling us
457 QCString inputString; // input string
458 QCString currentCmd; // the command used
460 int inputPosition = 0; // read pointer
461 QCString fileName; // file name that is read from
462 int lineNr = 0; // line number in the input
463 int raiseLevel = 0; // section level raise amount
464 QCString raisePrefix; // section label to append
465 bool inBody = FALSE; // was the comment found inside the body of a function?
466 OutputContext inContext; // are we inside the brief, details or xref part
467 bool briefEndsAtDot = FALSE; // does the brief description stop at a dot?
468 QCString formulaText; // Running text of a formula
469 QCString formulaPreText; // Start command of a formula
470 QCString formulaPostText; // End command of a formula
471 QCString formulaEnv; // environment name
472 int formulaNewLines = 0; // amount of new lines in the formula
473 QCString *pOutputString = nullptr; // pointer to string to which the output is appended.
474 QCString outputXRef; // temp argument of todo/test/../xrefitem commands
475 QCString blockName; // preformatted block name (e.g. verbatim, latexonly,...)
476 XRefKind xrefKind = XRef_Item; // kind of cross-reference command
478 GuardType guardType = Guard_If; // kind of guards for conditional section
479 QCString functionProto; // function prototype
480 GuardedSectionStack *guards = nullptr; // tracks nested conditional sections (if,ifnot,..)
481 Entry *current = nullptr; // working entry
482
485
493 Protection protection = Protection::Public;
494
497 int braceCount = 0;
500 int condCount = 0;
501
506
508 int roundCount = 0;
509 std::vector<int> htmlDetailsStack;
510
516
518
521 bool htmlAnchor = false;
522 bool CScode = false;
523};
524
525
526static std::mutex g_sectionMutex;
527static std::mutex g_formulaMutex;
528static std::mutex g_citeMutex;
529
530//-----------------------------------------------------------------------------
531
532static QCString stripQuotes(const char *s);
533static SectionType sectionLevelToType(int level);
534static void stripTrailingWhiteSpace(QCString &s);
535
536static void initParser(yyscan_t yyscanner);
537static bool checkStructuralIndicator(yyscan_t yyscanner);
538[[maybe_unused]] static bool makeStructuralIndicator(yyscan_t yyscanner,MakeEntryType maker);
539static void lineCount(yyscan_t yyscanner);
540static void addXRefItem(yyscan_t yyscanner,
541 const QCString &listName,const QCString &itemTitle,
542 const QCString &listTitle,bool append);
543static QCString addFormula(yyscan_t yyscanner);
544static void checkFormula(yyscan_t yyscanner);
545static void addSection(yyscan_t yyscanner, bool addYYtext = true);
546static inline void setOutput(yyscan_t yyscanner,OutputContext ctx);
547static void addAnchor(yyscan_t yyscanner,const QCString &anchor, const QCString &title="");
548static inline void addOutput(yyscan_t yyscanner,const char *s);
549static inline void addOutput(yyscan_t yyscanner,const QCString &s);
550static inline void addOutput(yyscan_t yyscanner,char c);
551static void endBrief(yyscan_t yyscanner);
552static void handleGuard(yyscan_t yyscanner,const QCString &expr);
553static int yyread(yyscan_t yyscanner,char *buf,int max_size);
554static void addCite(yyscan_t yyscanner);
555static void addIline(yyscan_t yyscanner,int lineNr);
556static void addIlineBreak(yyscan_t yyscanner,int lineNr);
557
558#define unput_string(yytext,yyleng) do { for (int i=(int)yyleng-1;i>=0;i--) unput(yytext[i]); } while(0)
559
560//-----------------------------------------------------------------------------
561
562#undef YY_INPUT
563#define YY_INPUT(buf,result,max_size) result=yyread(yyscanner,buf,max_size);
564
565// otherwise the filename would be the name of the converted file (*.cpp instead of *.l)
566static inline const char *getLexerFILE() {return __FILE__;}
567#include "doxygen_lex.h"
568
Represents an unstructured piece of information, about an entity found in the sources.
Definition entry.h:116
Wrapper class for the Entry type.
Definition types.h:793
Abstract interface for outline parsers.
Definition parserintf.h:42
This is an alternative implementation of QCString.
Definition qcstring.h:101
Interface for the comment block scanner.
std::stack< GuardedSection > GuardedSectionStack
Definition commentscan.h:48
static bool handlePrivate(yyscan_t yyscanner, const QCString &, const StringVector &)
static void handleGuard(yyscan_t yyscanner, const QCString &expr)
static bool handleHideIncludegraph(yyscan_t yyscanner, const QCString &, const StringVector &)
static const std::map< std::string, DocCmdMap > docCmdMap
static bool handleDetails(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleName(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleImage(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleStatic(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleFileInfoResult(yyscan_t yyscanner, const QCString &, const StringVector &optList, bool isSection)
static bool handleCopyDetails(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleProtectedSection(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleOverload(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleXRefItem(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleProtocol(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleWeakGroup(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleInternal(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleShowInitializer(yyscan_t yyscanner, const QCString &, const StringVector &)
SectionHandling
@ Escape
command is not-allowed in section title, it will be escaped
@ Replace
command will be handled in here / needs special handling here
@ Allowed
command is allowed without restrictions in section title
@ Break
command is not-allowed in section title, it will end the section title
static bool handleGroupgraph(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleQualifier(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleLineInfo(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleNoSubGrouping(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleMainpage(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleCite(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleTest(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleIRaise(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleHideCallgraph(yyscan_t yyscanner, const QCString &, const StringVector &)
static void addCite(yyscan_t yyscanner)
XRefKind
@ XRef_Item
@ XRef_Deprecated
@ XRef_Todo
@ XRef_Test
@ XRef_Bug
@ XRef_None
static bool handleCallgraph(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleIngroup(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleStruct(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleInterface(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleShowInlineSource(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleAddToGroup(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleDef(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleConcept(yyscan_t yyscanner, const QCString &, const StringVector &)
static void setOutput(yyscan_t yyscanner, OutputContext ctx)
static bool handleExtends(yyscan_t yyscanner, const QCString &, const StringVector &)
static QCString stripQuotes(const char *s)
static bool handleBrief(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleRefItem(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleIncludedBygraph(yyscan_t yyscanner, const QCString &, const StringVector &)
static void initParser(yyscan_t yyscanner)
static bool makeStructuralIndicator(yyscan_t yyscanner, MakeEntryType maker)
static bool handleUnion(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleHideDirectoryGraph(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleRelated(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleBug(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleReferencesRelation(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleHideIncludedBygraph(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleRaiseWarning(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleElseIf(yyscan_t yyscanner, const QCString &, const StringVector &)
static int yyread(yyscan_t yyscanner, char *buf, int max_size)
bool(* DocCmdFunc)(yyscan_t yyscanner, const QCString &name, const StringVector &optList)
static bool handleMemberOf(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleToc(yyscan_t yyscanner, const QCString &s, const StringVector &)
static bool handleParBlock(yyscan_t yyscanner, const QCString &, const StringVector &)
static const char * stateToString(int state)
static bool handleCategory(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handlePrivateSection(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleModule(yyscan_t yyscanner, const QCString &, const StringVector &)
static SectionType sectionLevelToType(int level)
static std::mutex g_formulaMutex
static bool handleInherit(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleEndIf(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleDirectoryGraph(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleTodo(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleIPrefix(yyscan_t yyscanner, const QCString &, const StringVector &)
static void addAnchor(yyscan_t yyscanner, const QCString &anchor, const QCString &title="")
static bool handleCopyDoc(yyscan_t yyscanner, const QCString &, const StringVector &)
GuardType
@ Guard_If
@ Guard_ElseIf
@ Guard_IfNot
static bool handleReferencedByRelation(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleEnum(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleFileInfoSection(yyscan_t yyscanner, const QCString &cmdName, const StringVector &optList)
static bool handleIfNot(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleFormatBlock(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleHideInlineSource(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleNoop(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleAnchor(yyscan_t yyscanner, const QCString &, const StringVector &)
static std::mutex g_citeMutex
static bool handleHideInitializer(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool checkStructuralIndicator(yyscan_t yyscanner)
static std::mutex g_sectionMutex
static bool handleCallergraph(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleParam(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleHideInheritanceGraph(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleIf(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handlePage(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handlePackage(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleHideEnumValues(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleSection(yyscan_t yyscanner, const QCString &, const StringVector &)
static void addOutput(yyscan_t yyscanner, const char *s)
static bool handleCollaborationgraph(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleHideGroupgraph(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleIFile(yyscan_t yyscanner, const QCString &, const StringVector &)
std::vector< HtmlContextInfo > HtmlContextStack
static bool handleFn(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleDeprecated(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleIncludegraph(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handlePure(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleHideCollaborationgraph(yyscan_t yyscanner, const QCString &, const StringVector &)
static void endBrief(yyscan_t yyscanner)
CommandSpacing
@ Inline
command appears inline in the output which can be a brief description.
@ XRef
command is a cross reference (todo, bug, test, deprecated, xrefitem).
@ Invisible
command sets some property but does not appear in the output.
@ Block
command starts a new paragraphs / ends a brief description.
EntryType(* MakeEntryType)()
static bool handleHideReferencedByRelation(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handlePublic(yyscan_t yyscanner, const QCString &s, const StringVector &)
static bool handleDir(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleRelatedAlso(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleInheritanceGraph(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleAddIndex(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleFileInfo(yyscan_t yyscanner, const QCString &cmdName, const StringVector &optList)
static const char * getLexerFILE()
OutputContext
@ OutputXRef
@ OutputDoc
@ OutputBrief
@ OutputInbody
static bool handleSubpage(yyscan_t yyscanner, const QCString &s, const StringVector &)
static void addXRefItem(yyscan_t yyscanner, const QCString &listName, const QCString &itemTitle, const QCString &listTitle, bool append)
static bool handleProtected(yyscan_t yyscanner, const QCString &, const StringVector &)
static QCString addFormula(yyscan_t yyscanner)
static bool handleEndParBlock(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleElse(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleClass(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleHeaderFile(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleCopyBrief(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleShowEnumValues(yyscan_t yyscanner, const QCString &, const StringVector &)
static void stripTrailingWhiteSpace(QCString &s)
static bool handleHideReferencesRelation(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleFile(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleRetval(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleIdlException(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleNamespace(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleHideCallergraph(yyscan_t yyscanner, const QCString &, const StringVector &)
static void addIline(yyscan_t yyscanner, int lineNr)
static void addIlineBreak(yyscan_t yyscanner, int lineNr)
static bool handleDefGroup(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handleExample(yyscan_t yyscanner, const QCString &, const StringVector &)
static void addSection(yyscan_t yyscanner, bool addYYtext=true)
static bool handleILine(yyscan_t yyscanner, const QCString &, const StringVector &)
static bool handlePublicSection(yyscan_t yyscanner, const QCString &s, const StringVector &)
static void checkFormula(yyscan_t yyscanner)
std::vector< std::string > StringVector
Definition containers.h:33
#define lineCount(s, len)
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34
Some helper functions for std::string.
CommandSpacing spacing
DocCmdMap(DocCmdFunc h, CommandSpacing s, SectionHandling sh)
SectionHandling sectionHandling
DocCmdFunc handler
OutputContext context
HtmlContextInfo(const QCString &tn, OutputContext ctx)
OutlineParserInterface * langParser
std::vector< int > htmlDetailsStack
HtmlContextStack htmlContextStack
QCString * pOutputString
OutputContext inContext
MakeEntryType currentMakeEntryType
GuardedSectionStack * guards
Protection protection
Protection
Definition types.h:32
A bunch of utility functions.
569%}
570
571 /* start command character */
572CMD ("\\"|"@")
573PRE ("pre"|"PRE")
574TABLE ("table"|"TABLE")
575TABLEDEL ("table"|"tr"|"th"|"td"|"TABLE"|"TR"|"TH"|"TD")
576P [pP]
577UL ("ul"|"UL")
578OL ("ol"|"OL")
579DL ("dl"|"DL")
580IMG ("img"|"IMG")
581HR ("hr"|"HR")
582PARA ("para"|"PARA")
583CODE ("code"|"CODE")
584ENDCODE "/"{CODE}
585CAPTION ("caption"|"CAPTION")
586CENTER ("center"|"CENTER")
587DIV ("div"|"DIV")
588DETAILS ("details"|"DETAILS")
589BLOCKQUOTE ("blockquote"|"BLOCKQUOTE")
590DETAILEDHTML {CENTER}|{DIV}|{PRE}|{UL}|{TABLE}|{OL}|{DL}|{P}|[Hh][1-6]|{IMG}|{HR}|{PARA}|{BLOCKQUOTE}
591DETAILEDHTMLOPT {CODE}
592DETAILEDHTMLOPTEND {ENDCODE}
593SUMMARY ("summary"|"SUMMARY")
594REMARKS ("remarks"|"REMARKS")
595AHTML [aA]{BN}*
596ANCHTML ("id"|"name"|"ID"|"NAME")"="("\""{LABELID}"\""|"'"{LABELID}"'"|{LABELID})
597BN [ \t\n\r]
598B [ \t]
599Bopt {B}*
600ATTR ({B}+[^>\n]*)?
601DOCNL "\n"|"\\ilinebr"
602LC "\\"{B}*"\n"
603NW [^a-z_A-Z0-9]
604FILESCHAR [a-z_A-Z0-9\x80-\xFF\\:\\\/\-\+=@&#~]
605FILEECHAR [a-z_A-Z0-9\x80-\xFF\-\+=@&#~]
606FILE ({FILESCHAR}*{FILEECHAR}+("."{FILESCHAR}*{FILEECHAR}+)*)|("\""[^\n\"]*"\"")
607ID [$a-z_A-Z\x80-\xFF][$a-z_A-Z0-9\x80-\xFF]*
608LABELID [a-z_A-Z\x80-\xFF][a-z_A-Z0-9\x80-\xFF\-]*
609CITESCHAR [a-z_A-Z0-9\x80-\xFF\-\?]
610CITEECHAR [a-z_A-Z0-9\x80-\xFF\-\+:\/\?]*
611CITEID {CITESCHAR}{CITEECHAR}*("."{CITESCHAR}{CITEECHAR}*)*|"\""{CITESCHAR}{CITEECHAR}*("."{CITESCHAR}{CITEECHAR}*)*"\""
612SCOPEID {ID}({ID}*{BN}*"::"{BN}*)*({ID}?)
613SCOPENAME "$"?(({ID}?{BN}*("::"|"."){BN}*)*)((~{BN}*)?{ID})
614TMPLSPEC "<"{BN}*[^>]+{BN}*">"
615MAILADDR ("mailto:")?[a-z_A-Z0-9\x80-\xff.+-]+"@"[a-z_A-Z0-9\x80-\xff-]+("."[a-z_A-Z0-9\x80-\xff\-]+)+[a-z_A-Z0-9\x80-\xff\-]+
616RCSTAG "$"{ID}":"[^\n$]+"$"
617MODULE_ID ({ID}".")*{ID}
618LINENR {Bopt}[1-9][0-9]*
619IFILELINE ("\\ifile \""[^"]*"\" \\iline "[0-9]+" "("iprefix \""[^"]*"\" ")?("iraise "[0-9]+" ")?)
620
621 // C start comment
622CCS "/\*"
623 // C end comment
624CCE "*\/"
625
626 // end of section title with asterisk
627STAopt [^\n@\\*]*
628 // end of section title without asterisk
629STopt [^\n@\\]*
630
631%option noyywrap
632
633 /* comment parsing states. */
634%x Comment
635%x PageDocArg1
636%x PageDocArg2
637%x RelatesParam1
638%x ClassDocArg1
639%x ClassDocArg2
640%x ClassDocArg3
641%x CategoryDocArg1
642%x XRefItemParam1
643%x XRefItemParam2
644%x XRefItemParam3
645%x FileDocArg1
646%x ParamArg1
647%x EnumDocArg1
648%x NameSpaceDocArg1
649%x PackageDocArg1
650%x ConceptDocArg1
651%x ModuleDocArg1
652%x GroupDocArg1
653%x GroupDocArg2
654%x SectionLabel
655%x SectionTitle
656%x SubpageLabel
657%x SubpageTitle
658%x FormatBlock
659%x LineParam
660%x GuardParam
661%x GuardParamEnd
662%x SkipGuardedSection
663%x SkipInternal
664%x NameParam
665%x InGroupParam
666%x FnParam
667%x OverloadParam
668%x InheritParam
669%x ExtendsParam
670%x ReadFormulaShort
671%x ReadFormulaShortSection
672%x ReadFormulaRound
673%x ReadFormulaRoundSection
674%x ReadFormulaLong
675%x AnchorLabel
676%x AnchorLabelSection
677%x HtmlComment
678%x HtmlA
679%x SkipLang
680%x CiteLabel
681%x CiteLabelSection
682%x CopyDoc
683%x GuardExpr
684%x CdataSection
685%x Noop
686%x RaiseWarning
687%x RaiseWarningSection
688%x Qualifier
689%x LinkSection
690%x IFile
691%x IFileSection
692%x ILine
693%x ILineSection
694%x IRaise
695%x IRaisePrefix
696
698
699 /* What can happen in while parsing a comment block:
700 * commands (e.g. @page, or \page)
701 * escaped commands (e.g. @@page or \\page).
702 * formulas (e.g. \f$...\f$ \f[...\f] \f{...\f} \f(...\f) )
703 * directories (e.g. \doxygen\src\‍)
704 * autolist end. (e.g. a dot on an otherwise empty line)
705 * newlines.
706 * end of brief description due to blank line.
707 * end of brief description due to some command (@command, or <command>).
708 * words and whitespace and other characters (#,?!, etc).
709 * grouping commands (e.g. @{ and @})
710 * language switch (e.g. \~english or \~).
711 * mail address (e.g. doxygen@gmail.com).
712 * quoted text, such as "foo@bar"
713 * XML commands, <summary></summary><remarks></remarks>
714 */
715
716<Comment>{CMD}{CMD}[a-z_A-Z]+{B}* { // escaped command
717 addOutput(yyscanner,yytext);
718 }
719<Comment>{CMD}{CMD}"~"[a-z_A-Z]* { // escaped command
720 addOutput(yyscanner,yytext);
721 }
722<Comment>{MAILADDR} { // mail address
723 addOutput(yyscanner,yytext);
724 }
725<Comment>"\""[^"\n]*"\"" { // quoted text
726 addOutput(yyscanner,yytext);
727 }
728<Comment>("\\"[a-z_A-Z]+)+"\\" { // directory (or chain of commands!)
729 addOutput(yyscanner,yytext);
730 }
731<Comment>"<"{DETAILEDHTML}{ATTR}">" { // HTML command that ends a brief description
732 QCString htmlOpenTag(yytext);
733 int spacePos = htmlOpenTag.find(' '); // check for optional attributes
734 if (spacePos==-1) spacePos=yyleng-1;
735 QCString htmlTagName = htmlOpenTag.mid(1,spacePos-1);
736 //printf("found open tag '%s'\n",qPrint(htmlTagName));
737 yyextra->htmlContextStack.emplace_back(htmlTagName,yyextra->inContext);
738 if (yyextra->inContext==OutputBrief)
739 {
740 setOutput(yyscanner,OutputDoc);
741 }
742 // continue with the same input
743 REJECT;
744 }
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition qcstring.h:226
745<Comment>"</"{DETAILEDHTML}">" { // HTML command that ends a brief description
746 QCString htmlCloseTag(yytext);
747 QCString htmlTagName = htmlCloseTag.mid(2,htmlCloseTag.length()-3);
748 //printf("found close tag '%s'\n",qPrint(htmlTagName));
749 if (!yyextra->htmlContextStack.empty() &&
750 yyextra->htmlContextStack.back().tagName==htmlTagName)
751 {
752 if (yyextra->inContext==OutputXRef && yyextra->htmlContextStack.back().context!=OutputXRef)
753 {
754 //printf("switching back to OutputDoc\n");
755 setOutput(yyscanner,OutputDoc);
756 }
757 yyextra->htmlContextStack.pop_back();
758 }
759 REJECT;
760 }
761<Comment>"<"{DETAILEDHTMLOPT}">" { // HTML <code> command that ends a brief description
762 // without attributes
763 if (yyextra->current->lang==SrcLangExt::CSharp)
764 {
765 yyextra->CScode=true;
766 setOutput(yyscanner,OutputDoc);
767 addOutput(yyscanner,"@code{cs}");
768 }
769 else
770 {
771 // continue with the same input
772 REJECT;
773 }
774 }
775<Comment>"<"{DETAILEDHTMLOPTEND}">" { // HTML command that ends a brief description
776 if (yyextra->CScode)
777 {
778 addOutput(yyscanner,"@endcode");
779 yyextra->CScode=false;
780 }
781 else
782 {
783 yyextra->CScode=false;
784 // continue with the same input
785 REJECT;
786 }
787 }
788<Comment>"<"{DETAILEDHTMLOPT}{ATTR}">" { // HTML <code> command that ends a brief description
789 // with attributes, so cannot be CS.
790 if (yyextra->current->lang==SrcLangExt::CSharp)
791 {
792 setOutput(yyscanner,OutputDoc);
793 }
794 // continue with the same input
795 REJECT;
796 }
797<Comment>"<"{DETAILS}{ATTR}">" { // start of a HTML style details description
798 yyextra->htmlDetailsStack.push_back(0);
799 yyextra->htmlContextStack.emplace_back("details",yyextra->inContext);
800 if (yyextra->inContext==OutputBrief)
801 {
802 setOutput(yyscanner,OutputDoc);
803 }
804 addOutput(yyscanner,yytext);
805 }
806<Comment>"</"{DETAILS}">" { // end of a HTML style details description
807 if (!yyextra->htmlDetailsStack.empty())
808 {
809 yyextra->htmlDetailsStack.pop_back();
810 }
811 if (!yyextra->htmlContextStack.empty() &&
812 yyextra->htmlContextStack.back().tagName=="details")
813 {
814 if (yyextra->inContext==OutputXRef && yyextra->htmlContextStack.back().context!=OutputXRef)
815 {
816 //printf("switching back to OutputDoc\n");
817 setOutput(yyscanner,OutputDoc);
818 }
819 yyextra->htmlContextStack.pop_back();
820 }
821 addOutput(yyscanner,yytext);
822 }
823<Comment>"<"{AHTML} { // potential start of HTML anchor, see issue 9200
824 yyextra->htmlAnchorStr = yytext;
825 yyextra->htmlAnchor = false;
826 BEGIN(HtmlA);
827 }
828<HtmlA>{ANCHTML} { // only labels that can be converted to doxygen anchor
829 yyextra->htmlAnchorStr += yytext;
830 QCString tag(yytext);
831 int s=tag.find("=");
832 char c=tag[s+1];
833 QCString id;
834 if (c=='\'' || c=='"') // valid start
835 {
836 int e=tag.find(c,s+2);
837 if (e!=-1) // found matching end
838 {
839 id=tag.mid(s+2,e-s-2); // extract id
840 addAnchor(yyscanner,id);
841 }
842 }
843 else
844 {
845 id=tag.mid(s+1);
846 addAnchor(yyscanner,id);
847 }
848 if (!id.isEmpty() && !yyextra->htmlAnchor)
849 {
850 // only use first analogous to what is in docparser
851 addOutput(yyscanner,"@anchor ");
852 addOutput(yyscanner,id.data());
853 addOutput(yyscanner," ");
854 yyextra->htmlAnchor = true;
855 }
856 }
857<HtmlA>("\""[^\n\"]*"\""|"'"[^\n']*"'") {
858 yyextra->htmlAnchorStr += yytext;
859 }
860<HtmlA>">"|"/>" {
861 if (!yyextra->htmlAnchor)
862 {
863 addOutput(yyscanner,yyextra->htmlAnchorStr);
864 addOutput(yyscanner,yytext);
865 }
866 else
867 {
868 if (yyleng == 1) // to keep <a></a> pairs, otherwise single </a> present
869 {
870 addOutput(yyscanner,"<a>");
871 }
872 }
873 BEGIN(Comment);
874 }
875<HtmlA>{DOCNL} { // newline
876 yyextra->htmlAnchorStr += yytext;
877 if (*yytext == '\n') yyextra->lineNr++;
878 }
879<HtmlA>. { // catch-all for anything else
880 yyextra->htmlAnchorStr += yytext;
881 }
882<Comment>"<"{SUMMARY}">" { // start of a .NET XML style brief description
883 if (yyextra->htmlDetailsStack.empty())
884 {
885 setOutput(yyscanner,OutputBrief);
886 }
887 else // HTML5 style <summary> as part of <details> section.
888 {
889 addOutput(yyscanner,yytext);
890 }
891 }
892<Comment>"<"{REMARKS}">" { // start of a .NET XML style detailed description
893 setOutput(yyscanner,OutputDoc);
894 addOutput(yyscanner,yytext);
895 }
896<Comment>"</"{SUMMARY}">" { // start of a .NET XML style detailed description
897 if (!yyextra->htmlDetailsStack.empty())
898 {
899 addOutput(yyscanner,yytext);
900 }
901 else
902 {
903 setOutput(yyscanner,OutputDoc);
904 }
905 }
906<Comment>"</"{REMARKS}">" { // end of a brief or detailed description
907 setOutput(yyscanner,OutputDoc);
908 addOutput(yyscanner,yytext);
909 }
910<Comment>"<"{CAPTION}{ATTR}">" {
911 QCString tag(yytext);
912 int s=tag.find("id=");
913 if (s!=-1) // command has id attribute
914 {
915 char c=tag[s+3];
916 if (c=='\'' || c=='"') // valid start
917 {
918 int e=tag.find(c,s+4);
919 if (e!=-1) // found matching end
920 {
921 QCString id=tag.mid(s+4,e-s-4); // extract id
922 addAnchor(yyscanner,id);
923 }
924 }
925 }
926 addOutput(yyscanner,yytext);
927 }
928<Comment>"<"{PRE}{ATTR}">" {
929 yyextra->insidePre=TRUE;
930 addOutput(yyscanner,yytext);
931 }
932<Comment>"</"{PRE}">" {
933 yyextra->insidePre=FALSE;
934 addOutput(yyscanner,yytext);
935 }
936<Comment>{RCSTAG} { // RCS tag which end a brief description
937 setOutput(yyscanner,OutputDoc);
938 REJECT;
939 }
940<Comment>"<!--" {
941 BEGIN(HtmlComment);
942 }
943<Comment>"<!\[CDATA\[" {
944 BEGIN(CdataSection);
945 }
946<Comment>{B}*{CMD}"endinternal"{B}* {
947 addOutput(yyscanner," \\endinternal ");
948 if (!yyextra->inInternalDocs)
949 warn(yyextra->fileName,yyextra->lineNr,
950 "found \\endinternal without matching \\internal"
951 );
952 yyextra->inInternalDocs = FALSE;
953 }
#define warn(file, line, fmt,...)
Definition message.h:97
954<Comment>{B}*"\\ilinebr "{B}* { // preserve spacing around \\ilinebr
955 addOutput(yyscanner,yytext);
956 }
957<Comment>(\n|"\\ilinebr ")/({B}*(\n|{IFILELINE}?"\\ilinebr "))+ { // at least one blank line (or blank line command)
958 if (yyextra->inContext==OutputBrief)
959 {
960 endBrief(yyscanner);
961 }
962 else
963 {
964 REJECT;
965 }
966 }
967<Comment>{B}*{CMD}[a-z_A-Z]+"{"[^}]*"}"{B}* |
968<Comment>{B}*{CMD}[a-z_A-Z]+{B}* { // potentially interesting command
969 // the {B}* in the front was added for bug620924
970 QCString fullMatch = QCString(yytext);
971 int idx = fullMatch.find('{');
972 /* handle `f{` command as special case */
973 if ((idx > 1) && (yytext[idx-1] == 'f') && (yytext[idx-2] == '\\' || yytext[idx-2] =='@')) REJECT;
974 int idxEnd = fullMatch.find("}",idx+1);
975 QCString cmdName;
976 StringVector optList;
977 if (idx == -1) // no options
978 {
979 cmdName = QCString(yytext).stripWhiteSpace().mid(1); // to remove {CMD}
980 }
981 else // options present
982 {
983 cmdName = fullMatch.left(idx).stripWhiteSpace().mid(1); // to remove {CMD}
984 QCString optStr = fullMatch.mid(idx+1,idxEnd-idx-1).stripWhiteSpace();
985 optList = split(optStr.str(),",");
986 }
987 auto it = docCmdMap.find(cmdName.str());
988 //printf("lookup command '%s' found=%d\n",qPrint(cmdName),it!=docCmdMap.end());
989 if (it!=docCmdMap.end()) // special action is required
990 {
991 int i=0;
992 while (yytext[i]==' ' || yytext[i]=='\t') i++;
993 yyextra->spaceBeforeCmd = QCString(yytext).left(i);
994 CommandSpacing spacing = it->second.spacing;
995 if ((spacing==CommandSpacing::Block || spacing==CommandSpacing::XRef) &&
996 !(yyextra->inContext==OutputXRef && cmdName=="parblock"))
997 {
998 yyextra->briefEndsAtDot=FALSE;
999 bool insideXRef = yyextra->inContext==OutputXRef && spacing==CommandSpacing::XRef;
1000 // this command forces the end of brief description
1001 setOutput(yyscanner,insideXRef ? OutputXRef : OutputDoc);
1002 }
1003 //if (i>0) addOutput(yyscanner,QCString(yytext).left(i)); // removed for bug 689341
1004 if (it->second.handler && it->second.handler(yyscanner, cmdName, optList))
1005 {
1006 // implicit split of the comment block into two
1007 // entries. Restart the next block at the start
1008 // of this command.
1009 yyextra->parseMore=TRUE;
1010
1011 yyextra->inputPosition=yyextra->prevPosition + (int)(yy_bp - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf);
1012 yyterminate();
1013 }
1014 else if (it->second.handler==nullptr)
1015 {
1016 // command without handler, to be processed
1017 // later by parsedoc.cpp
1018 addOutput(yyscanner,yytext);
1019 }
1020 }
1021 else // command not relevant
1022 {
1023 addOutput(yyscanner,yytext);
1024 }
1025 }
int find(char c, int index=0, bool cs=TRUE) const
Definition qcstring.cpp:43
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
Definition qcstring.h:245
const std::string & str() const
Definition qcstring.h:537
QCString left(size_t len) const
Definition qcstring.h:214
#define yyterminate()
StringVector split(const std::string &s, const std::string &delimiter)
split input string s by string delimiter delimiter.
Definition util.cpp:7094
1026<Comment>{B}*({CMD}{CMD})"f"[$\[{] { // escaped formula command
1027 addOutput(yyscanner,yytext);
1028 }
1029<Comment>{B}*{CMD}"~"[a-z_A-Z-]* { // language switch command
1030 QCString langId = QCString(yytext).stripWhiteSpace().mid(2);
1031 if (!langId.isEmpty() &&
1032 qstricmp(Config_getEnumAsString(OUTPUT_LANGUAGE),langId)!=0)
1033 { // enable language specific section
1034 if (!Config_isAvailableEnum(OUTPUT_LANGUAGE,langId))
1035 {
1036 warn(yyextra->fileName,yyextra->lineNr,
1037 "non supported language '{}' specified in '{}'",langId,QCString(yytext).stripWhiteSpace());
1038 }
1039 BEGIN(SkipLang);
1040 }
1041 }
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
#define Config_getEnumAsString(name)
Definition config.h:36
#define Config_isAvailableEnum(name, value)
Definition config.h:45
int qstricmp(const char *s1, const char *s2)
Definition qcstring.cpp:442
std::string_view stripWhiteSpace(std::string_view s)
Given a string view s, returns a new, narrower view on that string, skipping over any leading or trai...
Definition stringutil.h:72
1042<Comment>{B}*{CMD}"f{"[^}\n]+"}"("{"?) { // start of a formula with custom environment
1043 setOutput(yyscanner,OutputDoc);
1044 yyextra->formulaText="";
1045 yyextra->formulaPreText="\\begin";
1046 yyextra->formulaPostText="";
1047 yyextra->formulaEnv=QCString(yytext).stripWhiteSpace().mid(2);
1048 if (yyextra->formulaEnv.at(yyextra->formulaEnv.length()-1)=='{')
1049 {
1050 // remove trailing open brace
1051 yyextra->formulaEnv=yyextra->formulaEnv.left(yyextra->formulaEnv.length()-1);
1052 }
1053 yyextra->formulaPreText+=yyextra->formulaEnv;
1054 yyextra->formulaNewLines=0;
1055 BEGIN(ReadFormulaLong);
1056 }
1057<Comment>{B}*{CMD}"f$" { // start of a inline formula
1058 yyextra->formulaText="";
1059 yyextra->formulaPreText="$";
1060 yyextra->formulaPostText="";
1061 yyextra->formulaNewLines=0;
1062 BEGIN(ReadFormulaShort);
1063 }
1064<Comment>{B}*{CMD}"f(" { // start of a inline formula
1065 yyextra->formulaText="";
1066 yyextra->formulaPreText="";
1067 yyextra->formulaPostText="";
1068 yyextra->formulaNewLines=0;
1069 BEGIN(ReadFormulaRound);
1070 }
1071<Comment>{B}*{CMD}"f[" { // start of a block formula
1072 setOutput(yyscanner,OutputDoc);
1073 yyextra->formulaText="";
1074 yyextra->formulaPreText="\\[";
1075 yyextra->formulaPostText="";
1076 yyextra->formulaNewLines=0;
1077 BEGIN(ReadFormulaLong);
1078 }
1079<Comment>{B}*{CMD}"{" { // begin of a group
1080 //yyextra->langParser->handleGroupStartCommand(yyextra->memberGroupHeader);
1081 yyextra->docGroup.open(yyextra->current,yyextra->fileName,yyextra->lineNr);
1082 }
1083<Comment>{B}*{CMD}"}" { // end of a group
1084 //yyextra->langParser->handleGroupEndCommand();
1085 yyextra->docGroup.close(yyextra->current,yyextra->fileName,yyextra->lineNr,TRUE);
1086 yyextra->docGroup.clearHeader();
1087 yyextra->parseMore=TRUE;
1088 yyextra->needNewEntry = TRUE;
1089 yyextra->inputPosition=yyextra->prevPosition + (int)(yy_bp - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf) + (int)strlen(yytext);
1090 yyterminate();
1091 }
1092<Comment>{B}*{CMD}[$@\\&~<>#%] { // escaped character
1093 addOutput(yyscanner,yytext);
1094 }
1095<Comment>[a-z_A-Z]+ { // normal word
1096 addOutput(yyscanner,yytext);
1097 }
1098<Comment>^{B}*"."{Bopt}/\n { // explicit end autolist: e.g " ."
1099 addOutput(yyscanner,yytext);
1100 }
1101<Comment>^{B}*[1-9][0-9]*"."{B}+ |
1102<Comment>^{B}*[*+]{B}+ { // start of autolist
1103 if (!yyextra->markdownSupport)
1104 {
1105 REJECT;
1106 }
1107 else
1108 {
1109 if (yyextra->inContext!=OutputXRef)
1110 {
1111 yyextra->briefEndsAtDot=FALSE;
1112 setOutput(yyscanner,OutputDoc);
1113 }
1114 addOutput(yyscanner,yytext);
1115 }
1116 }
1117<Comment>^{B}*"-"{B}+ { // start of autolist
1118 if (yyextra->inContext!=OutputXRef)
1119 {
1120 yyextra->briefEndsAtDot=FALSE;
1121 setOutput(yyscanner,OutputDoc);
1122 }
1123 addOutput(yyscanner,yytext);
1124 }
1125<Comment>^{B}*([\-:|]{B}*)*("--"|"---")({B}*[\-:|])*{Bopt}/\n { // horizontal line (dashed)
1126 addOutput(yyscanner,yytext);
1127 }
1128<Comment>{CMD}"---" { // escaped mdash
1129 addOutput(yyscanner,yytext);
1130 }
1131<Comment>{CMD}"--" { // escaped mdash
1132 addOutput(yyscanner,yytext);
1133 }
1134<Comment>"---" { // mdash
1135 addOutput(yyscanner,yyextra->insidePre || yyextra->markdownSupport ? yytext : "&mdash;");
1136 }
1137<Comment>"--" { // ndash
1138 addOutput(yyscanner,yyextra->insidePre || yyextra->markdownSupport ? yytext : "&ndash;");
1139 }
1140<Comment>"-#"{B}+ { // numbered item
1141 if (yyextra->inContext!=OutputXRef)
1142 {
1143 yyextra->briefEndsAtDot=FALSE;
1144 setOutput(yyscanner,OutputDoc);
1145 }
1146 addOutput(yyscanner,yytext);
1147 }
1148<Comment>[?!][a-z_A-Z0-9\‍(\‍)=<] |
1149<Comment>("."+)[a-z_A-Z0-9\‍)] { // . at start or in the middle of a word, or ellipsis
1150 // ? or ! in middle of word or followed by equal sign or round bracket.
1151 addOutput(yyscanner,yytext);
1152 }
1153<Comment>{CMD}[\.?!] { // we have to be a bit careful with the special commands
1154 // \. \? and \! as they might otherwise terminate a brief description
1155 addOutput(yyscanner,yytext);
1156 }
1157<Comment>".\\"[ \t] { // . with escaped space.
1158 addOutput(yyscanner,yytext[0]);
1159 addOutput(yyscanner,yytext[2]);
1160 }
1161<Comment>"."[,:;] { // . with some puntuations such as "e.g.," or "e.g.:"
1162 addOutput(yyscanner,yytext);
1163 }
1164<Comment>"...\\"[ \t] { // ellipsis with escaped space.
1165 addOutput(yyscanner,"... ");
1166 }
1167<Comment>"..."/[^\.] { // ellipsis
1168 addOutput(yyscanner,"...");
1169 }
1170<Comment>".."[\.]?/[^ \t\n] { // internal ellipsis
1171 addOutput(yyscanner,yytext);
1172 }
1173<Comment>(\n|"\\ilinebr ")({B}*(\n|"\\ilinebr "))+ { // at least one blank line (or blank line command)
1174 if (yyextra->inContext==OutputXRef)
1175 {
1176 // see bug 613024, we need to put the newlines after ending the XRef section.
1177 if (!yyextra->insideParBlock) setOutput(yyscanner,OutputDoc);
1178 yy_size_t i;
1179 for (i=0;i<(yy_size_t)yyleng;)
1180 {
1181 if (yytext[i]=='\n') addOutput(yyscanner,'\n'),i++;
1182 else if (strncmp(yytext+i,"\\ilinebr ",9)==0) addOutput(yyscanner,"\\ilinebr "),i+=9;
1183 else i++;
1184 }
1185 }
1186 else if (yyextra->inContext!=OutputBrief)
1187 {
1188 yy_size_t i;
1189 for (i=0;i<(yy_size_t)yyleng;)
1190 {
1191 if (yytext[i]=='\n') addOutput(yyscanner,'\n'),i++;
1192 else if (strncmp(yytext+i,"\\ilinebr ",9)==0) addOutput(yyscanner,"\\ilinebr "),i+=9;
1193 else i++;
1194 }
1195 setOutput(yyscanner,OutputDoc);
1196 }
1197 else // yyextra->inContext==OutputBrief
1198 { // only go to the detailed description if we have
1199 // found some brief description and not just whitespace
1200 endBrief(yyscanner);
1201 }
1202 lineCount(yyscanner);
1203 }
1204<Comment>"."[?!] |
1205<Comment>[\.?!] { // potential end of a JavaDoc style comment
1206 addOutput(yyscanner,yytext);
1207 if (yyextra->briefEndsAtDot)
1208 {
1209 setOutput(yyscanner,OutputDoc);
1210 yyextra->briefEndsAtDot=FALSE;
1211 }
1212 }
1213<Comment>{DOCNL} { // newline
1214 addOutput(yyscanner,yytext);
1215 if (*yytext == '\n') yyextra->lineNr++;
1216 }
1217<Comment>"<"[/]?{TABLEDEL}">" { // In case in xrefitem type some special handling is required
1218 if (yyextra->inContext==OutputXRef)
1219 {
1220 setOutput(yyscanner,OutputDoc);
1221 addOutput(yyscanner,yytext);
1222 }
1223 else
1224 {
1225 REJECT;
1226 }
1227 }
1228<Comment>. { // catch-all for anything else
1229 addOutput(yyscanner,*yytext);
1230 }
1231
1232
1233 /* -------------- Rules for handling HTML comments ----------- */
1234
1235<HtmlComment>"---"[!]?">"{B}* {
1236 warn(yyextra->fileName,yyextra->lineNr,
1237 "incorrect HTML end comment --->"
1238 );
1239 }
1240<HtmlComment>"--"[!]?">"{B}* { BEGIN( Comment ); }
1241<HtmlComment>{DOCNL} {
1242 if (*yytext=='\n')
1243 {
1244 yyextra->lineNr++;
1245 addOutput(yyscanner," \\iline "+QCString().setNum(yyextra->lineNr)+" ");
1246 }
1247 }
1248<HtmlComment>[^\\\n\-]+ { // ignore unimportant characters
1249 }
1250<HtmlComment>. { // ignore every else
1251 }
1252
1253<CdataSection>"\]\]>" {
1254 BEGIN( Comment );
1255 }
1256<CdataSection>{DOCNL} {
1257 addOutput(yyscanner,'\n');
1258 if (*yytext=='\n') yyextra->lineNr++;
1259 }
1260<CdataSection>[<>&] { // the special XML characters for iwhich the CDATA section is especially used
1261 addOutput(yyscanner,'\\');
1262 addOutput(yyscanner,*yytext);
1263 }
1264<CdataSection>[^\\\n\]<>&]+ {
1265 addOutput(yyscanner,yytext);
1266 }
1267<CdataSection>. {
1268 addOutput(yyscanner,*yytext);
1269 }
1270
1271 /* -------------- Rules for handling formulas ---------------- */
1272
1273<ReadFormulaShort,ReadFormulaShortSection>{CMD}"f$" { // end of inline formula
1274 yyextra->formulaPostText+="$";
1275 QCString form = addFormula(yyscanner);
1276 addOutput(yyscanner," "+form);
1277 if (YY_START == ReadFormulaShort)
1278 {
1279 BEGIN(Comment);
1280 }
1281 else
1282 {
1283 yyextra->sectionTitle+= " "+form;
1284 BEGIN(SectionTitle);
1285 }
1286 }
1287<ReadFormulaRound,ReadFormulaRoundSection>{CMD}"f)" { // end of inline formula
1288 QCString form = addFormula(yyscanner);
1289 addOutput(yyscanner," "+form);
1290 if (YY_START == ReadFormulaRound)
1291 {
1292 BEGIN(Comment);
1293 }
1294 else
1295 {
1296 yyextra->sectionTitle+= " "+form;
1297 BEGIN(SectionTitle);
1298 }
1299 }
1300<ReadFormulaLong>{CMD}"f]" { // end of block formula
1301 yyextra->formulaPostText+="\\]";
1302 addOutput(yyscanner," "+addFormula(yyscanner));
1303 BEGIN(Comment);
1304 }
1305<ReadFormulaLong>{CMD}"f}" { // end of custom env formula
1306 yyextra->formulaPostText+="\\end";
1307 yyextra->formulaPostText+=yyextra->formulaEnv;
1308 addOutput(yyscanner," "+addFormula(yyscanner));
1309 BEGIN(Comment);
1310 }
1311<ReadFormulaLong,ReadFormulaShort,ReadFormulaShortSection,ReadFormulaRound,ReadFormulaRoundSection>[^\\@\n]+ { // any non-special character
1312 yyextra->formulaText+=yytext;
1313 }
1314<ReadFormulaLong,ReadFormulaShort,ReadFormulaShortSection,ReadFormulaRound,ReadFormulaRoundSection>\n { // new line
1315 yyextra->formulaNewLines++;
1316 yyextra->formulaText+=*yytext;
1317 yyextra->lineNr++;
1318 addIline(yyscanner,yyextra->lineNr);
1319 }
1320<ReadFormulaLong,ReadFormulaShort,ReadFormulaShortSection,ReadFormulaRound,ReadFormulaRoundSection>. { // any other character
1321 yyextra->formulaText+=*yytext;
1322 }
1323
1324 /* ------------ handle argument of enum command --------------- */
1325
1326<EnumDocArg1>{SCOPEID} { // handle argument
1327 makeStructuralIndicator(yyscanner,yyextra->currentMakeEntryType);
1328 yyextra->current->name = yytext;
1329 BEGIN( Comment );
1330 }
1331<EnumDocArg1>{LC} { // line continuation
1332 yyextra->lineNr++;
1333 addOutput(yyscanner,'\n');
1334 }
1335<EnumDocArg1>{DOCNL} { // missing argument
1336 warn(yyextra->fileName,yyextra->lineNr,
1337 "missing argument after '\\enum'."
1338 );
1339 unput_string(yytext,yyleng);
1340 BEGIN( Comment );
1341 }
#define unput_string(yytext, yyleng)
1342<EnumDocArg1>. { // ignore other stuff
1343 }
1344
1345 /* ------------ handle argument of namespace command --------------- */
1346
1347<NameSpaceDocArg1>{SCOPENAME} { // handle argument
1348 makeStructuralIndicator(yyscanner,yyextra->currentMakeEntryType);
1349 lineCount(yyscanner);
1350 yyextra->current->name = substitute(removeRedundantWhiteSpace(QCString(yytext)),QCString("."),QCString("::"));
1351 BEGIN( Comment );
1352 }
QCString substitute(const QCString &s, const QCString &src, const QCString &dst)
substitute all occurrences of src in s by dst
Definition qcstring.cpp:477
QCString removeRedundantWhiteSpace(const QCString &s)
Definition util.cpp:578
1353<NameSpaceDocArg1>{LC} { // line continuation
1354 yyextra->lineNr++;
1355 addOutput(yyscanner,'\n');
1356 }
1357<NameSpaceDocArg1>{DOCNL} { // missing argument
1358 warn(yyextra->fileName,yyextra->lineNr,
1359 "missing argument after '\\namespace'."
1360 );
1361 unput_string(yytext,yyleng);
1362 BEGIN( Comment );
1363 }
1364<NameSpaceDocArg1>. { // ignore other stuff
1365 }
1366
1367 /* ------------ handle argument of package command --------------- */
1368
1369<PackageDocArg1>{ID}("."{ID})* { // handle argument
1370 yyextra->current->name = yytext;
1371 BEGIN( Comment );
1372 }
1373<PackageDocArg1>{LC} { // line continuation
1374 yyextra->lineNr++;
1375 addOutput(yyscanner,'\n');
1376 }
1377<PackageDocArg1>{DOCNL} { // missing argument
1378 warn(yyextra->fileName,yyextra->lineNr,
1379 "missing argument after \\package."
1380 );
1381 unput_string(yytext,yyleng);
1382 //addOutput(yyscanner,'\n');
1383 //if (*yytext=='\n') yyextra->lineNr++;
1384 BEGIN( Comment );
1385 }
1386<PackageDocArg1>. { // ignore other stuff
1387 }
1388
1389 /* ------------ handle argument of concept command --------------- */
1390
1391<ConceptDocArg1>{SCOPEID} { // handle argument
1392 makeStructuralIndicator(yyscanner,yyextra->currentMakeEntryType);
1393 yyextra->current->name = yytext;
1394 BEGIN( Comment );
1395 }
1396<ConceptDocArg1>{LC} { // line continuation
1397 yyextra->lineNr++;
1398 addOutput(yyscanner,'\n');
1399 }
1400<ConceptDocArg1>{DOCNL} { // missing argument
1401 warn(yyextra->fileName,yyextra->lineNr,
1402 "missing argument after '\\concept'."
1403 );
1404 unput_string(yytext,yyleng);
1405 BEGIN( Comment );
1406 }
1407<ConceptDocArg1>. { // ignore other stuff
1408 }
1409
1410 /* ------------ handle argument of module command --------------- */
1411<ModuleDocArg1>{MODULE_ID} { // handle argument
1412 makeStructuralIndicator(yyscanner,yyextra->currentMakeEntryType);
1413 yyextra->current->name = yytext;
1414 BEGIN( Comment );
1415 }
1416<ModuleDocArg1>{LC} { // line continuation
1417 yyextra->lineNr++;
1418 addOutput(yyscanner,'\n');
1419 }
1420<ModuleDocArg1>{DOCNL} { // missing argument
1421 warn(yyextra->fileName,yyextra->lineNr,
1422 "missing argument after '\\module'."
1423 );
1424 unput_string(yytext,yyleng);
1425 BEGIN( Comment );
1426 }
1427<ModuleDocArg1>. { // ignore other stuff
1428 }
1429
1430 /* ------ handle argument of class/struct/union command --------------- */
1431
1432<ClassDocArg1>{SCOPENAME}{TMPLSPEC} {
1433 makeStructuralIndicator(yyscanner,yyextra->currentMakeEntryType);
1434 lineCount(yyscanner);
1435 yyextra->current->name = substitute(removeRedundantWhiteSpace(QCString(yytext)),".","::");
1436 BEGIN( ClassDocArg2 );
1437 }
1438<ClassDocArg1>{SCOPENAME} { // first argument
1439 makeStructuralIndicator(yyscanner,yyextra->currentMakeEntryType);
1440 lineCount(yyscanner);
1441 yyextra->current->name = substitute(QCString(yytext),".","::");
1442 if (yyextra->current->section.isProtocolDoc())
1443 {
1444 yyextra->current->name+="-p";
1445 }
1446 // prepend outer scope name
1447 BEGIN( ClassDocArg2 );
1448 }
1449<CategoryDocArg1>{SCOPENAME}{B}*"("[^\‍)]+")" {
1450 makeStructuralIndicator(yyscanner,yyextra->currentMakeEntryType);
1451 lineCount(yyscanner);
1452 yyextra->current->name = substitute(QCString(yytext),".","::");
1453 BEGIN( ClassDocArg2 );
1454 }
1455<ClassDocArg1,CategoryDocArg1>{LC} { // line continuation
1456 yyextra->lineNr++;
1457 addOutput(yyscanner,'\n');
1458 }
1459<ClassDocArg1,CategoryDocArg1>{DOCNL} {
1460 warn(yyextra->fileName,yyextra->lineNr,
1461 "missing argument after '\\{}'.",yyextra->currentCmd
1462 );
1463 unput_string(yytext,yyleng);
1464 BEGIN( Comment );
1465 }
1466<ClassDocArg1,CategoryDocArg1>. { // ignore other stuff
1467 }
1468
1469<ClassDocArg2>{DOCNL} {
1470 unput_string(yytext,yyleng);
1471 BEGIN( Comment );
1472 }
1473<ClassDocArg2>{FILE}|"<>" { // second argument; include file
1474 yyextra->current->includeFile = yytext;
1475 BEGIN( ClassDocArg3 );
1476 }
1477<ClassDocArg2>{LC} { // line continuation
1478 yyextra->lineNr++;
1479 addOutput(yyscanner,'\n');
1480 }
1481<ClassDocArg2>. { // ignore other stuff
1482 }
1483
1484<ClassDocArg3>[<"]?{FILE}?[">]? { // third argument; include file name
1485 yyextra->current->includeName = yytext;
1486 BEGIN( Comment );
1487 }
1488<ClassDocArg3>{LC} { // line continuation
1489 yyextra->lineNr++;
1490 addOutput(yyscanner,'\n');
1491 }
1492<ClassDocArg3>{DOCNL} {
1493 //if (*yytext=='\n') yyextra->lineNr++;
1494 unput_string(yytext,yyleng);
1495 BEGIN( Comment );
1496 }
1497<ClassDocArg3>. { // ignore other stuff
1498 }
1499
1500 /* --------- handle arguments of {def,add,weak}group commands --------- */
1501
1502<GroupDocArg1>{LABELID}(".html"|".xhtml")? { // group name
1503 yyextra->current->name = yytext;
1504 //lastDefGroup.groupname = yytext;
1505 //lastDefGroup.pri = yyextra->current->groupingPri();
1506 // the .html stuff is for Qt compatibility
1507 if (yyextra->current->name.endsWith(".html"))
1508 {
1509 yyextra->current->name=yyextra->current->name.left(yyextra->current->name.length()-5);
1510 }
1511 else if (yyextra->current->name.endsWith(".xhtml"))
1512 {
1513 yyextra->current->name=yyextra->current->name.left(yyextra->current->name.length()-6);
1514 }
1515 yyextra->current->type.clear();
1516 BEGIN(GroupDocArg2);
1517 }
1518<GroupDocArg1>"\\"{B}*"\n" { // line continuation
1519 yyextra->lineNr++;
1520 addOutput(yyscanner,'\n');
1521 }
1522<GroupDocArg1>{DOCNL} { // missing argument!
1523 warn(yyextra->fileName,yyextra->lineNr,
1524 "missing group name after {}",
1525 yyextra->current->groupDocCmd()
1526 );
1527 //addOutput(yyscanner,'\n');
1528 //if (*yytext=='\n') yyextra->lineNr++;
1529 unput_string(yytext,yyleng);
1530 BEGIN( Comment );
1531 }
1532<GroupDocArg1>. { // ignore other stuff
1533 }
1534<GroupDocArg2>"\\"{B}*"\n" { // line continuation
1535 yyextra->lineNr++;
1536 addOutput(yyscanner,'\n');
1537 }
1538<GroupDocArg2>[^\n\\]+ { // title (stored in type)
1539 yyextra->current->type += yytext;
1540 yyextra->current->type = yyextra->current->type.stripWhiteSpace();
1541 }
1542<GroupDocArg2>{DOCNL}+ {
1543 if ( yyextra->current->groupDocType==Entry::GROUPDOC_NORMAL &&
1544 yyextra->current->type.isEmpty()
1545 ) // defgroup requires second argument
1546 {
1547 warn(yyextra->fileName,yyextra->lineNr,
1548 "missing title after "
1549 "\\defgroup {}", yyextra->current->name
1550 );
1551 }
1552 unput_string(yytext,yyleng);
1553 int extraLineNr = 0;
1554 if (yyextra->inContext == OutputBrief)
1555 {
1556 for (int i = 0; i < yyleng; i++)
1557 {
1558 if (yytext[i]=='\n') extraLineNr++;
1559 }
1560 }
1561 //if (*yytext=='\n') yyextra->lineNr++;
1562 //addOutput(yyscanner,'\n');
1563 if ( yyextra->current->groupDocType!=Entry::GROUPDOC_NORMAL)
1564 {
1565 addOutput(yyscanner," \\ifile \""+ yyextra->fileName);
1566 addOutput(yyscanner,"\" \\iline " + QCString().setNum(yyextra->lineNr + extraLineNr) + " \\ilinebr ");
1567 }
1568 BEGIN( Comment );
1569 }
@ GROUPDOC_NORMAL
defgroup
Definition entry.h:121
1570<GroupDocArg2>. { // title (stored in type)
1571 yyextra->current->type += yytext;
1572 yyextra->current->type = yyextra->current->type.stripWhiteSpace();
1573 }
1574
1575 /* --------- handle arguments of page/mainpage command ------------------- */
1576
1577<PageDocArg1>[^\n]*"\\ilinebr @ianchor"\{[^\]\n]*\}{B}{FILE} { // special case where the Markdown processor has rewritten
1578 // "@page label Title" as
1579 // "@page md_label Title\ilinebr @ianchor{Title} label"
1580 QCString text = yytext;
1581 int start = text.find('{');
1582 int end = text.find('}',start+1);
1583 yyextra->current->name = text.mid(end+2);
1584 int istart = yyextra->current->name.find("\\ilinebr");
1585 if (istart != -1)
1586 {
1587 QCString rest = yyextra->current->name.mid(istart);
1588 unput_string(rest,rest.length());
1589 yyextra->current->name = yyextra->current->name.mid(0,istart);
1590 }
1591 yyextra->current->args = text.mid(start+1,end-start-1);
1592 //printf("name='%s' title='%s'\n",qPrint(yyextra->current->name),qPrint(yyextra->current->args));
1593 BEGIN( PageDocArg2 );
1594 }
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:153
DirIterator end(const DirIterator &) noexcept
Definition dir.cpp:175
1595<PageDocArg1>{FILE} { // first argument; page name
1596 yyextra->current->name = stripQuotes(yytext);
1597 yyextra->current->args = "";
1598 BEGIN( PageDocArg2 );
1599 }
1600<PageDocArg1>{LC} { yyextra->lineNr++;
1601 addOutput(yyscanner,'\n');
1602 }
1603<PageDocArg1>{DOCNL} {
1604 warn(yyextra->fileName,yyextra->lineNr,
1605 "missing argument after \\page."
1606 );
1607 unput_string(yytext,yyleng);
1608 //if (*yytext=='\n') yyextra->lineNr++;
1609 //addOutput(yyscanner,'\n');
1610 BEGIN( Comment );
1611 }
1612<PageDocArg1>. { // ignore other stuff
1613 }
1614<PageDocArg2>{DOCNL} { // second argument; page title
1615 unput_string(yytext,yyleng);
1616 //if (*yytext=='\n') yyextra->lineNr++;
1617 //addOutput(yyscanner,'\n');
1618 addOutput(yyscanner," \\ifile \""+ yyextra->fileName);
1619 addOutput(yyscanner,"\" \\iline " + QCString().setNum(yyextra->lineNr) + " \\ilinebr ");
1620 BEGIN( Comment );
1621 }
1622<PageDocArg2>{CMD}[<>] {
1623 // bug 748927
1624 QCString tmp(yytext);
1625 tmp = substitute(substitute(tmp,"@<","&lt;"),"@>","&gt;");
1626 tmp = substitute(substitute(tmp,"\\<","&lt;"),"\\>","&gt;");
1627 yyextra->current->args += tmp;
1628 }
1629<PageDocArg2>. {
1630 yyextra->current->args += yytext;
1631 }
1632 /* --------- handle arguments of the param command ------------ */
1633<ParamArg1>{ID}/{B}*"," {
1634 addOutput(yyscanner,yytext);
1635 }
1636<ParamArg1>"," {
1637 addOutput(yyscanner," , ");
1638 }
1639<ParamArg1>{DOCNL} {
1640 if (*yytext=='\n') yyextra->lineNr++;
1641 addOutput(yyscanner," ");
1642 }
1643<ParamArg1>{ID} {
1644 addOutput(yyscanner,yytext);
1645 BEGIN( Comment );
1646 }
1647<ParamArg1>. {
1648 unput(yytext[0]);
1649 BEGIN( Comment );
1650 }
1651
1652 /* --------- handle arguments of the file/dir/example command ------------ */
1653
1654<FileDocArg1>{DOCNL} { // no file name specified
1655 unput_string(yytext,yyleng);
1656 //if (*yytext=='\n') yyextra->lineNr++;
1657 //addOutput(yyscanner,'\n');
1658 BEGIN( Comment );
1659 }
1660<FileDocArg1>{FILE} { // first argument; name
1661 yyextra->current->name = stripQuotes(yytext);
1662 BEGIN( Comment );
1663 }
1664<FileDocArg1>{LC} { yyextra->lineNr++;
1665 addOutput(yyscanner,'\n');
1666 }
1667<FileDocArg1>. { // ignore other stuff
1668 }
1669
1670 /* --------- handle arguments of the xrefitem command ------------ */
1671
1672<XRefItemParam1>{LABELID} { // first argument
1673 yyextra->newXRefItemKey=yytext;
1674 setOutput(yyscanner,OutputXRef);
1675 BEGIN(XRefItemParam2);
1676 }
1677<XRefItemParam1>{LC} { // line continuation
1678 yyextra->lineNr++;
1679 addOutput(yyscanner,'\n');
1680 }
1681<XRefItemParam1>{DOCNL} { // missing arguments
1682 warn(yyextra->fileName,yyextra->lineNr,
1683 "Missing first argument of \\xrefitem"
1684 );
1685 if (*yytext=='\n') yyextra->lineNr++;
1686 addOutput(yyscanner,'\n');
1687 yyextra->inContext = OutputDoc;
1688 BEGIN( Comment );
1689 }
1690<XRefItemParam1>. { // ignore other stuff
1691 }
1692
1693<XRefItemParam2>"\""[^\n\"]*"\"" { // second argument
1694 yyextra->xrefItemTitle = stripQuotes(yytext);
1695 BEGIN(XRefItemParam3);
1696 }
1697<XRefItemParam2>{LC} { // line continuation
1698 yyextra->lineNr++;
1699 addOutput(yyscanner,'\n');
1700 }
1701<XRefItemParam2>{DOCNL} { // missing argument
1702 warn(yyextra->fileName,yyextra->lineNr,
1703 "Missing second argument of \\xrefitem"
1704 );
1705 if (*yytext=='\n') yyextra->lineNr++;
1706 addOutput(yyscanner,'\n');
1707 yyextra->inContext = OutputDoc;
1708 BEGIN( Comment );
1709 }
1710<XRefItemParam2>. { // ignore other stuff
1711 }
1712
1713<XRefItemParam3>"\""[^\n\"]*"\"" { // third argument
1714 yyextra->xrefListTitle = stripQuotes(yytext);
1715 yyextra->xrefKind = XRef_Item;
1716 BEGIN( Comment );
1717 }
1718<XRefItemParam2,XRefItemParam3>{LC} { // line continuation
1719 yyextra->lineNr++;
1720 addOutput(yyscanner,'\n');
1721 }
1722<XRefItemParam3>{DOCNL} { // missing argument
1723 warn(yyextra->fileName,yyextra->lineNr,
1724 "Missing third argument of \\xrefitem"
1725 );
1726 if (*yytext=='\n') yyextra->lineNr++;
1727 addOutput(yyscanner,'\n');
1728 yyextra->inContext = OutputDoc;
1729 BEGIN( Comment );
1730 }
1731<XRefItemParam3>. { // ignore other stuff
1732 }
1733
1734
1735 /* ----- handle arguments of the relates(also)/memberof command ------- */
1736
1737<RelatesParam1>({ID}("::"|"."))*{ID} { // argument
1738 yyextra->current->relates = yytext;
1739 //if (yyextra->current->mGrpId!=DOX_NOGROUP)
1740 //{
1741 // memberGroupRelates = yytext;
1742 //}
1743 BEGIN( Comment );
1744 }
1745<RelatesParam1>{LC} { // line continuation
1746 yyextra->lineNr++;
1747 addOutput(yyscanner,'\n');
1748 }
1749<RelatesParam1>{DOCNL} { // missing argument
1750 warn(yyextra->fileName,yyextra->lineNr,
1751 "Missing argument of '\\{}' command",yyextra->currentCmd
1752 );
1753 unput_string(yytext,yyleng);
1754 //if (*yytext=='\n') yyextra->lineNr++;
1755 //addOutput(yyscanner,'\n');
1756 BEGIN( Comment );
1757 }
1758<RelatesParam1>. { // ignore other stuff
1759 }
1760
1761
1762 /* ----- handle arguments of the qualifier command ----- */
1763<Qualifier>{LABELID} { // unquoted version, simple label
1764 yyextra->current->qualifiers.emplace_back(yytext);
1765 BEGIN( Comment );
1766 }
1767<Qualifier>"\""[^\"]*"\"" { // quotes version, add without quotes
1768 std::string inp(yytext);
1769 yyextra->current->qualifiers.push_back(inp.substr(1,yyleng-2));
1770 BEGIN( Comment );
1771 }
1772<Qualifier>{DOCNL} { // missing argument
1773 warn(yyextra->fileName,yyextra->lineNr,
1774 "Missing argument of '\\{}' command",yyextra->currentCmd
1775 );
1776 unput_string(yytext,yyleng);
1777 BEGIN( Comment );
1778 }
1779<Qualifier>. {
1780 warn(yyextra->fileName,yyextra->lineNr,
1781 "Argument of '\\{}' command should be quoted",yyextra->currentCmd
1782 );
1783 unput_string(yytext,yyleng);
1784 BEGIN( Comment );
1785 }
1786 /* ----- handle arguments of the iline command ----- */
1787<ILine>{LINENR}/[\\@\n\.] |
1788<ILine>{LINENR}{B} {
1789 bool ok = false;
1790 int nr = QCString(yytext).toInt(&ok);
1791 if (!ok)
1792 {
1793 warn(yyextra->fileName,yyextra->lineNr,"Invalid line number '{}' for iline command",yytext);
1794 }
1795 else
1796 {
1797 yyextra->lineNr = nr;
1798 }
1799 addOutput(yyscanner,yytext);
1800 if (YY_START == ILine)
1801 {
1802 BEGIN(Comment);
1803 }
1804 else
1805 {
1806 yyextra->sectionTitle+=yytext;
1807 BEGIN(SectionTitle);
1808 }
1809 }
int toInt(bool *ok=nullptr, int base=10) const
Definition qcstring.cpp:249
1810<ILine,ILineSection>. {
1811 addOutput(yyscanner,yytext);
1812 if (YY_START == ILine)
1813 {
1814 BEGIN(Comment);
1815 }
1816 else
1817 {
1818 yyextra->sectionTitle+=yytext;
1819 BEGIN(SectionTitle);
1820 }
1821 }
1822
1823 /* ----- handle arguments of the iraise command ----- */
1824<IRaise>{B}*[0-9]+/[\\@\n\.] |
1825<IRaise>{B}*[0-9]+{B} {
1826 bool ok = false;
1827 int nr = QCString(yytext).toInt(&ok);
1828 if (!ok)
1829 {
1830 warn(yyextra->fileName,yyextra->lineNr,"Invalid level '{}' for iraise command",yytext);
1831 }
1832 else
1833 {
1834 yyextra->raiseLevel = nr;
1835 }
1836 BEGIN(Comment);
1837 }
1838<IRaise>. {
1839 unput(yytext[0]);
1840 BEGIN(Comment);
1841 }
1842 /* ----- handle arguments of the iprefix command ----- */
1843
1844<IRaisePrefix>{B}*"\""({LABELID})?"\"" {
1845 QCString text(yytext);
1846 yyextra->raisePrefix = text.stripWhiteSpace().mid(1,text.length()-2);
1847 addOutput(yyscanner,yytext);
1848 BEGIN(Comment);
1849 }
1850<IRaisePrefix>. {
1851 unput(yytext[0]);
1852 BEGIN(Comment);
1853 }
1854
1855
1856 /* ----- handle arguments of the ifile command ----- */
1857
1858<IFile,IFileSection>{FILE} {
1859 addOutput(yyscanner,yytext);
1860 QCString text(yytext);
1861 if (yytext[0] == '\"') yyextra->fileName = text.mid(1,text.length()-2);
1862 else yyextra->fileName = yytext;
1863 if (YY_START == IFile)
1864 {
1865 BEGIN(Comment);
1866 }
1867 else
1868 {
1869 yyextra->sectionTitle+=yytext;
1870 BEGIN(SectionTitle);
1871 }
1872 }
1873
1874<LinkSection>[^\\@\n]* {
1875 yyextra->sectionTitle+=yytext;
1876 }
1877<LinkSection>{CMD}{CMD} {
1878 yyextra->sectionTitle+=yytext;
1879 }
1880<LinkSection>{DOCNL} {
1881 addOutput(yyscanner,yytext);
1882 if (*yytext == '\n') yyextra->lineNr++;
1883 yyextra->sectionTitle+=yytext;
1884 }
1885<LinkSection>{CMD}"endlink" {
1886 yyextra->sectionTitle+=yytext;
1887 BEGIN(SectionTitle);
1888 }
1889<LinkSection>. {
1890 yyextra->sectionTitle+=yytext;
1891 }
1892<LinkSection><<EOF>> {
1893 warn(yyextra->fileName,yyextra->lineNr,
1894 "reached end of comment while inside a '\\link' command, missing '\\endlink' command"
1895 );
1896 yyterminate();
1897 }
1898 /* ----- handle arguments of the relates(also)/addindex commands ----- */
1899
1900<LineParam>{CMD}{CMD} { // escaped command
1901 addOutput(yyscanner,yytext);
1902 }
1903<LineParam>{DOCNL} { // end of argument
1904 //if (*yytext=='\n') yyextra->lineNr++;
1905 //addOutput(yyscanner,'\n');
1906 unput_string(yytext,yyleng);
1907 BEGIN( Comment );
1908 }
1909<LineParam>{LC} { // line continuation
1910 yyextra->lineNr++;
1911 addOutput(yyscanner,'\n');
1912 }
1913<LineParam>({CMD}{CMD}){ID} { // escaped command
1914 addOutput(yyscanner,yytext);
1915 }
1916<LineParam>. { // ignore other stuff
1917 addOutput(yyscanner,*yytext);
1918 }
1919
1920 /* ----- handle arguments of the section/subsection/.. commands ------- */
1921
1922<SectionLabel>{LABELID} { // first argument
1923 yyextra->sectionLabel=yyextra->raisePrefix+yytext;
1924 addOutput(yyscanner,yyextra->sectionLabel.data());
1925 yyextra->sectionTitle.clear();
1926 BEGIN(SectionTitle);
1927 }
1928<SectionLabel>{DOCNL} { // missing argument
1929 warn(yyextra->fileName,yyextra->lineNr,
1930 "\\section command has no label"
1931 );
1932 if (*yytext=='\n') yyextra->lineNr++;
1933 addOutput(yyscanner,'\n');
1934 BEGIN( Comment );
1935 }
1936<SectionLabel>. { // invalid character for section label
1937 warn(yyextra->fileName,yyextra->lineNr,
1938 "Invalid or missing section label"
1939 );
1940 BEGIN(Comment);
1941 }
1942<SectionTitle>{STAopt}/"\n" { // end of section title
1943 addSection(yyscanner);
1944 addOutput(yyscanner,yytext);
1945 BEGIN( Comment );
1946 }
1947<SectionTitle>{STopt}"\\\\ilinebr" { // escaped end of section title
1948 yyextra->sectionTitle+=yytext;
1949 }
1950<SectionTitle>{STopt}/"\\ilinebr" { // end of section title
1951 addSection(yyscanner);
1952 addOutput(yyscanner,yytext);
1953 BEGIN( Comment );
1954 }
1955<SectionTitle>{B}*{CMD}"f$" {
1956 yyextra->formulaText="";
1957 yyextra->formulaPreText="$";
1958 yyextra->formulaPostText="";
1959 yyextra->formulaNewLines=0;
1960 BEGIN(ReadFormulaShortSection);
1961 }
1962<SectionTitle>{B}*{CMD}"f(" { // start of a inline formula
1963 yyextra->formulaText="";
1964 yyextra->formulaPreText="";
1965 yyextra->formulaPostText="";
1966 yyextra->formulaNewLines=0;
1967 BEGIN(ReadFormulaRoundSection);
1968 }
1969<SectionTitle>{B}*{CMD}"~"[a-z_A-Z-]* | // language switch command
1970<SectionTitle>{B}*{CMD}"f"[\[{] { // block formula
1971 setOutput(yyscanner,OutputDoc);
1972 addOutput(yyscanner," \\ilinebr ");
1973 addSection(yyscanner,false);
1974 warn(yyextra->fileName,yyextra->lineNr,
1975 "'\\{}' command is not allowed in section title, ending section title.",
1976 QCString(yytext).stripWhiteSpace()
1977 );
1978 unput_string(yytext,yyleng);
1979 BEGIN(Comment);
1980 }
1981<SectionTitle>{LC} { // line continuation
1982 yyextra->lineNr++;
1983 addOutput(yyscanner,'\n');
1984 }
1985<SectionTitle>[^\n@\\]* { // any character without special meaning
1986 yyextra->sectionTitle+=yytext;
1987 addOutput(yyscanner,yytext);
1988 }
1989<SectionTitle>{B}*{CMD}{CMD} {
1990 yyextra->sectionTitle+=yytext;
1991 addOutput(yyscanner,yytext);
1992 }
1993<SectionTitle>{B}*{CMD}[a-z_A-Z]+"{"[^}]*"}"{B}* |
1994<SectionTitle>{B}*{CMD}[a-z_A-Z]+{B}* { // handling command in section title
1995 QCString fullMatch = QCString(yytext);
1996 int idx = fullMatch.find('{');
1997 /* handle `f{` command as special case */
1998 if ((idx > 1) && (yytext[idx-1] == 'f') && (yytext[idx-2] == '\\' || yytext[idx-2] =='@')) REJECT;
1999 int idxEnd = fullMatch.find("}",idx+1);
2000 QCString cmdName;
2001 StringVector optList;
2002 if (idx == -1) // no options
2003 {
2004 cmdName = QCString(yytext).stripWhiteSpace().mid(1); // to remove {CMD}
2005 }
2006 else // options present
2007 {
2008 cmdName = fullMatch.left(idx).stripWhiteSpace().mid(1); // to remove {CMD}
2009 QCString optStr = fullMatch.mid(idx+1,idxEnd-idx-1).stripWhiteSpace();
2010 optList = split(optStr.str(),",");
2011 }
2012 auto it = docCmdMap.find(cmdName.str());
2013 if (it!=docCmdMap.end()) // special action is required
2014 {
2015 switch (it->second.sectionHandling)
2016 {
2018 {
2019 int i=0;
2020 while (yytext[i]==' ' || yytext[i]=='\t') i++;
2021 yyextra->sectionTitle+=fullMatch.left(i);
2022 yyextra->sectionTitle+='@';
2023 yyextra->sectionTitle+=fullMatch.mid(i);
2024 addOutput(yyscanner,qPrint(fullMatch.left(i)));
2025 addOutput(yyscanner,'@');
2026 addOutput(yyscanner,qPrint(fullMatch.mid(i)));
2027 warn(yyextra->fileName,yyextra->lineNr,
2028 "'\\{}' command is not allowed in section title, escaping command.",cmdName
2029 );
2030 }
2031 break;
2033 {
2034 addSection(yyscanner,false);
2035 addOutput(yyscanner," \\ilinebr ");
2036 warn(yyextra->fileName,yyextra->lineNr,
2037 "'\\{}' command is not allowed in section title, ending section title.",cmdName
2038 );
2039 unput_string(yytext,yyleng);
2040 BEGIN(Comment);
2041 }
2042 break;
2044 {
2045 if (cmdName == "fileinfo")
2046 {
2047 int i=0;
2048 while (yytext[i]==' ' || yytext[i]=='\t') i++;
2049 yyextra->sectionTitle+=fullMatch.left(i);
2050 addOutput(yyscanner,fullMatch.left(i));
2051 handleFileInfoSection(yyscanner,cmdName,optList);
2052 if (idxEnd == -1)
2053 {
2054 yyextra->sectionTitle+=fullMatch.mid(i+9);
2055 addOutput(yyscanner,fullMatch.mid(i+9));
2056 }
2057 else
2058 {
2059 yyextra->sectionTitle+=fullMatch.mid(idxEnd+1);
2060 addOutput(yyscanner,fullMatch.mid(idxEnd+1));
2061 }
2062 }
2063 else if (cmdName == "lineinfo")
2064 {
2065 int i=0;
2066 while (yytext[i]==' ' || yytext[i]=='\t') i++;
2067 yyextra->sectionTitle+=fullMatch.left(i);
2068 yyextra->sectionTitle+=QCString().setNum(yyextra->lineNr);
2069 yyextra->sectionTitle+=' ';
2070 yyextra->sectionTitle+=fullMatch.mid(i+9);
2071 addOutput(yyscanner,fullMatch.left(i));
2072 addOutput(yyscanner,QCString().setNum(yyextra->lineNr));
2073 addOutput(yyscanner,' ');
2074 addOutput(yyscanner,fullMatch.mid(i+9));
2075 }
2076 else if (cmdName == "raisewarning")
2077 {
2078 yyextra->raiseWarning = "";
2079 BEGIN(RaiseWarningSection);
2080 }
2081 else if (cmdName == "noop")
2082 {
2083 addSection(yyscanner,false);
2084 BEGIN(Noop);
2085 }
2086 else if (cmdName == "cite")
2087 {
2088 yyextra->sectionTitle+=yytext;
2089 addOutput(yyscanner,yytext);
2090 BEGIN(CiteLabelSection);
2091 }
2092 else if (cmdName == "iline")
2093 {
2094 yyextra->sectionTitle+=yytext;
2095 addOutput(yyscanner,yytext);
2096 BEGIN(ILineSection);
2097 }
2098 else if (cmdName == "ifile")
2099 {
2100 yyextra->sectionTitle+=yytext;
2101 addOutput(yyscanner,yytext);
2102 BEGIN(IFileSection);
2103 }
2104 else if ((cmdName == "anchor") || (cmdName == "ianchor"))
2105 {
2106 addOutput(yyscanner,"@"+cmdName);
2107 if (optList.empty())
2108 {
2109 yyextra -> anchorTitle = "";
2110 }
2111 else
2112 {
2113 addOutput(yyscanner,"{"+join(optList," ")+"}");
2114 yyextra -> anchorTitle = join(optList," ");
2115 }
2116 addOutput(yyscanner," ");
2117 BEGIN(AnchorLabelSection);
2118 }
2119 else if (cmdName == "link")
2120 {
2121 yyextra->sectionTitle+=yytext;
2122 BEGIN(LinkSection);
2123 }
2124 else
2125 {
2126 yyextra->sectionTitle+=yytext;
2127 warn(yyextra->fileName,yyextra->lineNr,
2128 "internal error '\\{}' command is to be replaced in section title.",cmdName
2129 );
2130 }
2131 }
2132 break;
2134 {
2135 yyextra->sectionTitle+=yytext;
2136 addOutput(yyscanner,yytext);
2137 }
2138 break;
2139 }
2140 }
2141 else
2142 {
2143 yyextra->sectionTitle+=yytext;
2144 addOutput(yyscanner,yytext);
2145 }
2146 }
QCString & setNum(short n)
Definition qcstring.h:444
const char * qPrint(const char *s)
Definition qcstring.h:672
std::string join(const StringVector &sv, const std::string &delimiter)
create a string where the string in the vector are joined by the given delimiter
Definition util.cpp:7145
2147<SectionTitle>. { // anything else
2148 yyextra->sectionTitle+=yytext;
2149 addOutput(yyscanner,*yytext);
2150 }
2151
2152 /* ----- handle arguments of the subpage command ------- */
2153
2154<SubpageLabel>{FILE} { // first argument
2155 addOutput(yyscanner,yytext);
2156 // we add subpage labels as a kind of "inheritance" relation to prevent
2157 // needing to add another list to the Entry class.
2158 yyextra->current->extends.emplace_back(QCString(yytext),Protection::Public,Specifier::Normal);
2159 BEGIN(SubpageTitle);
2160 }
2161<SubpageLabel>{DOCNL} { // missing argument
2162 warn(yyextra->fileName,yyextra->lineNr,
2163 "\\subpage command has no label"
2164 );
2165 if (*yytext=='\n') yyextra->lineNr++;
2166 addOutput(yyscanner,'\n');
2167 BEGIN( Comment );
2168 }
2169<SubpageLabel>. {
2170 unput(yytext[0]);
2171 BEGIN( Comment );
2172 }
2173<SubpageTitle>{DOCNL} { // no title, end command
2174 addOutput(yyscanner,yytext);
2175 BEGIN( Comment );
2176 }
2177<SubpageTitle>[ \t]*"\""[^\"\n]*"\"" { // add title, end of command
2178 addOutput(yyscanner,yytext);
2179 BEGIN( Comment );
2180 }
2181<SubpageTitle>. { // no title, end of command
2182 unput(*yytext);
2183 BEGIN( Comment );
2184 }
2185
2186 /* ----- handle arguments of the anchor command ------- */
2187
2188<AnchorLabel,AnchorLabelSection>{LABELID} { // found argument
2189 QCString lbl = yyextra->raisePrefix+yytext;
2190 addAnchor(yyscanner,lbl, yyextra->anchorTitle);
2191 addOutput(yyscanner,lbl.data());
2192 if (YY_START == AnchorLabel)
2193 {
2194 BEGIN(Comment);
2195 }
2196 else
2197 {
2198 BEGIN(SectionTitle);
2199 }
2200 }
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
2201<AnchorLabel,AnchorLabelSection>{DOCNL} { // missing argument
2202 warn(yyextra->fileName,yyextra->lineNr,
2203 "\\anchor command has no label"
2204 );
2205 if (*yytext=='\n') yyextra->lineNr++;
2206 addOutput(yyscanner,'\n');
2207 if (YY_START == AnchorLabel)
2208 {
2209 BEGIN(Comment);
2210 }
2211 else
2212 {
2213 BEGIN(SectionTitle);
2214 }
2215 }
2216<AnchorLabel,AnchorLabelSection>. { // invalid character for anchor label
2217 warn(yyextra->fileName,yyextra->lineNr,
2218 "Invalid or missing anchor label"
2219 );
2220 addOutput(yyscanner,yytext);
2221 if (YY_START == AnchorLabel)
2222 {
2223 BEGIN(Comment);
2224 }
2225 else
2226 {
2227 BEGIN(SectionTitle);
2228 }
2229 }
2230
2231
2232 /* ----- handle arguments of the preformatted block commands ------- */
2233
2234<FormatBlock>{CMD}("endverbatim"|"endiverbatim"|"endiliteral"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endrtfonly"|"endmanonly"|"enddot"|"endcode"|"endicode"|"endmsc")/{NW} { // possible ends
2235 addOutput(yyscanner,yytext);
2236 if (&yytext[4]==yyextra->blockName) // found end of the block
2237 {
2238 BEGIN(Comment);
2239 }
2240 }
2241<FormatBlock>{CMD}"enduml" {
2242 addOutput(yyscanner,yytext);
2243 if (yyextra->blockName=="startuml") // found end of the block
2244 {
2245 BEGIN(Comment);
2246 }
2247 }
2248<FormatBlock>[^ \@\*\/\\\n]* { // some word
2249 addOutput(yyscanner,yytext);
2250 }
2251<FormatBlock>{DOCNL} { // new line
2252 if (*yytext=='\n') yyextra->lineNr++;
2253 addOutput(yyscanner,'\n');
2254 }
2255<FormatBlock>{CCS} { // start of a C-comment
2256 if (!(yyextra->blockName=="code" || yyextra->blockName=="verbatim" ||
2257 yyextra->blockName=="icode" || yyextra->blockName=="iverbatim"||
2258 yyextra->blockName=="iliteral"
2259 )
2260 ) yyextra->commentCount++;
2261 addOutput(yyscanner,yytext);
2262 }
2263<FormatBlock>{CCE} { // end of a C-comment
2264 addOutput(yyscanner,yytext);
2265 if (!(yyextra->blockName=="code" || yyextra->blockName=="verbatim" ||
2266 yyextra->blockName=="icode" || yyextra->blockName=="iverbatim"||
2267 yyextra->blockName=="iliteral"
2268 )
2269 )
2270 {
2271 yyextra->commentCount--;
2272 if (yyextra->commentCount<0)
2273 {
2274 QCString endTag = "end"+yyextra->blockName;
2275 if (yyextra->blockName=="startuml") endTag="enduml";
2276 warn(yyextra->fileName,yyextra->lineNr,
2277 "found */ without matching /* while inside a \\{} block! Perhaps a missing \\{}?",
2278 yyextra->blockName,endTag);
2279 }
2280 }
2281 }
2282<FormatBlock>. {
2283 addOutput(yyscanner,*yytext);
2284 }
2285<FormatBlock><<EOF>> {
2286 QCString endTag = "end"+yyextra->blockName;
2287 if (yyextra->blockName=="startuml") endTag="enduml";
2288 warn(yyextra->fileName,yyextra->lineNr,
2289 "reached end of comment while inside a \\{} block; check for missing \\{} tag!",
2290 yyextra->blockName,endTag
2291 );
2292 yyterminate();
2293 }
2294
2295 /* ----- handle arguments of if/ifnot commands ------- */
2296
2297<GuardParam>{B}*"(" {
2298 yyextra->guardExpr=yytext;
2299 yyextra->roundCount=1;
2300 BEGIN(GuardExpr);
2301 }
2302<GuardExpr>[^()]* {
2303 yyextra->guardExpr+=yytext;
2304 lineCount(yyscanner);
2305 }
2306<GuardExpr>"(" {
2307 yyextra->guardExpr+=yytext;
2308 yyextra->roundCount++;
2309 }
2310<GuardExpr>")" {
2311 yyextra->guardExpr+=yytext;
2312 yyextra->roundCount--;
2313 if (yyextra->roundCount==0)
2314 {
2315 handleGuard(yyscanner,yyextra->guardExpr);
2316 }
2317 }
2318<GuardExpr>\n {
2319 warn(yyextra->fileName,yyextra->lineNr,
2320 "invalid expression '{}' for yyextra->guards",yyextra->guardExpr);
2321 unput(*yytext);
2322 BEGIN(GuardParam);
2323 }
2324<GuardParam>{B}*[a-z_A-Z0-9.\-]+ { // parameter of if/ifnot yyextra->guards
2325 handleGuard(yyscanner,QCString(yytext));
2326 }
2327<GuardParam>{DOCNL} { // end of argument
2328 //next line is commented out due to bug620924
2329 //addOutput(yyscanner,'\n');
2330 addIlineBreak(yyscanner,yyextra->lineNr);
2331 unput_string(yytext,yyleng);
2332 handleGuard(yyscanner,QCString());
2333 }
2334<GuardParam>{LC} { // line continuation
2335 yyextra->lineNr++;
2336 addOutput(yyscanner,'\n');
2337 }
2338<GuardParam>. { // empty condition
2339 unput(*yytext);
2340 handleGuard(yyscanner,QCString());
2341 }
2342<GuardParamEnd>{B}*{DOCNL} {
2343 lineCount(yyscanner);
2344 yyextra->spaceBeforeIf.clear();
2345 addIlineBreak(yyscanner,yyextra->lineNr);
2346 BEGIN(Comment);
2347 }
2348<GuardParamEnd>{B}* {
2349 if (!yyextra->spaceBeforeIf.isEmpty()) // needed for 665313 in combination with bug620924
2350 {
2351 addOutput(yyscanner,yyextra->spaceBeforeIf);
2352 }
2353 yyextra->spaceBeforeIf.clear();
2354 addIlineBreak(yyscanner,yyextra->lineNr);
2355 BEGIN(Comment);
2356 }
2357<GuardParamEnd>. {
2358 unput(*yytext);
2359 addIlineBreak(yyscanner,yyextra->lineNr);
2360 BEGIN(Comment);
2361 }
2362
2363 /* ----- handle skipping of conditional sections ------- */
2364
2365<SkipGuardedSection>{CMD}"ifnot"/{NW} {
2366 yyextra->guardType = Guard_IfNot;
2367 yyextra->guards->emplace(false);
2368 BEGIN( GuardParam );
2369 }
2370<SkipGuardedSection>{CMD}"if"/{NW} {
2371 yyextra->guardType = Guard_If;
2372 yyextra->guards->emplace(false);
2373 BEGIN( GuardParam );
2374 }
2375<SkipGuardedSection>{CMD}"endif"/{NW} {
2376 if (yyextra->guards->empty())
2377 {
2378 warn(yyextra->fileName,yyextra->lineNr,
2379 "found \\endif without matching start command");
2380 BEGIN( Comment );
2381 }
2382 else
2383 {
2384 yyextra->guards->pop();
2385 if (yyextra->guards->empty())
2386 {
2387 BEGIN( GuardParamEnd );
2388 }
2389 else
2390 {
2391 if (yyextra->guards->top().isEnabled())
2392 {
2393 BEGIN( GuardParamEnd );
2394 }
2395 else
2396 {
2397 BEGIN( SkipGuardedSection );
2398 }
2399 }
2400 }
2401 }
2402<SkipGuardedSection>{CMD}"else"/{NW} {
2403 if (yyextra->guards->empty())
2404 {
2405 warn(yyextra->fileName,yyextra->lineNr,
2406 "found \\else without matching start command");
2407 }
2408 else if (yyextra->guards->top().hasElse())
2409 {
2410 warn(yyextra->fileName,yyextra->lineNr,
2411 "found multiple \\else commands in same \\if construct");
2412 yyextra->guards->top().setEnabled(false);
2413 BEGIN( SkipGuardedSection );
2414 }
2415 else if (!yyextra->guards->top().parentVisible())
2416 {
2417 yyextra->guards->top().setEnabled(false);
2418 BEGIN( SkipGuardedSection );
2419 }
2420 else
2421 {
2422 yyextra->spaceBeforeIf = yyextra->spaceBeforeCmd;
2423 yyextra->guards->top().setElse();
2424 if (!yyextra->guards->top().parentVisible())
2425 {
2426 yyextra->guards->top().setEnabled(false);
2427 BEGIN( SkipGuardedSection );
2428 }
2429 else if (yyextra->guards->top().isEnabledFound())
2430 {
2431 yyextra->guards->top().setEnabled(false);
2432 BEGIN( SkipGuardedSection );
2433 }
2434 else
2435 {
2436 yyextra->guards->top().setEnabled(true);
2437 BEGIN( GuardParamEnd );
2438 }
2439 }
2440 }
2441<SkipGuardedSection>{CMD}"elseif"/{NW} {
2442 if (yyextra->guards->empty())
2443 {
2444 warn(yyextra->fileName,yyextra->lineNr,
2445 "found \\elseif without matching start command");
2446 }
2447 else if (yyextra->guards->top().hasElse())
2448 {
2449 warn(yyextra->fileName,yyextra->lineNr,
2450 "found \\elseif command after \\else command was given in \\if construct");
2451 yyextra->guardType = Guard_ElseIf;
2452 yyextra->spaceBeforeIf = yyextra->spaceBeforeCmd;
2453 yyextra->guards->top().setEnabled(false);
2454 BEGIN( GuardParam );
2455 }
2456 else
2457 {
2458 yyextra->guardType = Guard_ElseIf;
2459 yyextra->spaceBeforeIf = yyextra->spaceBeforeCmd;
2460 yyextra->guards->top().setEnabled(false);
2461 BEGIN( GuardParam );
2462 }
2463 }
2464<SkipGuardedSection>{DOCNL} { // skip line
2465 if (*yytext=='\n') yyextra->lineNr++;
2466 //addOutput(yyscanner,'\n');
2467 }
2468<SkipGuardedSection>[^ \\@\n]+ { // skip non-special characters
2469 }
2470<SkipGuardedSection>{CMD}{CMD} |
2471<SkipGuardedSection>. { // any other character
2472 }
2473
2474
2475 /* ----- handle skipping of internal section ------- */
2476
2477<SkipInternal>{DOCNL} { // skip line
2478 if (*yytext=='\n') yyextra->lineNr++;
2479 addOutput(yyscanner,'\n');
2480 }
2481<SkipInternal>[@\\]"if"/[ \t] {
2482 yyextra->condCount++;
2483 }
2484<SkipInternal>[@\\]"ifnot"/[ \t] {
2485 yyextra->condCount++;
2486 }
2487<SkipInternal>[@\\]/"endif" {
2488 yyextra->condCount--;
2489 if (yyextra->condCount<0) // handle conditional section around of \internal, see bug607743
2490 {
2491 unput('\\');
2492 BEGIN(Comment);
2493 }
2494 }
2495<SkipInternal>[@\\]/"section"[ \t] {
2496 if (yyextra->sectionLevel>0)
2497 {
2498 unput('\\');
2499 BEGIN(Comment);
2500 }
2501 }
2502<SkipInternal>[@\\]/"subsection"[ \t] {
2503 if (yyextra->sectionLevel>1)
2504 {
2505 unput('\\');
2506 BEGIN(Comment);
2507 }
2508 }
2509<SkipInternal>[@\\]/"subsubsection"[ \t] {
2510 if (yyextra->sectionLevel>2)
2511 {
2512 unput('\\');
2513 BEGIN(Comment);
2514 }
2515 }
2516<SkipInternal>[@\\]/"paragraph"[ \t] {
2517 if (yyextra->sectionLevel>3)
2518 {
2519 unput('\\');
2520 BEGIN(Comment);
2521 }
2522 }
2523<SkipInternal>[@\\]/"subparagraph"[ \t] {
2524 if (yyextra->sectionLevel>4)
2525 {
2526 unput('\\');
2527 BEGIN(Comment);
2528 }
2529 }
2530<SkipInternal>[@\\]/"subsubparagraph"[ \t] {
2531 if (yyextra->sectionLevel>5)
2532 {
2533 unput('\\');
2534 BEGIN(Comment);
2535 }
2536 }
2537<SkipInternal>[@\\]"endinternal"[ \t]* {
2538 BEGIN(Comment);
2539 }
2540<SkipInternal>[^ \\@\n]+ { // skip non-special characters
2541 }
2542<SkipInternal>. { // any other character
2543 }
2544
2545
2546 /* ----- handle argument of name command ------- */
2547
2548<NameParam>{DOCNL} { // end of argument
2549 //if (*yytext=='\n') yyextra->lineNr++;
2550 //addOutput(yyscanner,'\n');
2551 unput_string(yytext,yyleng);
2552 BEGIN( Comment );
2553 }
2554<NameParam>{LC} { // line continuation
2555 yyextra->lineNr++;
2556 addOutput(yyscanner,'\n');
2557 yyextra->docGroup.appendHeader(' ');
2558 }
2559<NameParam>. { // ignore other stuff
2560 yyextra->docGroup.appendHeader(*yytext);
2561 yyextra->current->name+=*yytext;
2562 }
2563
2564 /* ----- handle argument of noop command ------- */
2565<Noop>{DOCNL} { // end of argument
2566 if (*yytext=='\n')
2567 {
2568 yyextra->lineNr++;
2569 addOutput(yyscanner,'\n');
2570 }
2571 BEGIN( Comment );
2572 }
2573<Noop>. { // ignore other stuff
2574 }
2575 /* ----- handle argument of raisewarning command ------- */
2576<RaiseWarning,RaiseWarningSection>{DOCNL} { // end of argument
2577 warn_doc_error(yyextra->fileName,yyextra->lineNr,
2578 "{}",yyextra->raiseWarning);
2579 yyextra->raiseWarning = "";
2580 if (*yytext=='\n') yyextra->lineNr++;
2581 addOutput(yyscanner,'\n');
2582 if (YY_START == RaiseWarning)
2583 {
2584 BEGIN(Comment);
2585 }
2586 else
2587 {
2588 yyextra->sectionTitle+=yytext;
2589 BEGIN(SectionTitle);
2590 }
2591 }
#define warn_doc_error(file, line, fmt,...)
Definition message.h:112
2592<RaiseWarning,RaiseWarningSection>. { // ignore other stuff
2593 yyextra->raiseWarning += yytext;
2594 }
2595 /* ----- handle argument of ingroup command ------- */
2596
2597<InGroupParam>{LABELID} { // group id
2598 yyextra->current->groups.emplace_back(
2600 );
2601 yyextra->inGroupParamFound=TRUE;
2602 }
@ GROUPING_INGROUP
membership in group was defined by @ingroup
Definition types.h:236
2603<InGroupParam>{DOCNL} { // missing argument
2604 if (!yyextra->inGroupParamFound)
2605 {
2606 warn(yyextra->fileName,yyextra->lineNr,
2607 "Missing group name for \\ingroup command"
2608 );
2609 }
2610 //if (*yytext=='\n') yyextra->lineNr++;
2611 //addOutput(yyscanner,'\n');
2612 unput_string(yytext,yyleng);
2613 BEGIN( Comment );
2614 }
2615<InGroupParam>{LC} { // line continuation
2616 yyextra->lineNr++;
2617 addOutput(yyscanner,'\n');
2618 }
2619<InGroupParam>. { // ignore other stuff
2620 addOutput(yyscanner,*yytext);
2621 }
2622
2623 /* ----- handle argument of fn command ------- */
2624
2625<FnParam>{DOCNL} { // end of argument
2626 if (yyextra->braceCount==0)
2627 {
2628 if (yyextra->functionProto.stripWhiteSpace().isEmpty())
2629 {
2630 warn(yyextra->fileName,yyextra->lineNr,
2631 "missing argument after '\\{}'.",yyextra->currentCmd
2632 );
2633 }
2634 else
2635 {
2636 makeStructuralIndicator(yyscanner,yyextra->currentMakeEntryType);
2637 yyextra->langParser->parsePrototype(yyextra->functionProto);
2638 }
2639 unput_string(yytext,yyleng);
2640 BEGIN( Comment );
2641 }
2642 }
2643<FnParam>{LC} { // line continuation
2644 yyextra->lineNr++;
2645 yyextra->functionProto+=' ';
2646 }
2647<FnParam>[^@\\\n()]+ { // non-special characters
2648 yyextra->functionProto+=yytext;
2649 }
2650<FnParam>"(" {
2651 yyextra->functionProto+=yytext;
2652 yyextra->braceCount++;
2653 }
2654<FnParam>")" {
2655 yyextra->functionProto+=yytext;
2656 yyextra->braceCount--;
2657 }
2658<FnParam>. { // add other stuff
2659 yyextra->functionProto+=*yytext;
2660 }
2661
2662
2663 /* ----- handle argument of overload command ------- */
2664
2665
2666<OverloadParam>{DOCNL} { // end of argument
2667 if (*yytext=='\n') yyextra->lineNr++;
2668 if (yyextra->functionProto.stripWhiteSpace().isEmpty())
2669 { // plain overload command
2670 addOutput(yyscanner,getOverloadDocs());
2671 addOutput(yyscanner,'\n');
2672 }
2673 else // overload declaration
2674 {
2675 makeStructuralIndicator(yyscanner,EntryType::makeOverloadDoc);
2676 yyextra->langParser->parsePrototype(yyextra->functionProto);
2677 }
2678 BEGIN( Comment );
2679 }
QCString getOverloadDocs()
Definition util.cpp:4595
2680<OverloadParam>{LC} { // line continuation
2681 yyextra->lineNr++;
2682 yyextra->functionProto+=' ';
2683 }
2684<OverloadParam>. { // add other stuff
2685 yyextra->functionProto+=*yytext;
2686 }
2687
2688 /* ----- handle argument of inherit command ------- */
2689
2690<InheritParam>({ID}("::"|"."))*{ID} { // found argument
2691 yyextra->current->extends.emplace_back(
2692 removeRedundantWhiteSpace(QCString(yytext)),Protection::Public,Specifier::Normal
2693 );
2694 BEGIN( Comment );
2695 }
2696<InheritParam>{DOCNL} { // missing argument
2697 warn(yyextra->fileName,yyextra->lineNr,
2698 "\\inherit command has no argument"
2699 );
2700 if (*yytext=='\n') yyextra->lineNr++;
2701 addOutput(yyscanner,'\n');
2702 BEGIN( Comment );
2703 }
2704<InheritParam>. { // invalid character for anchor label
2705 warn(yyextra->fileName,yyextra->lineNr,
2706 "Invalid or missing name for \\inherit command"
2707 );
2708 BEGIN(Comment);
2709 }
2710
2711 /* ----- handle argument of extends and implements commands ------- */
2712
2713<ExtendsParam>({ID}("::"|"."))*{ID} { // found argument
2714 yyextra->current->extends.emplace_back(
2715 removeRedundantWhiteSpace(QCString(yytext)),Protection::Public,Specifier::Normal
2716 );
2717 BEGIN( Comment );
2718 }
2719<ExtendsParam>{DOCNL} { // missing argument
2720 warn(yyextra->fileName,yyextra->lineNr,
2721 "'\\{}' command has no argument",yyextra->currentCmd
2722 );
2723 //if (*yytext=='\n') yyextra->lineNr++;
2724 //addOutput(yyscanner,'\n');
2725 unput_string(yytext,yyleng);
2726 BEGIN( Comment );
2727 }
2728<ExtendsParam>. { // ignore other stuff
2729 }
2730
2731 /* ----- handle language specific sections ------- */
2732
2733<SkipLang>[\\@]"~"[a-zA-Z-]* { /* language switch */
2734 QCString langId(&yytext[2]);
2735 if (!langId.isEmpty() && !Config_isAvailableEnum(OUTPUT_LANGUAGE,langId))
2736 {
2737 warn(yyextra->fileName,yyextra->lineNr,
2738 "non supported language '{}' specified in '{}'",langId,QCString(yytext).stripWhiteSpace());
2739 }
2740 else if (langId.isEmpty() ||
2741 qstricmp(Config_getEnumAsString(OUTPUT_LANGUAGE),langId)==0)
2742 { // enable language specific section
2743 BEGIN(Comment);
2744 }
2745 }
2746<SkipLang>[^*@\\\n]* { /* any character not a *, @, backslash or new line */
2747 }
2748<SkipLang>{DOCNL} { /* new line in verbatim block */
2749 if (*yytext=='\n') yyextra->lineNr++;
2750 }
2751<SkipLang>. { /* any other character */
2752 }
2753
2754 /* ----- handle arguments of the cite command ------- */
2755
2756<CiteLabel,CiteLabelSection>{CITEID} { // found argument
2757 addCite(yyscanner);
2758 addOutput(yyscanner,yytext);
2759 if (YY_START == CiteLabel)
2760 {
2761 BEGIN(Comment);
2762 }
2763 else
2764 {
2765 yyextra->sectionTitle+=yytext;
2766 BEGIN(SectionTitle);
2767 }
2768 }
2769<CiteLabel,CiteLabelSection>{DOCNL} { // missing argument
2770 warn(yyextra->fileName,yyextra->lineNr,
2771 "\\cite command has no label"
2772 );
2773 //if (*yytext=='\n') yyextra->lineNr++;
2774 //addOutput(yyscanner,'\n');
2775 if (YY_START == CiteLabel)
2776 {
2777 unput_string(yytext,yyleng);
2778 BEGIN(Comment);
2779 }
2780 else
2781 {
2782 yyextra->sectionTitle+=yytext;
2783 unput_string(yytext,yyleng);
2784 BEGIN(SectionTitle);
2785 }
2786 }
2787<CiteLabel,CiteLabelSection>. { // invalid character for cite label
2788 warn(yyextra->fileName,yyextra->lineNr,
2789 "Invalid or missing cite label"
2790 );
2791 if (YY_START == CiteLabel)
2792 {
2793 BEGIN(Comment);
2794 }
2795 else
2796 {
2797 yyextra->sectionTitle+=yytext;
2798 BEGIN(SectionTitle);
2799 }
2800 }
2801
2802 /* ----- handle argument of the copydoc command ------- */
2803
2804<CopyDoc><<EOF>> {
2805 setOutput(yyscanner,OutputDoc);
2806 addOutput(yyscanner," \\ilinebr\\ilinebr\\copydetails ");
2807 addOutput(yyscanner,yyextra->copyDocArg);
2808 addOutput(yyscanner,"\n");
2809 BEGIN(Comment);
2810 }
2811<CopyDoc>{DOCNL} {
2812 if (*yytext=='\n') yyextra->lineNr++;
2813 if (yyextra->braceCount==0)
2814 {
2815 setOutput(yyscanner,OutputDoc);
2816 addOutput(yyscanner," \\ilinebr\\ilinebr\\copydetails ");
2817 addOutput(yyscanner,yyextra->copyDocArg);
2818 addOutput(yyscanner,"\n");
2819 BEGIN(Comment);
2820 }
2821 }
2822<CopyDoc>{LC} { // line continuation
2823 yyextra->lineNr++;
2824 }
2825<CopyDoc>[^@\\\n()]+ { // non-special characters
2826 yyextra->copyDocArg+=yytext;
2827 addOutput(yyscanner,yytext);
2828 }
2829<CopyDoc>"(" {
2830 yyextra->copyDocArg+=yytext;
2831 addOutput(yyscanner,yytext);
2832 yyextra->braceCount++;
2833 }
2834<CopyDoc>")" {
2835 yyextra->copyDocArg+=yytext;
2836 addOutput(yyscanner,yytext);
2837 yyextra->braceCount--;
2838 }
2839<CopyDoc>. {
2840 yyextra->copyDocArg+=yytext;
2841 addOutput(yyscanner,yytext);
2842 }
2843
2844 /*
2845<*>. { fprintf(stderr,"Lex scanner %s %sdefault rule for state %s: #%s#\n", __FILE__,!yyextra->fileName.isEmpty() ? ("(" + yyextra->fileName +") ").data(): "",stateToString(YY_START),yytext);}
2846<*>\n { fprintf(stderr,"Lex scanner %s %sdefault rule newline for state %s.\n", __FILE__, !yyextra->fileName.isEmpty() ? ("(" + yyextra->fileName +") ").data(): "",stateToString(YY_START));}
2847 */
2848
2849%%
2850
2851//----------------------------------------------------------------------------
2852
2853static bool handleBrief(yyscan_t yyscanner,const QCString &, const StringVector &)
2854{
2855 //printf("handleBrief\n");
2856 setOutput(yyscanner,OutputBrief);
2857 return FALSE;
2858}
2859
2860static bool handleFn(yyscan_t yyscanner,const QCString &cmd, const StringVector &)
2861{
2862 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2863 yyextra->braceCount=0;
2864 yyextra->functionProto.clear();
2865 yyextra->currentCmd = cmd;
2866 yyextra->currentMakeEntryType = EntryType::makeMemberDoc;
2867 BEGIN( FnParam );
2868 return checkStructuralIndicator(yyscanner);
2869}
2870
2871static bool handleDef(yyscan_t yyscanner,const QCString &cmd, const StringVector &)
2872{
2873 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2874 yyextra->functionProto.clear();
2875 yyextra->braceCount=0;
2876 yyextra->currentCmd = cmd;
2877 yyextra->currentMakeEntryType = EntryType::makeDefineDoc;
2878 BEGIN( FnParam );
2879 return checkStructuralIndicator(yyscanner);
2880}
2881
2882static bool handleOverload(yyscan_t yyscanner,const QCString &, const StringVector &)
2883{
2884 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2885 yyextra->functionProto.clear();
2886 BEGIN(OverloadParam);
2887 return FALSE;
2888}
2889
2890static bool handleEnum(yyscan_t yyscanner,const QCString &, const StringVector &)
2891{
2892 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2893 yyextra->currentMakeEntryType = EntryType::makeEnumDoc;
2894 BEGIN( EnumDocArg1 );
2895 return checkStructuralIndicator(yyscanner);
2896}
2897
2898static bool handleDefGroup(yyscan_t yyscanner,const QCString &, const StringVector &)
2899{
2900 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2901 bool stop=makeStructuralIndicator(yyscanner,EntryType::makeGroupDoc);
2902 yyextra->current->groupDocType = Entry::GROUPDOC_NORMAL;
2903 BEGIN( GroupDocArg1 );
2904 return stop;
2905}
2906
2907static bool handleAddToGroup(yyscan_t yyscanner,const QCString &, const StringVector &)
2908{
2909 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2910 bool stop=makeStructuralIndicator(yyscanner,EntryType::makeGroupDoc);
2911 yyextra->current->groupDocType = Entry::GROUPDOC_ADD;
2912 BEGIN( GroupDocArg1 );
2913 return stop;
2914}
2915
2916static bool handleWeakGroup(yyscan_t yyscanner,const QCString &, const StringVector &)
2917{
2918 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2919 bool stop=makeStructuralIndicator(yyscanner,EntryType::makeGroupDoc);
2920 yyextra->current->groupDocType = Entry::GROUPDOC_WEAK;
2921 BEGIN( GroupDocArg1 );
2922 return stop;
2923}
2924
2925static bool handleNamespace(yyscan_t yyscanner,const QCString &, const StringVector &)
2926{
2927 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2928 yyextra->currentMakeEntryType = EntryType::makeNamespaceDoc;
2929 BEGIN( NameSpaceDocArg1 );
2930 return checkStructuralIndicator(yyscanner);
2931}
2932
2933static bool handlePackage(yyscan_t yyscanner,const QCString &, const StringVector &)
2934{
2935 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2936 bool stop=makeStructuralIndicator(yyscanner,EntryType::makePackageDoc);
2937 BEGIN( PackageDocArg1 );
2938 return stop;
2939}
2940
2941static bool handleClass(yyscan_t yyscanner,const QCString &cmd, const StringVector &)
2942{
2943 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2944 yyextra->currentCmd = cmd;
2945 yyextra->currentMakeEntryType = EntryType::makeClassDoc;
2946 BEGIN( ClassDocArg1 );
2947 return checkStructuralIndicator(yyscanner);
2948}
2949
2950static bool handleConcept(yyscan_t yyscanner,const QCString &cmd, const StringVector &)
2951{
2952 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2953 yyextra->currentCmd = cmd;
2954 yyextra->currentMakeEntryType = EntryType::makeConceptDoc;
2955 BEGIN( ConceptDocArg1 );
2956 return checkStructuralIndicator(yyscanner);
2957}
2958
2959static bool handleModule(yyscan_t yyscanner,const QCString &cmd, const StringVector &)
2960{
2961 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2962 yyextra->currentCmd = cmd;
2963 yyextra->currentMakeEntryType = EntryType::makeModuleDoc;
2964 BEGIN( ModuleDocArg1 );
2965 return checkStructuralIndicator(yyscanner);
2966}
2967
2968static bool handleHeaderFile(yyscan_t yyscanner,const QCString &, const StringVector &)
2969{
2970 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2971 BEGIN( ClassDocArg2 );
2972 return FALSE;
2973}
2974
2975static bool handleProtocol(yyscan_t yyscanner,const QCString &cmd, const StringVector &)
2976{ // Obj-C protocol
2977 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2978 yyextra->currentCmd = cmd;
2979 yyextra->currentMakeEntryType = EntryType::makeProtocolDoc;
2980 BEGIN( ClassDocArg1 );
2981 return checkStructuralIndicator(yyscanner);
2982}
2983
2984static bool handleCategory(yyscan_t yyscanner,const QCString &cmd, const StringVector &)
2985{ // Obj-C category
2986 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2987 yyextra->currentCmd = cmd;
2988 yyextra->currentMakeEntryType = EntryType::makeCategoryDoc;
2989 BEGIN( CategoryDocArg1 );
2990 return checkStructuralIndicator(yyscanner);
2991}
2992
2993static bool handleUnion(yyscan_t yyscanner,const QCString &cmd, const StringVector &)
2994{
2995 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2996 yyextra->currentCmd = cmd;
2997 yyextra->currentMakeEntryType = EntryType::makeUnionDoc;
2998 BEGIN( ClassDocArg1 );
2999 return checkStructuralIndicator(yyscanner);
3000}
3001
3002static bool handleStruct(yyscan_t yyscanner,const QCString &cmd, const StringVector &)
3003{
3004 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3005 yyextra->currentCmd = cmd;
3006 yyextra->currentMakeEntryType = EntryType::makeStructDoc;
3007 BEGIN( ClassDocArg1 );
3008 return checkStructuralIndicator(yyscanner);
3009}
3010
3011static bool handleInterface(yyscan_t yyscanner,const QCString &cmd, const StringVector &)
3012{
3013 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3014 yyextra->currentCmd = cmd;
3015 yyextra->currentMakeEntryType = EntryType::makeInterfaceDoc;
3016 BEGIN( ClassDocArg1 );
3017 return checkStructuralIndicator(yyscanner);
3018}
3019
3020static bool handleIdlException(yyscan_t yyscanner,const QCString &cmd, const StringVector &)
3021{
3022 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3023 yyextra->currentCmd = cmd;
3024 yyextra->currentMakeEntryType = EntryType::makeExceptionDoc;
3025 BEGIN( ClassDocArg1 );
3026 return checkStructuralIndicator(yyscanner);
3027}
3028
3029static bool handlePage(yyscan_t yyscanner,const QCString &, const StringVector &)
3030{
3031 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3032 bool stop=makeStructuralIndicator(yyscanner,EntryType::makePageDoc);
3033 BEGIN( PageDocArg1 );
3034 return stop;
3035}
3036
3037static bool handleMainpage(yyscan_t yyscanner,const QCString &, const StringVector &)
3038{
3039 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3040 bool stop=makeStructuralIndicator(yyscanner,EntryType::makeMainpageDoc);
3041 if (!stop)
3042 {
3043 yyextra->current->name = "mainpage";
3044 }
3045 setOutput(yyscanner,OutputDoc);
3046 BEGIN( PageDocArg2 );
3047 return stop;
3048}
3049
3050static bool handleFile(yyscan_t yyscanner,const QCString &, const StringVector &)
3051{
3052 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3053 bool stop=makeStructuralIndicator(yyscanner,EntryType::makeFileDoc);
3054 if (!stop)
3055 {
3056 yyextra->current->name = yyextra->fileName;
3057 }
3058 BEGIN( FileDocArg1 );
3059 return stop;
3060}
3061
3062static bool handleParam(yyscan_t yyscanner,const QCString &, const StringVector &)
3063{
3064 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3065 // we need process param and retval arguments to escape leading underscores in case of
3066 // markdown processing, see bug775493
3067 addOutput(yyscanner,"@param ");
3068 BEGIN( ParamArg1 );
3069 return FALSE;
3070}
3071
3072static bool handleRetval(yyscan_t yyscanner,const QCString &, const StringVector &)
3073{
3074 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3075 addOutput(yyscanner,"@retval ");
3076 BEGIN( ParamArg1 );
3077 return FALSE;
3078}
3079
3080static bool handleDir(yyscan_t yyscanner,const QCString &, const StringVector &)
3081{
3082 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3083 bool stop=makeStructuralIndicator(yyscanner,EntryType::makeDirDoc);
3084 if (!stop) yyextra->current->name = yyextra->fileName;
3085 BEGIN( FileDocArg1 );
3086 return stop;
3087}
3088
3089static bool handleExample(yyscan_t yyscanner,const QCString &cmd, const StringVector &optList)
3090{
3091 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3092 MakeEntryType sectionMaker = EntryType::makeExample;
3093 for (const auto &opt : optList)
3094 {
3095 if (opt=="lineno")
3096 {
3097 sectionMaker=EntryType::makeExampleLineno;
3098 }
3099 else
3100 {
3101 warn(yyextra->fileName,yyextra->lineNr,
3102 "unsupported option '{}' for command '\\{}'",opt,cmd);
3103 }
3104 }
3105 bool stop=makeStructuralIndicator(yyscanner,sectionMaker);
3106 if (!stop) yyextra->current->name = yyextra->fileName;
3107 BEGIN( FileDocArg1 );
3108 return stop;
3109}
3110
3111static bool handleDetails(yyscan_t yyscanner,const QCString &, const StringVector &)
3112{
3113 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3114 if (yyextra->inContext!=OutputBrief)
3115 {
3116 addOutput(yyscanner," \\ilinebr\\ilinebr "); // treat @details outside brief description
3117 // as a new paragraph
3118 }
3119 setOutput(yyscanner,OutputDoc);
3120 return FALSE;
3121}
3122
3123static bool handleRaiseWarning(yyscan_t yyscanner,const QCString &, const StringVector &)
3124{
3125 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3126 yyextra->raiseWarning = "";
3127 BEGIN( RaiseWarning );
3128 return FALSE;
3129}
3130
3131static bool handleNoop(yyscan_t yyscanner,const QCString &, const StringVector &)
3132{
3133 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3134 BEGIN( Noop );
3135 return FALSE;
3136}
3137
3138static bool handleName(yyscan_t yyscanner,const QCString &, const StringVector &)
3139{
3140 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3141 bool stop=makeStructuralIndicator(yyscanner,EntryType::makeMemberGrp);
3142 if (!stop)
3143 {
3144 yyextra->docGroup.clearHeader();
3145 BEGIN( NameParam );
3146 if (!yyextra->docGroup.isEmpty()) // end of previous member group
3147 {
3148 yyextra->docGroup.close(yyextra->current,yyextra->fileName,yyextra->lineNr,TRUE,true);
3149 }
3150 }
3151 return stop;
3152}
3153
3154static bool handleTodo(yyscan_t yyscanner,const QCString &, const StringVector &)
3155{
3156 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3157 yyextra->newXRefKind = XRef_Todo;
3158 setOutput(yyscanner,OutputXRef);
3159 yyextra->xrefKind = XRef_Todo;
3160 return FALSE;
3161}
3162
3163static bool handleTest(yyscan_t yyscanner,const QCString &, const StringVector &)
3164{
3165 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3166 yyextra->newXRefKind = XRef_Test;
3167 setOutput(yyscanner,OutputXRef);
3168 yyextra->xrefKind = XRef_Test;
3169 return FALSE;
3170}
3171
3172static bool handleBug(yyscan_t yyscanner,const QCString &, const StringVector &)
3173{
3174 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3175 yyextra->newXRefKind = XRef_Bug;
3176 setOutput(yyscanner,OutputXRef);
3177 yyextra->xrefKind = XRef_Bug;
3178 return FALSE;
3179}
3180
3181static bool handleDeprecated(yyscan_t yyscanner,const QCString &, const StringVector &)
3182{
3183 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3184 yyextra->newXRefKind = XRef_Deprecated;
3185 setOutput(yyscanner,OutputXRef);
3186 yyextra->xrefKind = XRef_Deprecated;
3187 return FALSE;
3188}
3189
3190static bool handleXRefItem(yyscan_t yyscanner,const QCString &, const StringVector &)
3191{
3192 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3193 yyextra->newXRefKind = XRef_Item;
3194 BEGIN(XRefItemParam1);
3195 return FALSE;
3196}
3197
3198static bool handleParBlock(yyscan_t yyscanner,const QCString &, const StringVector &)
3199{
3200 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3201 if (yyextra->insideParBlock)
3202 {
3203 warn(yyextra->fileName,yyextra->lineNr,
3204 "found \\parblock command while already in a parblock!");
3205 }
3206 if (!yyextra->spaceBeforeCmd.isEmpty())
3207 {
3208 addOutput(yyscanner,yyextra->spaceBeforeCmd);
3209 yyextra->spaceBeforeCmd.clear();
3210 }
3211 addOutput(yyscanner,"@parblock ");
3212 yyextra->insideParBlock = TRUE;
3213 return FALSE;
3214}
3215
3216static bool handleEndParBlock(yyscan_t yyscanner,const QCString &, const StringVector &)
3217{
3218 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3219 if (!yyextra->insideParBlock)
3220 {
3221 warn(yyextra->fileName,yyextra->lineNr,
3222 "found \\endparblock command without matching \\parblock!");
3223 }
3224 addOutput(yyscanner,"@endparblock");
3225 setOutput(yyscanner,OutputDoc); // to end a parblock inside a xrefitem like context
3226 yyextra->insideParBlock = FALSE;
3227 return FALSE;
3228}
3229
3230static bool handleRelated(yyscan_t yyscanner,const QCString &cmd, const StringVector &)
3231{
3232 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3233 if (!yyextra->current->relates.isEmpty())
3234 {
3235 warn(yyextra->fileName,yyextra->lineNr,
3236 "found multiple \\relates, \\relatesalso or \\memberof commands in a comment block, using last definition");
3237 }
3238 yyextra->current->relatesType = RelatesType::Simple;
3239 yyextra->currentCmd = cmd;
3240 BEGIN(RelatesParam1);
3241 return FALSE;
3242}
3243
3244static bool handleRelatedAlso(yyscan_t yyscanner,const QCString &cmd, const StringVector &)
3245{
3246 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3247 if (!yyextra->current->relates.isEmpty())
3248 {
3249 warn(yyextra->fileName,yyextra->lineNr,
3250 "found multiple \\relates, \\relatesalso or \\memberof commands in a comment block, using last definition");
3251 }
3252 yyextra->current->relatesType = RelatesType::Duplicate;
3253 yyextra->currentCmd = cmd;
3254 BEGIN(RelatesParam1);
3255 return FALSE;
3256}
3257
3258static bool handleMemberOf(yyscan_t yyscanner,const QCString &cmd, const StringVector &)
3259{
3260 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3261 if (!yyextra->current->relates.isEmpty())
3262 {
3263 warn(yyextra->fileName,yyextra->lineNr,
3264 "found multiple \\relates, \\relatesalso or \\memberof commands in a comment block, using last definition");
3265 }
3266 yyextra->current->relatesType = RelatesType::MemberOf;
3267 yyextra->currentCmd = cmd;
3268 BEGIN(RelatesParam1);
3269 return FALSE;
3270}
3271
3272static bool handleRefItem(yyscan_t yyscanner,const QCString &, const StringVector &)
3273{
3274 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3275 addOutput(yyscanner,"@refitem ");
3276 BEGIN(LineParam);
3277 return FALSE;
3278}
3279
3280static bool handleSection(yyscan_t yyscanner,const QCString &s, const StringVector &)
3281{
3282 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3283 setOutput(yyscanner,OutputDoc);
3284 //printf("handleSection(%s) raiseLevel=%d\n",qPrint(s),yyextra->raiseLevel);
3285 BEGIN(SectionLabel);
3286 // determine natural section level
3287 if (s=="section") yyextra->sectionLevel=SectionType::Section;
3288 else if (s=="subsection") yyextra->sectionLevel=SectionType::Subsection;
3289 else if (s=="subsubsection") yyextra->sectionLevel=SectionType::Subsubsection;
3290 else if (s=="paragraph") yyextra->sectionLevel=SectionType::Paragraph;
3291 else if (s=="subparagraph") yyextra->sectionLevel=SectionType::Subparagraph;
3292 else if (s=="subsubparagraph") yyextra->sectionLevel=SectionType::Subsubparagraph;
3293 // raise it if requested
3294 yyextra->sectionLevel = std::min(yyextra->sectionLevel + yyextra->raiseLevel,SectionType::MaxLevel);
3295 // rewrite the update section level to the output
3296 switch (yyextra->sectionLevel)
3297 {
3298 case SectionType::Section: addOutput(yyscanner,"@section "); break;
3299 case SectionType::Subsection: addOutput(yyscanner,"@subsection "); break;
3300 case SectionType::Subsubsection: addOutput(yyscanner,"@subsubsection "); break;
3301 case SectionType::Paragraph: addOutput(yyscanner,"@paragraph "); break;
3302 case SectionType::Subparagraph: addOutput(yyscanner,"@subparagraph "); break;
3303 case SectionType::Subsubparagraph: addOutput(yyscanner,"@subsubparagraph "); break;
3304 default: addOutput(yyscanner,"@"+s+" "); break;
3305 }
3306 return FALSE;
3307}
3308
3309static bool handleSubpage(yyscan_t yyscanner,const QCString &s, const StringVector &)
3310{
3311 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3312 if (!yyextra->current->section.isEmpty() &&
3313 !yyextra->current->section.isPageDoc() &&
3314 !yyextra->current->section.isMainpageDoc()
3315 )
3316 {
3317 warn(yyextra->fileName,yyextra->lineNr,
3318 "found \\subpage command in a comment block that is not marked as a page!");
3319 }
3320 if (!yyextra->spaceBeforeCmd.isEmpty())
3321 {
3322 addOutput(yyscanner,yyextra->spaceBeforeCmd);
3323 yyextra->spaceBeforeCmd.clear();
3324 }
3325 addOutput(yyscanner,"@"+s+" ");
3326 BEGIN(SubpageLabel);
3327 return FALSE;
3328}
3329
3330static bool handleAnchor(yyscan_t yyscanner,const QCString &s, const StringVector &optList)
3331{
3332 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3333 addOutput(yyscanner,"@"+s+" ");
3334 if (optList.empty())
3335 {
3336 yyextra -> anchorTitle = "";
3337 }
3338 else
3339 {
3340 yyextra -> anchorTitle = join(optList," ");
3341 }
3342 BEGIN(AnchorLabel);
3343 return FALSE;
3344}
3345
3346static bool handleImage(yyscan_t yyscanner,const QCString &s, const StringVector &optList)
3347{
3348 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3349 for (const auto &opt : optList)
3350 {
3351 QCString locOpt(opt);
3352 locOpt = locOpt.stripWhiteSpace();
3353 if (locOpt.lower().startsWith("anchor:"))
3354 {
3355 addAnchor(yyscanner,locOpt.mid(7));
3356 break; // real option handling will be done later on
3357 }
3358 }
3359 if (optList.empty())
3360 {
3361 addOutput(yyscanner,"@"+s+" ");
3362 }
3363 else
3364 {
3365 addOutput(yyscanner,"@"+s+"{"+QCString(join(optList,","))+"} ");
3366 }
3367 BEGIN(Comment);
3368 return FALSE;
3369}
3370
3371static bool handleCite(yyscan_t yyscanner,const QCString &s, const StringVector &)
3372{
3373 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3374 if (!yyextra->spaceBeforeCmd.isEmpty())
3375 {
3376 addOutput(yyscanner,yyextra->spaceBeforeCmd);
3377 yyextra->spaceBeforeCmd.clear();
3378 }
3379 addOutput(yyscanner,"@"+s+" ");
3380 BEGIN(CiteLabel);
3381 return FALSE;
3382}
3383
3384static bool handleFormatBlock(yyscan_t yyscanner,const QCString &s, const StringVector &optList)
3385{
3386 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3387 if (!yyextra->spaceBeforeCmd.isEmpty())
3388 {
3389 addOutput(yyscanner,yyextra->spaceBeforeCmd);
3390 yyextra->spaceBeforeCmd.clear();
3391 }
3392 if (optList.empty())
3393 {
3394 addOutput(yyscanner,"@"+s+" ");
3395 }
3396 else
3397 {
3398 addOutput(yyscanner,"@"+s+"{"+QCString(join(optList,","))+"} ");
3399 }
3400 //printf("handleFormatBlock(%s) with option(%s)\n",qPrint(s),qPrint(opt));
3401 yyextra->blockName=s;
3402 yyextra->commentCount=0;
3403 BEGIN(FormatBlock);
3404 return FALSE;
3405}
3406
3407static bool handleAddIndex(yyscan_t yyscanner,const QCString &, const StringVector &)
3408{
3409 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3410 addOutput(yyscanner,yytext);
3411 BEGIN(LineParam);
3412 return FALSE;
3413}
3414
3415static bool handleFileInfo(yyscan_t yyscanner,const QCString &cmdName, const StringVector &optList)
3416{
3417 return handleFileInfoResult(yyscanner,cmdName, optList, false);
3418}
3419static bool handleFileInfoSection(yyscan_t yyscanner,const QCString &cmdName, const StringVector &optList)
3420{
3421 return handleFileInfoResult(yyscanner,cmdName, optList, true);
3422}
3423static bool handleFileInfoResult(yyscan_t yyscanner,const QCString &, const StringVector &optList, bool isSection)
3424{
3425 using OutputWriter = std::function<void(yyscan_t,FileInfo &,bool)>;
3426 static std::unordered_map<std::string,OutputWriter> options =
3427 { // name, writer
3428 { "name", [](yyscan_t s,FileInfo &fi,bool isSect) { addOutput(s,fi.baseName());
3429 if (isSect)
3430 {
3431 struct yyguts_t *yyg = (struct yyguts_t*)s;
3432 yyextra->sectionTitle+=fi.baseName();
3433 }
3434 } },
3435 { "extension", [](yyscan_t s,FileInfo &fi,bool isSect) { addOutput(s,fi.extension(true));
3436 if (isSect)
3437 {
3438 struct yyguts_t *yyg = (struct yyguts_t*)s;
3439 yyextra->sectionTitle+=fi.extension(true);
3440 }
3441 } },
3442 { "filename", [](yyscan_t s,FileInfo &fi,bool isSect) { addOutput(s,fi.fileName());
3443 if (isSect)
3444 {
3445 struct yyguts_t *yyg = (struct yyguts_t*)s;
3446 yyextra->sectionTitle+=fi.fileName();
3447 }
3448 } },
3449 { "directory", [](yyscan_t s,FileInfo &fi,bool isSect) { addOutput(s,fi.dirPath());
3450 if (isSect)
3451 {
3452 struct yyguts_t *yyg = (struct yyguts_t*)s;
3453 yyextra->sectionTitle+=fi.dirPath();
3454 }
3455 } },
3456 { "full", [](yyscan_t s,FileInfo &fi,bool isSect) { addOutput(s,fi.absFilePath());
3457 if (isSect)
3458 {
3459 struct yyguts_t *yyg = (struct yyguts_t*)s;
3460 yyextra->sectionTitle+=fi.absFilePath();
3461 }
3462 } },
3463 };
3464
3465 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3466 if (!yyextra->spaceBeforeCmd.isEmpty())
3467 {
3468 if (isSection) yyextra->sectionTitle+=yyextra->spaceBeforeCmd;
3469 addOutput(yyscanner,yyextra->spaceBeforeCmd);
3470 yyextra->spaceBeforeCmd.clear();
3471 }
3472 bool first = true;
3473 FileInfo fi(yyextra->fileName.str());
3474 for (const auto &opt_ : optList)
3475 {
3476 QCString optStripped = QCString(opt_).stripWhiteSpace();
3477 std::string opt = optStripped.lower().str();
3478 auto it = options.find(opt);
3479 if (it != options.end())
3480 {
3481 if (!first)
3482 {
3483 warn(yyextra->fileName,yyextra->lineNr,"Multiple options specified with \\fileinfo, discarding '{}'", optStripped);
3484 }
3485 else
3486 {
3487 it->second(yyscanner,fi,isSection);
3488 }
3489 first = false;
3490 }
3491 else
3492 {
3493 warn(yyextra->fileName,yyextra->lineNr,"Unknown option specified with \\fileinfo: '{}'", optStripped);
3494 }
3495 }
3496 if (first) // no options specified
3497 {
3498 if (Config_getBool(FULL_PATH_NAMES))
3499 {
3500 if (isSection) yyextra->sectionTitle+=stripFromPath(yyextra->fileName);
3501 addOutput(yyscanner,stripFromPath(yyextra->fileName));
3502 }
3503 else
3504 {
3505 if (isSection) yyextra->sectionTitle+=yyextra->fileName;
3506 addOutput(yyscanner,yyextra->fileName);
3507 }
3508 }
3509 return false;
3510}
3511
3512static bool handleLineInfo(yyscan_t yyscanner,const QCString &, const StringVector &)
3513{
3514 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3515 if (!yyextra->spaceBeforeCmd.isEmpty())
3516 {
3517 addOutput(yyscanner,yyextra->spaceBeforeCmd);
3518 yyextra->spaceBeforeCmd.clear();
3519 }
3520 addOutput(yyscanner,QCString().setNum(yyextra->lineNr));
3521 return FALSE;
3522}
3523
3524static bool handleILine(yyscan_t yyscanner,const QCString &, const StringVector &)
3525{
3526 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3527 addOutput(yyscanner,yytext);
3528 BEGIN(ILine);
3529 return FALSE;
3530}
3531
3532static bool handleIFile(yyscan_t yyscanner,const QCString &, const StringVector &)
3533{
3534 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3535 addOutput(yyscanner,yytext);
3536 BEGIN(IFile);
3537 return FALSE;
3538}
3539
3540static bool handleIRaise(yyscan_t yyscanner,const QCString &, const StringVector &)
3541{
3542 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3543 BEGIN(IRaise);
3544 return FALSE;
3545}
3546
3547static bool handleIPrefix(yyscan_t yyscanner,const QCString &, const StringVector &)
3548{
3549 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3550 addOutput(yyscanner,"@iprefix ");
3551 BEGIN(IRaisePrefix);
3552 return FALSE;
3553}
3554
3555static bool handleIf(yyscan_t yyscanner,const QCString &, const StringVector &)
3556{
3557 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3558 yyextra->guardType = Guard_If;
3559 yyextra->spaceBeforeIf = yyextra->spaceBeforeCmd;
3560 if (yyextra->guards->empty())
3561 {
3562 yyextra->guards->emplace(true);
3563 }
3564 else
3565 {
3566 bool enabled = yyextra->guards->top().isEnabled();
3567 yyextra->guards->emplace(enabled);
3568 }
3569 BEGIN(GuardParam);
3570 return FALSE;
3571}
3572
3573static bool handleIfNot(yyscan_t yyscanner,const QCString &, const StringVector &)
3574{
3575 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3576 yyextra->guardType = Guard_IfNot;
3577 yyextra->spaceBeforeIf = yyextra->spaceBeforeCmd;
3578 if (yyextra->guards->empty())
3579 {
3580 yyextra->guards->emplace(true);
3581 }
3582 else
3583 {
3584 bool enabled = yyextra->guards->top().isEnabled();
3585 yyextra->guards->emplace(enabled);
3586 }
3587 BEGIN(GuardParam);
3588 return FALSE;
3589}
3590
3591static bool handleElseIf(yyscan_t yyscanner,const QCString &, const StringVector &)
3592{
3593 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3594 if (yyextra->guards->empty())
3595 {
3596 warn(yyextra->fileName,yyextra->lineNr,
3597 "found \\elseif without matching start command");
3598 }
3599 else if (yyextra->guards->top().hasElse())
3600 {
3601 warn(yyextra->fileName,yyextra->lineNr,
3602 "found \\elseif command after \\else command was given in \\if construct");
3603 yyextra->guardType = Guard_ElseIf;
3604 yyextra->spaceBeforeIf = yyextra->spaceBeforeCmd;
3605 yyextra->guards->top().setEnabled(false);
3606 BEGIN(GuardParam);
3607 }
3608 else
3609 {
3610 yyextra->guardType = Guard_ElseIf;
3611 yyextra->spaceBeforeIf = yyextra->spaceBeforeCmd;
3612 yyextra->guards->top().setEnabled(false);
3613 BEGIN(GuardParam);
3614 }
3615 return FALSE;
3616}
3617
3618static bool handleElse(yyscan_t yyscanner,const QCString &, const StringVector &)
3619{
3620 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3621 if (yyextra->guards->empty())
3622 {
3623 warn(yyextra->fileName,yyextra->lineNr,
3624 "found \\else without matching start command");
3625 }
3626 else if (yyextra->guards->top().hasElse())
3627 {
3628 warn(yyextra->fileName,yyextra->lineNr,
3629 "found multiple \\else commands in same \\if construct");
3630 yyextra->guards->top().setEnabled(false);
3631 yyextra->guards->top().setElse();
3632 BEGIN( SkipGuardedSection );
3633 }
3634 else
3635 {
3636 yyextra->guards->top().setElse();
3637 yyextra->spaceBeforeIf = yyextra->spaceBeforeCmd;
3638 if (yyextra->guards->top().isEnabledFound())
3639 {
3640 yyextra->guards->top().setEnabled(false);
3641 BEGIN( SkipGuardedSection );
3642 }
3643 else
3644 {
3645 yyextra->guards->top().setEnabled(true);
3646 BEGIN( GuardParamEnd );
3647 }
3648 }
3649 return FALSE;
3650}
3651
3652static bool handleEndIf(yyscan_t yyscanner,const QCString &, const StringVector &)
3653{
3654 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3655 if (yyextra->guards->empty())
3656 {
3657 warn(yyextra->fileName,yyextra->lineNr,
3658 "found \\endif without matching start command");
3659 }
3660 else
3661 {
3662 yyextra->guards->pop();
3663 }
3664 if (!yyextra->spaceBeforeCmd.isEmpty())
3665 {
3666 addOutput(yyscanner,yyextra->spaceBeforeCmd);
3667 yyextra->spaceBeforeCmd.clear();
3668 }
3669 if (yyextra->guards->empty())
3670 {
3671 BEGIN( GuardParamEnd );
3672 }
3673 else
3674 {
3675 if (yyextra->guards->top().isEnabled())
3676 {
3677 BEGIN( GuardParamEnd );
3678 }
3679 else
3680 {
3681 BEGIN( SkipGuardedSection );
3682 }
3683 }
3684 return FALSE;
3685}
3686
3687static bool handleIngroup(yyscan_t yyscanner,const QCString &, const StringVector &)
3688{
3689 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3690 yyextra->inGroupParamFound=FALSE;
3691 BEGIN( InGroupParam );
3692 return FALSE;
3693}
3694
3695static bool handleNoSubGrouping(yyscan_t yyscanner,const QCString &, const StringVector &)
3696{
3697 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3698 yyextra->current->subGrouping = FALSE;
3699 return FALSE;
3700}
3701
3702static bool handleShowInitializer(yyscan_t yyscanner,const QCString &, const StringVector &)
3703{
3704 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3705 yyextra->current->initLines = 100000; // ON
3706 return FALSE;
3707}
3708
3709static bool handleHideInitializer(yyscan_t yyscanner,const QCString &, const StringVector &)
3710{
3711 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3712 yyextra->current->initLines = 0; // OFF
3713 return FALSE;
3714}
3715
3716static bool handleCallgraph(yyscan_t yyscanner,const QCString &, const StringVector &)
3717{
3718 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3719 yyextra->current->commandOverrides.override_callGraph(true); // ON
3720 return FALSE;
3721}
3722
3723static bool handleHideCallgraph(yyscan_t yyscanner,const QCString &, const StringVector &)
3724{
3725 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3726 yyextra->current->commandOverrides.override_callGraph(false); // OFF
3727 return FALSE;
3728}
3729
3730static bool handleCallergraph(yyscan_t yyscanner,const QCString &, const StringVector &)
3731{
3732 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3733 yyextra->current->commandOverrides.override_callerGraph(true); // ON
3734 return FALSE;
3735}
3736
3737static bool handleHideCallergraph(yyscan_t yyscanner,const QCString &, const StringVector &)
3738{
3739 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3740 yyextra->current->commandOverrides.override_callerGraph(false); // OFF
3741 return FALSE;
3742}
3743
3744static bool handleShowEnumValues(yyscan_t yyscanner,const QCString &, const StringVector &)
3745{
3746 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3747 yyextra->current->commandOverrides.override_enumValues(true); // ON
3748 return FALSE;
3749}
3750
3751static bool handleHideEnumValues(yyscan_t yyscanner,const QCString &, const StringVector &)
3752{
3753 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3754 yyextra->current->commandOverrides.override_enumValues(false); // OFF
3755 return FALSE;
3756}
3757
3758static bool handleShowInlineSource(yyscan_t yyscanner,const QCString &, const StringVector &)
3759{
3760 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3761 yyextra->current->commandOverrides.override_inlineSource(true); // ON
3762 return FALSE;
3763}
3764
3765static bool handleHideInlineSource(yyscan_t yyscanner,const QCString &, const StringVector &)
3766{
3767 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3768 yyextra->current->commandOverrides.override_inlineSource(false); // OFF
3769 return FALSE;
3770}
3771
3772static bool handleIncludegraph(yyscan_t yyscanner,const QCString &, const StringVector &)
3773{
3774 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3775 yyextra->current->commandOverrides.override_includeGraph(true); // ON
3776 return FALSE;
3777}
3778
3779static bool handleIncludedBygraph(yyscan_t yyscanner,const QCString &, const StringVector &)
3780{
3781 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3782 yyextra->current->commandOverrides.override_includedByGraph(true); // ON
3783 return FALSE;
3784}
3785
3786static bool handleHideIncludegraph(yyscan_t yyscanner,const QCString &, const StringVector &)
3787{
3788 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3789 yyextra->current->commandOverrides.override_includeGraph(false); // OFF
3790 return FALSE;
3791}
3792
3793static bool handleHideIncludedBygraph(yyscan_t yyscanner,const QCString &, const StringVector &)
3794{
3795 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3796 yyextra->current->commandOverrides.override_includedByGraph(false); // OFF
3797 return FALSE;
3798}
3799
3800static bool handleDirectoryGraph(yyscan_t yyscanner,const QCString &, const StringVector &)
3801{
3802 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3803 yyextra->current->commandOverrides.override_directoryGraph(true); // ON
3804 return FALSE;
3805}
3806
3807static bool handleHideDirectoryGraph(yyscan_t yyscanner,const QCString &, const StringVector &)
3808{
3809 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3810 yyextra->current->commandOverrides.override_directoryGraph(false); // OFF
3811 return FALSE;
3812}
3813
3814static bool handleCollaborationgraph(yyscan_t yyscanner,const QCString &, const StringVector &)
3815{
3816 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3817 yyextra->current->commandOverrides.override_collaborationGraph(true); // ON
3818 return FALSE;
3819}
3820
3821static bool handleHideCollaborationgraph(yyscan_t yyscanner,const QCString &, const StringVector &)
3822{
3823 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3824 yyextra->current->commandOverrides.override_collaborationGraph(false); // OFF
3825 return FALSE;
3826}
3827
3828static bool handleGroupgraph(yyscan_t yyscanner,const QCString &, const StringVector &)
3829{
3830 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3831 yyextra->current->commandOverrides.override_groupGraph(true); // ON
3832 return FALSE;
3833}
3834
3835static bool handleHideGroupgraph(yyscan_t yyscanner,const QCString &, const StringVector &)
3836{
3837 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3838 yyextra->current->commandOverrides.override_groupGraph(false); // OFF
3839 return FALSE;
3840}
3841
3842static bool handleInheritanceGraph(yyscan_t yyscanner,const QCString &, const StringVector &optList)
3843{
3844 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3845 yyextra->current->commandOverrides.override_inheritanceGraph(CLASS_GRAPH_t::YES);
3846 for (const auto &opt_ : optList)
3847 {
3848 QCString opt = QCString(opt_).stripWhiteSpace().lower();
3849 if (!opt.isEmpty())
3850 {
3851 if (opt == "yes")
3852 {
3853 yyextra->current->commandOverrides.override_inheritanceGraph(CLASS_GRAPH_t::YES);
3854 }
3855 else if (opt == "graph")
3856 {
3857 yyextra->current->commandOverrides.override_inheritanceGraph(CLASS_GRAPH_t::GRAPH);
3858 }
3859 else if (opt == "builtin")
3860 {
3861 yyextra->current->commandOverrides.override_inheritanceGraph(CLASS_GRAPH_t::BUILTIN);
3862 }
3863 else if (opt == "text")
3864 {
3865 yyextra->current->commandOverrides.override_inheritanceGraph(CLASS_GRAPH_t::TEXT);
3866 }
3867 else if (opt == "no")
3868 {
3869 yyextra->current->commandOverrides.override_inheritanceGraph(CLASS_GRAPH_t::NO);
3870 }
3871 else
3872 {
3873 warn(yyextra->fileName,yyextra->lineNr,"Unknown option specified with \\inheritancegraph: '{}'",
3874 QCString(opt_).stripWhiteSpace());
3875 }
3876 }
3877 }
3878 return FALSE;
3879}
3880
3881static bool handleHideInheritanceGraph(yyscan_t yyscanner,const QCString &, const StringVector &)
3882{
3883 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3884 yyextra->current->commandOverrides.override_inheritanceGraph(CLASS_GRAPH_t::NO); // OFF
3885 return FALSE;
3886}
3887
3888static bool handleReferencedByRelation(yyscan_t yyscanner,const QCString &, const StringVector &)
3889{
3890 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3891 yyextra->current->commandOverrides.override_referencedByRelation(true); // ON
3892 return FALSE;
3893}
3894
3895static bool handleHideReferencedByRelation(yyscan_t yyscanner,const QCString &, const StringVector &)
3896{
3897 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3898 yyextra->current->commandOverrides.override_referencedByRelation(false); // OFF
3899 return FALSE;
3900}
3901
3902static bool handleReferencesRelation(yyscan_t yyscanner,const QCString &, const StringVector &)
3903{
3904 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3905 yyextra->current->commandOverrides.override_referencesRelation(true); // ON
3906 return FALSE;
3907}
3908
3909static bool handleHideReferencesRelation(yyscan_t yyscanner,const QCString &, const StringVector &)
3910{
3911 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3912 yyextra->current->commandOverrides.override_referencesRelation(false); // OFF
3913 return FALSE;
3914}
3915
3916static bool handleQualifier(yyscan_t yyscanner,const QCString &cmd, const StringVector &)
3917{
3918 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3919 yyextra->currentCmd = cmd;
3920 BEGIN(Qualifier);
3921 return FALSE;
3922}
3923
3924static bool handleInternal(yyscan_t yyscanner,const QCString &, const StringVector &)
3925{
3926 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3927 if (!Config_getBool(INTERNAL_DOCS))
3928 {
3929 // make sure some whitespace before a \internal command
3930 // is not treated as "documentation"
3931 if (yyextra->current->doc.stripWhiteSpace().isEmpty())
3932 {
3933 yyextra->current->doc.clear();
3934 }
3935 yyextra->condCount=0;
3936 BEGIN( SkipInternal );
3937 }
3938 else
3939 {
3940 // re-enabled for bug640828
3941 addOutput(yyscanner," \\internal ");
3942 yyextra->inInternalDocs = TRUE;
3943 }
3944 return FALSE;
3945}
3946
3947static bool handleStatic(yyscan_t yyscanner,const QCString &, const StringVector &)
3948{
3949 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3950 yyextra->current->isStatic = TRUE;
3951 return FALSE;
3952}
3953
3954static bool handlePure(yyscan_t yyscanner,const QCString &, const StringVector &)
3955{
3956 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3957 yyextra->current->virt = Specifier::Pure;
3958 return FALSE;
3959}
3960
3961static bool handlePrivate(yyscan_t yyscanner,const QCString &, const StringVector &)
3962{
3963 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3964 yyextra->current->protection = Protection::Private;
3965 return FALSE;
3966}
3967
3968static bool handlePrivateSection(yyscan_t yyscanner,const QCString &, const StringVector &)
3969{
3970 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3971 yyextra->current->protection = yyextra->protection = Protection::Private;
3972 return FALSE;
3973}
3974
3975static bool handleProtected(yyscan_t yyscanner,const QCString &, const StringVector &)
3976{
3977 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3978 yyextra->current->protection = Protection::Protected;
3979 return FALSE;
3980}
3981
3982static bool handleProtectedSection(yyscan_t yyscanner,const QCString &, const StringVector &)
3983{
3984 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3985 yyextra->current->protection = yyextra->protection = Protection::Protected ;
3986 return FALSE;
3987}
3988
3989static bool handlePublic(yyscan_t yyscanner,const QCString &, const StringVector &)
3990{
3991 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3992 yyextra->current->protection = Protection::Public;
3993 return FALSE;
3994}
3995
3996static bool handlePublicSection(yyscan_t yyscanner,const QCString &, const StringVector &)
3997{
3998 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
3999 yyextra->current->protection = yyextra->protection = Protection::Public;
4000 return FALSE;
4001}
4002
4003static bool handleToc(yyscan_t yyscanner,const QCString &, const StringVector &optList)
4004{
4005 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4006 if (yyextra->current->section.isPageDoc() ||
4007 yyextra->current->section.isMainpageDoc())
4008 {
4009 for (const auto &opt_ : optList)
4010 {
4011 QCString opt = QCString(opt_).stripWhiteSpace().lower();
4012 int level = SectionType::MaxLevel;
4013 int i = opt.find(':');
4014 if (i>0) // found ':' but not on position 0 what would mean just a level
4015 {
4016 char dum=0;
4017 if (sscanf(opt.right(opt.length() - i - 1).data(),"%d%c",&level,&dum) != 1)
4018 {
4019 warn(yyextra->fileName,yyextra->lineNr,"Unknown option:level specified with \\tableofcontents: '{}'",
4021 opt = "";
4022 }
4023 else
4024 {
4025 level = level<=0 ? SectionType::MaxLevel : std::min(level,SectionType::MaxLevel);
4026 opt = opt.left(i).stripWhiteSpace();
4027 }
4028 }
4029 if (!opt.isEmpty())
4030 {
4031 if (opt == "html")
4032 {
4033 yyextra->current->localToc.enableHtml(level);
4034 }
4035 else if (opt == "latex")
4036 {
4037 yyextra->current->localToc.enableLatex(level);
4038 }
4039 else if (opt == "xml")
4040 {
4041 yyextra->current->localToc.enableXml(level);
4042 }
4043 else if (opt == "docbook")
4044 {
4045 yyextra->current->localToc.enableDocbook(level);
4046 }
4047 else
4048 {
4049 warn(yyextra->fileName,yyextra->lineNr,"Unknown option specified with \\tableofcontents: '{}'",
4050 QCString(opt_).stripWhiteSpace());
4051 }
4052 }
4053 }
4054 if (yyextra->current->localToc.nothingEnabled())
4055 {
4056 // for backward compatibility
4057 yyextra->current->localToc.enableHtml(SectionType::MaxLevel);
4058 yyextra->current->localToc.enableXml(SectionType::MaxLevel);
4059 }
4060 }
4061 return FALSE;
4062}
4063
4064static bool handleInherit(yyscan_t yyscanner,const QCString &, const StringVector &)
4065{
4066 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4067 BEGIN(InheritParam);
4068 return FALSE;
4069}
4070
4071static bool handleExtends(yyscan_t yyscanner,const QCString &cmd, const StringVector &)
4072{
4073 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4074 yyextra->currentCmd = cmd;
4075 BEGIN(ExtendsParam);
4076 return FALSE;
4077}
4078
4079static bool handleCopyBrief(yyscan_t yyscanner,const QCString &, const StringVector &)
4080{
4081 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4082 if (yyextra->current->brief.stripWhiteSpace().isEmpty() && yyextra->current->doc.stripWhiteSpace().isEmpty())
4083 { // if we don't have a brief or detailed description yet,
4084 // then the @copybrief should end up in the brief description.
4085 // otherwise it will be copied inline (see bug691315 & bug700788)
4086 setOutput(yyscanner,OutputBrief);
4087 }
4088 if (!yyextra->spaceBeforeCmd.isEmpty())
4089 {
4090 addOutput(yyscanner,yyextra->spaceBeforeCmd);
4091 yyextra->spaceBeforeCmd.clear();
4092 }
4093 addOutput(yyscanner,"\\copybrief ");
4094 return FALSE;
4095}
4096
4097static bool handleCopyDetails(yyscan_t yyscanner,const QCString &, const StringVector &)
4098{
4099 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4100 setOutput(yyscanner,OutputDoc);
4101 if (!yyextra->spaceBeforeCmd.isEmpty())
4102 {
4103 addOutput(yyscanner,yyextra->spaceBeforeCmd);
4104 yyextra->spaceBeforeCmd.clear();
4105 }
4106 addOutput(yyscanner,"\\copydetails ");
4107 return FALSE;
4108}
4109
4110static bool handleCopyDoc(yyscan_t yyscanner,const QCString &, const StringVector &)
4111{
4112 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4113 if (yyextra->current->brief.stripWhiteSpace().isEmpty() && yyextra->current->doc.stripWhiteSpace().isEmpty())
4114 { // if we don't have a brief or detailed description yet,
4115 // then the @copybrief should end up in the brief description.
4116 // otherwise it will be copied inline (see bug691315 & bug700788)
4117 setOutput(yyscanner,OutputBrief);
4118 }
4119 if (!yyextra->spaceBeforeCmd.isEmpty())
4120 {
4121 addOutput(yyscanner,yyextra->spaceBeforeCmd);
4122 yyextra->spaceBeforeCmd.clear();
4123 }
4124 addOutput(yyscanner,"\\copybrief ");
4125 yyextra->copyDocArg.clear();
4126 yyextra->braceCount = 0;
4127 BEGIN(CopyDoc);
4128 return FALSE;
4129}
4130
4131//-----------------------------------------------------------------------------------------
4132
4133static void initParser(yyscan_t yyscanner)
4134{
4135 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4136 yyextra->sectionLabel.clear();
4137 yyextra->sectionTitle.clear();
4138 yyextra->docGroup.clearHeader();
4139 yyextra->insideParBlock = FALSE;
4140}
4141
4142//-----------------------------------------------------------------------------
4143
4145{
4146 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4147 //printf("yyextra->current->section=%x\n",yyextra->current->section);
4148 return yyextra->current->section.isDoc();
4149}
4150
4152{
4153 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4154 assert(maker!=nullptr); // detect programming error
4155 //printf("yyextra->current->section=%x\n",yyextra->current->section);
4156 if (yyextra->current->section.isDoc())
4157 {
4158 return true;
4159 }
4160 else if (maker)
4161 {
4162 yyextra->needNewEntry = true;
4163 yyextra->current->section = maker();
4164 yyextra->current->fileName = yyextra->fileName;
4165 yyextra->current->startLine = yyextra->lineNr;
4166 if (yyextra->current->docLine == -1) yyextra->current->docLine = yyextra->lineNr;
4167 return false;
4168 }
4169 else
4170 {
4171 return false;
4172 }
4173}
4174
4175//-----------------------------------------------------------------
4176
4177static void lineCount(yyscan_t yyscanner)
4178{
4179 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4180 for( const char* c = yytext ; *c ; ++c )
4181 yyextra->lineNr += (*c == '\n') ;
4182}
4183
4184//-----------------------------------------------------------------
4185
4186static QCString stripQuotes(const char *s)
4187{
4188 QCString name;
4189 if (s==nullptr || *s==0) return name;
4190 name=s;
4191 if (name.at(0)=='"' && name.at(name.length()-1)=='"')
4192 {
4193 name=name.mid(1,name.length()-2);
4194 }
4195 return name;
4196}
4197
4198//-----------------------------------------------------------------
4199
4200static void addXRefItem(yyscan_t yyscanner,
4201 const QCString &listName,const QCString &itemTitle,
4202 const QCString &listTitle,bool append)
4203{
4204 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4205 if (listName.isEmpty()) return;
4206 //printf("addXRefItem(%s,%s,%s,%d)\n",listName,itemTitle,listTitle,append);
4207
4208 std::unique_lock<std::mutex> lock(g_sectionMutex);
4209
4210 RefList *refList = RefListManager::instance().add(listName,listTitle,itemTitle);
4211 RefItem *item = nullptr;
4212 for (auto it = yyextra->current->sli.rbegin(); it != yyextra->current->sli.rend(); ++it)
4213 {
4214 RefItem *i = *it;
4215 if (i && i->list()->listName()==listName)
4216 {
4217 //printf("found %s lii->type=%s\n",listName,qPrint(i->list()->listName()));
4218 item = i;
4219 break;
4220 }
4221 }
4222 if (item && append) // already found item of same type just before this one
4223 {
4224 //printf("listName=%s item id = %d existing\n",listName,item->id());
4225 item->setText(item->text() + " <p>" + yyextra->outputXRef);
4226 //printf("%s: text +=%s\n",listName,qPrint(item->text));
4227 }
4228 else // new item
4229 {
4230
4231 // if we have already an item from the same list type (e.g. a second @todo)
4232 // in the same Entry (i.e. lii!=0) then we reuse its link anchor.
4233 item = refList->add();
4234 //printf("listName=%s item id = %d new yyextra->current=%p\n",listName,item->id(),yyextra->current);
4235 QCString anchorLabel;
4236 anchorLabel.sprintf("_%s%06d",listName.data(),item->id());
4237 item->setText(yyextra->outputXRef);
4238 item->setAnchor(anchorLabel);
4239 yyextra->current->sli.push_back(item);
4240 QCString cmdString;
4241 cmdString.sprintf(" \\xrefitem %s %d.",qPrint(listName),item->id());
4242 if (yyextra->inBody)
4243 {
4244 yyextra->current->inbodyDocs += cmdString;
4245 }
4246 else
4247 {
4248 yyextra->current->doc += cmdString;
4249 }
4250
4251 {
4253 const SectionInfo *si = sm.find(anchorLabel);
4254 if (si)
4255 {
4256 if (!si->ref().isEmpty()) // we are from a tag file
4257 {
4258 si = sm.replace(anchorLabel,listName,yyextra->lineNr,
4259 yyextra->sectionTitle,SectionType::Anchor,
4260 yyextra->sectionLevel);
4261 yyextra->current->anchors.push_back(si);
4262 }
4263 else if (si->lineNr() != -1)
4264 {
4265 warn(listName,yyextra->lineNr,"multiple use of section label '{}', (first occurrence: {}, line {})",
4266 anchorLabel,si->fileName(),si->lineNr());
4267 }
4268 else
4269 {
4270 warn(listName,yyextra->lineNr,"multiple use of section label '{}', (first occurrence: {})",
4271 anchorLabel,si->fileName());
4272 }
4273 }
4274 else
4275 {
4276 si = sm.add(anchorLabel,listName,yyextra->lineNr,
4277 yyextra->sectionTitle,SectionType::Anchor,
4278 yyextra->sectionLevel);
4279 yyextra->current->anchors.push_back(si);
4280 }
4281 }
4282 }
4283 yyextra->outputXRef.clear();
4284}
4285
4286//-----------------------------------------------------------------------------
4287
4288// Adds a formula text to the list/dictionary of formulas if it was
4289// not already added. Returns the label of the formula.
4291{
4292 std::unique_lock<std::mutex> lock(g_formulaMutex);
4293 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4294 QCString formLabel;
4295 QCString formula = (yyextra->formulaPreText +
4296 yyextra->formulaText.stripLeadingAndTrailingEmptyLines() +
4297 yyextra->formulaPostText).stripWhiteSpace();
4298 //printf("formulaText=\n=1=\n{%s}\n=2=\n{%s}\n=3=\n{%s}\n===",
4299 // qPrint(yyextra->formulaText),
4300 // qPrint(yyextra->formulaText.stripLeadingAndTrailingEmptyLines()),
4301 // qPrint(formula)
4302 // );
4303 int id = FormulaManager::instance().addFormula(formula.str());
4304 formLabel.sprintf("\\_form#%d",id);
4305 for (int i=0;i<yyextra->formulaNewLines;i++) formLabel+="@_fakenl"; // add fake newlines to
4306 // keep the warnings
4307 // correctly aligned.
4308 return formLabel;
4309}
4310
4311//-----------------------------------------------------------------------------
4312
4314{
4315 if (level>=0 && level<SectionType::MaxLevel) return SectionType(level);
4316 return SectionType::Anchor;
4317}
4318
4319static void addSection(yyscan_t yyscanner, bool addYYtext)
4320{
4321 std::unique_lock<std::mutex> lock(g_sectionMutex);
4322 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4324 const SectionInfo *si = sm.find(yyextra->sectionLabel);
4325 if (si)
4326 {
4327 if (!si->ref().isEmpty()) // we are from a tag file
4328 {
4329 // create a new section element
4330 if (addYYtext) yyextra->sectionTitle+=yytext;
4331 yyextra->sectionTitle=yyextra->sectionTitle.stripWhiteSpace();
4332 si = sm.replace(yyextra->sectionLabel,yyextra->fileName,yyextra->lineNr,
4333 yyextra->sectionTitle,sectionLevelToType(yyextra->sectionLevel),
4334 yyextra->sectionLevel);
4335
4336 // add section to this entry
4337 yyextra->current->anchors.push_back(si);
4338 }
4339 else if (si->lineNr() != -1)
4340 {
4341 warn(yyextra->fileName,yyextra->lineNr,"multiple use of section label '{}' while adding section, (first occurrence: {}, line {})",
4342 yyextra->sectionLabel,si->fileName(),si->lineNr());
4343 }
4344 else
4345 {
4346 warn(yyextra->fileName,yyextra->lineNr,"multiple use of section label '{}' while adding section, (first occurrence: {})",
4347 yyextra->sectionLabel,si->fileName());
4348 }
4349 }
4350 else
4351 {
4352 // create a new section element
4353 if (addYYtext) yyextra->sectionTitle+=yytext;
4354 yyextra->sectionTitle=yyextra->sectionTitle.stripWhiteSpace();
4355 si = sm.add(yyextra->sectionLabel,yyextra->fileName,yyextra->lineNr,
4356 yyextra->sectionTitle,sectionLevelToType(yyextra->sectionLevel),
4357 yyextra->sectionLevel);
4358
4359 // add section to this entry
4360 yyextra->current->anchors.push_back(si);
4361 }
4362}
4363
4364//-----------------------------------------------------------------------------
4365
4366static void addCite(yyscan_t yyscanner)
4367{
4368 std::unique_lock<std::mutex> lock(g_citeMutex);
4369 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4370 QCString name(yytext);
4371 if (yytext[0] =='"')
4372 {
4373 name=yytext+1;
4374 name=name.left((int)yyleng-2);
4375 }
4377}
4378
4379//-----------------------------------------------------------------------------
4380static const reg::Ex nonBrief_re(R"( *[\\@]ifile \"[^\"]*\" [\\@]iline (\d+) [\\@]ilinebr ([ \n]*))");
4381
4382// strip trailing whitespace (excluding newlines) from string s
4384{
4385 size_t len = s.length();
4386 int i = (int)len-1;
4387 while (i>=0)
4388 {
4389 char c = s.at(i);
4390 if (c==' ' || c=='\t' || c=='\r') // normal whitespace
4391 {
4392 i--;
4393 }
4394 else if (c=='r' && i>=7 && literal_at(s.data()+i-7,"\\ilinebr")) // special line break marker
4395 {
4396 i-=8;
4397 }
4398 else // non-whitespace
4399 {
4400 break;
4401 }
4402 }
4403 //printf("stripTrailingWhitespace(%s) i=%d len=%d\n",qPrint(s),i,len);
4404 if (i!=(int)len-1)
4405 {
4406 s.resize(i+1); // string up to and including char at pos i
4407 }
4408}
4409
4410// selects the output to write to
4411static inline void setOutput(yyscan_t yyscanner,OutputContext ctx)
4412{
4413 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4414 bool xrefAppendToPrev = yyextra->xrefAppendFlag;
4415 // determine append flag for the next item (i.e. the end of this item)
4416 yyextra->xrefAppendFlag = !yyextra->inBody &&
4417 yyextra->inContext==OutputXRef && ctx==OutputXRef && // two consecutive xref items
4418 yyextra->newXRefKind==yyextra->xrefKind && // of the same kind
4419 (yyextra->xrefKind!=XRef_Item ||
4420 yyextra->newXRefItemKey==yyextra->xrefItemKey); // with the same key if \xrefitem
4421 //printf("%d && %d && %d && (%d || %d)\n",
4422 // yyextra->inContext==OutputXRef,
4423 // ctx==OutputXRef,
4424 // yyextra->newXRefKind==yyextra->xrefKind,
4425 // yyextra->xrefKind!=XRef_Item,
4426 // yyextra->newXRefItemKey==yyextra->xrefItemKey);
4427 //printf("refKind=%d yyextra->newXRefKind=%d xrefAppendToPrev=%d yyextra->xrefAppendFlag=%d\n",
4428 // yyextra->xrefKind,yyextra->newXRefKind,xrefAppendToPrev,yyextra->xrefAppendFlag);
4429
4430 //printf("setOutput(yyscanner,yyextra->inContext=%d ctx=%d)\n",yyextra->inContext,ctx);
4431 if (yyextra->inContext==OutputXRef) // end of XRef section => add the item
4432 {
4433 // See if we can append this new xref item to the previous one.
4434 // We know this at the start of the next item of the same
4435 // type and need to remember this until the end of that item.
4436 switch(yyextra->xrefKind)
4437 {
4438 case XRef_Todo:
4439 addXRefItem(yyscanner,QCString("todo"),
4440 theTranslator->trTodo(),
4441 theTranslator->trTodoList(),
4442 xrefAppendToPrev
4443 );
4444 break;
4445 case XRef_Test:
4446 addXRefItem(yyscanner,QCString("test"),
4447 theTranslator->trTest(),
4448 theTranslator->trTestList(),
4449 xrefAppendToPrev
4450 );
4451 break;
4452 case XRef_Bug:
4453 addXRefItem(yyscanner,QCString("bug"),
4454 theTranslator->trBug(),
4455 theTranslator->trBugList(),
4456 xrefAppendToPrev
4457 );
4458 break;
4459 case XRef_Deprecated:
4460 addXRefItem(yyscanner,QCString("deprecated"),
4461 theTranslator->trDeprecated(),
4462 theTranslator->trDeprecatedList(),
4463 xrefAppendToPrev
4464 );
4465 break;
4466 case XRef_Item: // user defined list
4467 addXRefItem(yyscanner,yyextra->xrefItemKey,
4468 yyextra->xrefItemTitle,
4469 yyextra->xrefListTitle,
4470 xrefAppendToPrev
4471 );
4472 break;
4473 case XRef_None:
4474 ASSERT(0);
4475 break;
4476 }
4477 }
4478 yyextra->xrefItemKey = yyextra->newXRefItemKey;
4479
4480 int oldContext = yyextra->inContext;
4481 yyextra->inContext = ctx;
4482 if (yyextra->inContext!=OutputXRef && yyextra->inBody) yyextra->inContext=OutputInbody;
4483 switch(yyextra->inContext)
4484 {
4485 case OutputDoc:
4486 if (oldContext!=yyextra->inContext)
4487 {
4488 stripTrailingWhiteSpace(yyextra->current->doc);
4489 if (yyextra->current->doc.isEmpty()) yyextra->current->docLine = yyextra->lineNr;
4490 if (yyextra->current->docFile.isEmpty())
4491 {
4492 yyextra->current->docFile = yyextra->fileName;
4493 yyextra->current->docLine = yyextra->lineNr;
4494 }
4495 }
4496 yyextra->pOutputString = &yyextra->current->doc;
4497 break;
4498 case OutputBrief:
4499 {
4500 if (oldContext!=yyextra->inContext)
4501 {
4502 if (yyextra->current->brief.isEmpty()) yyextra->current->briefLine = yyextra->lineNr;
4503 if (yyextra->current->briefFile.isEmpty())
4504 {
4505 yyextra->current->briefFile = yyextra->fileName;
4506 yyextra->current->briefLine = yyextra->lineNr;
4507 }
4508 }
4509 bool foundMatch = false;
4510 if (yyextra->current->brief.stripWhiteSpace().isEmpty()) // we only want one brief
4511 // description even if multiple
4512 // are given...
4513 {
4514 foundMatch = true;
4515 }
4516 else
4517 {
4518 std::string str = yyextra->current->brief.str();
4519 reg::Match match;
4520 if (reg::match(str,match,nonBrief_re)) // match found
4521 {
4522 size_t cnt = 0;
4523 for (size_t i = 0; i < match[2].str().size(); i++)
4524 {
4525 if (match[2].str()[i] == '\n') cnt++;
4526 }
4527 if (cnt>0)
4528 {
4529 yyextra->current->brief = yyextra->current->brief.left(yyextra->current->brief.length()-cnt);
4530 // set warning line correct
4531 yyextra->current->brief += " \\iline " + QCString().setNum(cnt + static_cast<int>(std::stoul(match[1].str()))) + " \\ilinebr ";
4532 }
4533 foundMatch = true;
4534 }
4535 }
4536 if (foundMatch)
4537 {
4538 yyextra->pOutputString = &yyextra->current->brief;
4539 }
4540 else
4541 {
4542 if (!yyextra->current->doc.isEmpty()) // when appending parts add a new line
4543 {
4544 yyextra->current->doc += "\n";
4545 }
4546 yyextra->pOutputString = &yyextra->current->doc;
4547 yyextra->inContext = OutputDoc; // need to switch to detailed docs, see bug 631380
4548 }
4549 }
4550 break;
4551 case OutputXRef:
4552 yyextra->pOutputString = &yyextra->outputXRef;
4553 // first item found, so can't append to previous
4554 //yyextra->xrefAppendFlag = FALSE;
4555 break;
4556 case OutputInbody:
4557 yyextra->pOutputString = &yyextra->current->inbodyDocs;
4558 break;
4559 }
4560}
4561
4562
4563static void addAnchor(yyscan_t yyscanner,const QCString &anchor, const QCString &title)
4564{
4565 std::unique_lock<std::mutex> lock(g_sectionMutex);
4566 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4568 const SectionInfo *si = sm.find(anchor);
4569 if (si)
4570 {
4571 if (!si->ref().isEmpty()) // we are from a tag file
4572 {
4573 si = sm.replace(anchor,yyextra->fileName,yyextra->lineNr,QCString(),SectionType::Anchor,0);
4574 yyextra->current->anchors.push_back(si);
4575 }
4576 else if (si->lineNr() != -1)
4577 {
4578 warn(yyextra->fileName,yyextra->lineNr,
4579 "multiple use of section label '{}' while adding anchor, (first occurrence: {}, line {})",
4580 anchor,si->fileName(),si->lineNr());
4581 }
4582 else
4583 {
4584 warn(yyextra->fileName,yyextra->lineNr,"multiple use of section label '{}' while adding anchor, (first occurrence: {})",
4585 anchor,si->fileName());
4586 }
4587 }
4588 else
4589 {
4590 si = sm.add(anchor,yyextra->fileName,yyextra->lineNr,title,SectionType::Anchor,0);
4591 yyextra->current->anchors.push_back(si);
4592 }
4593}
4594
4595// add a string to the output
4596static inline void addOutput(yyscan_t yyscanner,const char *s)
4597{
4598 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4599 //printf("addOutput(yyscanner,%s)\n",s);
4600 *yyextra->pOutputString+=s;
4601}
4602
4603// add a string to the output
4604static inline void addOutput(yyscan_t yyscanner,const QCString &s)
4605{
4606 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4607 //printf("addOutput(yyscanner,%s)\n",s);
4608 *yyextra->pOutputString+=s;
4609}
4610
4611// add a character to the output
4612static inline void addOutput(yyscan_t yyscanner,char c)
4613{
4614 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4615 *yyextra->pOutputString+=c;
4616}
4617
4618static void addIline(yyscan_t yyscanner,int lineNr)
4619{
4620 char cmd[30];
4621 qsnprintf(cmd,30," \\iline %d ",lineNr);
4622 addOutput(yyscanner, cmd);
4623}
4624
4625static void addIlineBreak(yyscan_t yyscanner,int lineNr)
4626{
4627 char cmd[30];
4628 qsnprintf(cmd,30," \\iline %d \\ilinebr ",lineNr);
4629 addOutput(yyscanner, cmd);
4630}
4631
4632static void endBrief(yyscan_t yyscanner)
4633{
4634 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4635 std::string_view str = yyextra->current->brief.view();
4636 reg::Match match;
4637 if (!stripWhiteSpace(str).empty() && !reg::match(str,match,nonBrief_re))
4638 { // only go to the detailed description if we have
4639 // found some brief description and not just whitespace
4640 yyextra->briefEndsAtDot=FALSE;
4641 setOutput(yyscanner,OutputDoc);
4642 if (yyextra->current->doc.stripWhiteSpace().isEmpty())
4643 {
4644 yyextra->current->docLine = yyextra->lineNr;
4645 yyextra->current->doc = "";
4646 }
4647 else
4648 {
4649 addIline(yyscanner,yyextra->lineNr);
4650 }
4651 addOutput(yyscanner,yytext);
4652 }
4653 else
4654 {
4655 int saveLineNr = yyextra->lineNr;
4656 lineCount(yyscanner);
4657 yyextra->current->briefLine = yyextra->lineNr;
4658 yyextra->lineNr = saveLineNr;
4659 }
4660}
4661
4662static int yyread(yyscan_t yyscanner,char *buf,int max_size)
4663{
4664 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4665 yyextra->prevPosition=yyextra->inputPosition;
4666 int c=0;
4667 while( c < max_size && yyextra->inputString[yyextra->inputPosition] )
4668 {
4669 *buf = yyextra->inputString[yyextra->inputPosition++] ;
4670 //printf("%d (%c)\n",*buf,*buf);
4671 c++; buf++;
4672 }
4673 return c;
4674}
4675
4676//----------------------------------------------------------------------------
4677
4678static void checkFormula(yyscan_t yyscanner)
4679{
4680 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4681 if (YY_START==ReadFormulaShort || YY_START==ReadFormulaShortSection ||
4682 YY_START==ReadFormulaRound || YY_START==ReadFormulaRoundSection ||
4683 YY_START==ReadFormulaLong)
4684 {
4685 warn(yyextra->fileName,yyextra->lineNr,"End of comment block while inside formula.");
4686 }
4687}
4688
4689//----------------------------------------------------------------------------
4690
4696
4698{
4699 commentscanYYlex_init_extra(&p->extra,&p->yyscanner);
4700#ifdef FLEX_DEBUG
4701 commentscanYYset_debug(Debug::isFlagSet(Debug::Lex_commentscan)?1:0,p->yyscanner);
4702#endif
4703}
4704
4706{
4707 commentscanYYlex_destroy(p->yyscanner);
4708}
4709
4711 /* in */ Entry *curEntry,
4712 /* in */ const QCString &comment,
4713 /* in */ const QCString &fileName,
4714 /* in,out */ int &lineNr,
4715 /* in */ bool isBrief,
4716 /* in */ bool isAutoBriefOn,
4717 /* in */ bool isInbody,
4718 /* in,out */ Protection &prot,
4719 /* in,out */ int &position,
4720 /* out */ bool &newEntryNeeded,
4721 /* in */ bool markdownSupport,
4722 /* inout */ GuardedSectionStack *guards
4723 )
4724{
4725 AUTO_TRACE("comment='{}' fileName={} lineNr={} isBrief={} isAutoBriefOn={} inInbody={}"
4726 " prot={} markdownSupport={}",Trace::trunc(comment),fileName,lineNr,isBrief,
4727 isAutoBriefOn,isInbody,prot,markdownSupport);
4728 yyscan_t yyscanner = p->yyscanner;
4729 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4730
4731 initParser(yyscanner);
4732 yyextra->guards = guards;
4733 yyextra->langParser = parser;
4734 yyextra->current = curEntry;
4735 yyextra->current->docLine = (lineNr > 1 ? lineNr : 1);
4736 if (comment.isEmpty()) return FALSE; // avoid empty strings
4737 yyextra->inputString = comment;
4738 yyextra->inputString.append(" ");
4739 yyextra->inputPosition = position;
4740 yyextra->lineNr = lineNr;
4741 yyextra->fileName = fileName;
4742 yyextra->protection = prot;
4743 yyextra->needNewEntry = FALSE;
4744 yyextra->xrefKind = XRef_None;
4745 yyextra->xrefAppendFlag = FALSE;
4746 yyextra->insidePre = FALSE;
4747 yyextra->parseMore = FALSE;
4748 yyextra->inBody = isInbody;
4749 yyextra->markdownSupport= markdownSupport;
4750 yyextra->outputXRef.clear();
4751 if (!isBrief && !isAutoBriefOn && !yyextra->current->doc.isEmpty())
4752 { // add newline separator between detailed comment blocks
4753 yyextra->current->doc += '\n';
4754 }
4755 setOutput(yyscanner, isBrief || isAutoBriefOn ? OutputBrief : OutputDoc );
4756 yyextra->briefEndsAtDot = isAutoBriefOn;
4757 yyextra->condCount = 0;
4758 yyextra->sectionLevel = 0;
4759 yyextra->spaceBeforeCmd.clear();
4760 yyextra->spaceBeforeIf.clear();
4761 yyextra->htmlContextStack.clear();
4762
4763 DebugLex debugLex(Debug::Lex_commentscan, __FILE__, !fileName.isEmpty() ? qPrint(fileName): nullptr);
4764 if (!yyextra->current->inbodyDocs.isEmpty() && isInbody) // separate in body fragments
4765 {
4766 char cmd[30];
4767 qsnprintf(cmd,30,"\n\n\\iline %d \\ilinebr ",lineNr);
4768 yyextra->current->inbodyDocs+=cmd;
4769 }
4770
4771 Debug::print(Debug::CommentScan,0,"-----------\nCommentScanner: {}:{}\n"
4772 "input=[\n{}]\n",fileName,lineNr,yyextra->inputString
4773 );
4774
4775 commentscanYYrestart( nullptr, yyscanner );
4776 BEGIN( Comment );
4777 commentscanYYlex(yyscanner);
4778 setOutput(yyscanner, OutputDoc );
4779
4780 if (YY_START==OverloadParam) // comment ended with \overload
4781 {
4782 addOutput(yyscanner,getOverloadDocs());
4783 }
4784
4785 if (yyextra->insideParBlock)
4786 {
4787 warn(yyextra->fileName,yyextra->lineNr,
4788 "Documentation block ended while inside a \\parblock. Missing \\endparblock");
4789 }
4790
4791 yyextra->current->doc=stripLeadingAndTrailingEmptyLines(yyextra->current->doc,yyextra->current->docLine);
4792 yyextra->current->brief=stripLeadingAndTrailingEmptyLines(yyextra->current->brief,yyextra->current->docLine);
4793
4794 if (yyextra->current->section.isFileDoc() && yyextra->current->doc.isEmpty())
4795 {
4796 // to allow a comment block with just a @file command.
4797 yyextra->current->doc="\n\n";
4798 }
4799
4800 if (yyextra->current->section.isMemberGrp() &&
4801 yyextra->docGroup.isEmpty()) // @name section but no group started yet
4802 {
4803 yyextra->docGroup.open(yyextra->current,yyextra->fileName,yyextra->lineNr,true);
4804 }
4805
4806 Debug::print(Debug::CommentScan,0,"-----------\nCommentScanner: {}:{}\noutput=[\n"
4807 "brief=[line={}\n{}]\ndocs=[line={}\n{}]\ninbody=[line={}\n{}]\n]\n===========\n",
4808 fileName,lineNr,
4809 yyextra->current->briefLine,yyextra->current->brief,
4810 yyextra->current->docLine,yyextra->current->doc,
4811 yyextra->current->inbodyLine,yyextra->current->inbodyDocs
4812 );
4813
4814 checkFormula(yyscanner);
4815 prot = yyextra->protection;
4816
4817 yyextra->docGroup.addDocs(curEntry);
4818
4819 newEntryNeeded = yyextra->needNewEntry;
4820
4821 // if we did not proceed during this call, it does not make
4822 // sense to continue, since we get stuck. See bug 567346 for situations
4823 // were this happens
4824 if (yyextra->parseMore && position==yyextra->inputPosition) yyextra->parseMore=FALSE;
4825
4826 if (!yyextra->parseMore && !yyextra->guards->empty())
4827 {
4828 warn(yyextra->fileName,yyextra->lineNr,"Documentation block ended in the middle of a conditional section!");
4829 }
4830
4831 if (yyextra->parseMore) position=yyextra->inputPosition; else position=0;
4832
4833 lineNr = yyextra->lineNr;
4834 AUTO_TRACE_EXIT("position={} parseMore={} newEntryNeeded={}",
4835 position,yyextra->parseMore,newEntryNeeded);
4836
4837 return yyextra->parseMore;
4838}
4839
4840static void handleGuard(yyscan_t yyscanner,const QCString &expr)
4841{
4842 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
4843 CondParser prs;
4844 bool sectionEnabled = false;
4845 if (!expr.isEmpty())
4846 {
4847 sectionEnabled=prs.parse(yyextra->fileName,yyextra->lineNr,expr.stripWhiteSpace());
4848 }
4849 bool parentEnabled = yyextra->guards->top().parentVisible();
4850 if (parentEnabled)
4851 {
4852 if (
4853 (sectionEnabled && yyextra->guardType==Guard_If) ||
4854 (!sectionEnabled && yyextra->guardType==Guard_IfNot)
4855 ) // section is visible
4856 {
4857
4858 yyextra->guards->top().setEnabled(true);
4859 yyextra->guards->top().setEnabledFound();
4860 BEGIN( GuardParamEnd );
4861 }
4862 else if (yyextra->guardType==Guard_ElseIf)
4863 {
4864 if (yyextra->guards->top().isEnabledFound())
4865 {
4866 yyextra->guards->top().setEnabled(false);
4867 BEGIN( SkipGuardedSection );
4868 }
4869 else if (sectionEnabled)
4870 {
4871 yyextra->guards->top().setEnabled(true);
4872 yyextra->guards->top().setEnabledFound();
4873 BEGIN( GuardParamEnd );
4874 }
4875 else
4876 {
4877 yyextra->guards->top().setEnabled(false);
4878 BEGIN( SkipGuardedSection );
4879 }
4880 }
4881 else // section is invisible
4882 {
4883 BEGIN( SkipGuardedSection );
4884 }
4885 }
4886 else // invisible because of parent
4887 {
4888 BEGIN( SkipGuardedSection );
4889 }
4890}
4891
4893{
4894 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
4895 yyextra->docGroup.initGroupInfo(entry);
4896}
4897
4898void CommentScanner::enterFile(const QCString &fileName,int lineNr)
4899{
4900 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
4901 yyextra->docGroup.enterFile(fileName,lineNr);
4902}
4903
4904void CommentScanner::leaveFile(const QCString &fileName,int lineNr)
4905{
4906 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
4907 yyextra->docGroup.leaveFile(fileName,lineNr);
4908}
4909
4910void CommentScanner::enterCompound(const QCString &fileName,int lineNr,const QCString &name)
4911{
4912 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
4913 yyextra->docGroup.enterCompound(fileName,lineNr,name);
4914}
4915
4916void CommentScanner::leaveCompound(const QCString &fileName,int lineNr,const QCString &name)
4917{
4918 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
4919 yyextra->docGroup.leaveCompound(fileName,lineNr,name);
4920}
4921
4922void CommentScanner::open(Entry *e,const QCString &fileName,int lineNr,bool implicit)
4923{
4924 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
4925 yyextra->docGroup.open(e,fileName,lineNr,implicit);
4926}
4927
4928void CommentScanner::close(Entry *e,const QCString &fileName,int lineNr,bool foundInline,bool implicit)
4929{
4930 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
4931 yyextra->docGroup.close(e,fileName,lineNr,foundInline,implicit);
4932}
4933
4934#include "commentscan.l.h"
static CitationManager & instance()
Definition cite.cpp:80
void insert(const QCString &label)
Insert a citation identified by label into the database.
Definition cite.cpp:90
void close(Entry *e, const QCString &fileName, int line, bool foundInline, bool implicit=false)
void leaveCompound(const QCString &fileName, int line, const QCString &name)
void open(Entry *e, const QCString &fileName, int line, bool implicit=false)
bool parseCommentBlock(OutlineParserInterface *parser, Entry *curEntry, const QCString &comment, const QCString &fileName, int &lineNr, bool isBrief, bool isJavadocStyle, bool isInbody, Protection &prot, int &position, bool &newEntryNeeded, bool markdownEnabled, GuardedSectionStack *guards)
Invokes the comment block parser with the request to parse a single comment block.
void initGroupInfo(Entry *entry)
std::unique_ptr< Private > p
void enterCompound(const QCString &fileName, int line, const QCString &name)
void enterFile(const QCString &fileName, int lineNr)
void leaveFile(const QCString &fileName, int lineNr)
Copyright (C) 1997-2015 by Dimitri van Heesch.
Definition condparser.h:28
bool parse(const QCString &fileName, int lineNr, const QCString &expr)
Copyright (C) 1997-2015 by Dimitri van Heesch.
@ Lex_commentscan
Definition debug.h:54
@ CommentScan
Definition debug.h:32
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:132
static void print(DebugMask mask, int prio, fmt::format_string< Args... > fmt, Args &&... args)
Definition debug.h:76
int docLine
line number at which the documentation was found
Definition entry.h:201
@ GROUPDOC_WEAK
weakgroup
Definition entry.h:123
@ GROUPDOC_ADD
addtogroup
Definition entry.h:122
Minimal replacement for QFileInfo.
Definition fileinfo.h:23
int addFormula(const std::string &formulaText, int width=-1, int height=-1)
Definition formula.cpp:691
static FormulaManager & instance()
Definition formula.cpp:54
T * add(const char *k, Args &&... args)
Definition linkedmap.h:90
const T * find(const std::string &key) const
Definition linkedmap.h:47
bool startsWith(const char *s) const
Definition qcstring.h:492
QCString lower() const
Definition qcstring.h:234
char & at(size_t i)
Returns a reference to the character at index i.
Definition qcstring.h:578
void resize(size_t newlen)
Definition qcstring.h:167
QCString right(size_t len) const
Definition qcstring.h:219
QCString & sprintf(const char *format,...)
Definition qcstring.cpp:29
This struct represents an item in the list of references.
Definition reflist.h:32
QCString text() const
Definition reflist.h:45
int id() const
Definition reflist.h:52
void setAnchor(const QCString &anchor)
Definition reflist.h:37
void setText(const QCString &text)
Definition reflist.h:36
RefList * list() const
Definition reflist.h:53
List of cross-referenced items.
Definition reflist.h:80
QCString listName() const
Definition reflist.h:101
RefItem * add()
Definition reflist.cpp:30
static RefListManager & instance()
Definition reflist.h:121
class that provide information about a section.
Definition section.h:57
QCString ref() const
Definition section.h:71
QCString fileName() const
Definition section.h:73
int lineNr() const
Definition section.h:72
singleton class that owns the list of all sections
Definition section.h:134
SectionInfo * replace(const QCString &label, const QCString &fileName, int lineNr, const QCString &title, SectionType type, int level, const QCString &ref=QCString())
Definition section.h:154
SectionInfo * add(const SectionInfo &si)
Definition section.h:138
static SectionManager & instance()
returns a reference to the singleton
Definition section.h:175
static constexpr int Anchor
Definition section.h:40
static constexpr int Section
Definition section.h:33
static constexpr int MaxLevel
Definition section.h:39
static constexpr int Subsection
Definition section.h:34
static constexpr int Subsubsection
Definition section.h:35
static constexpr int Paragraph
Definition section.h:36
static constexpr int Subsubparagraph
Definition section.h:38
static constexpr int Subparagraph
Definition section.h:37
Class representing a regular expression.
Definition regex.h:39
Object representing the matching results.
Definition regex.h:153
static int yyread(yyscan_t yyscanner, char *buf, int max_size)
Definition code.l:3989
static const reg::Ex nonBrief_re(R"( *[\\@]ifile \"[^\"]*\" [\\@]iline (\d+) [\\@]ilinebr ([ \n]*))")
#define Config_getBool(name)
Definition config.h:33
#define AUTO_TRACE(...)
Definition docnode.cpp:46
#define AUTO_TRACE_EXIT(...)
Definition docnode.cpp:48
Translator * theTranslator
Definition language.cpp:71
QCString trunc(const QCString &s, size_t numChars=15)
Definition trace.h:56
bool match(std::string_view str, Match &match, const Ex &re)
Matches a given string str for a match against regular expression re.
Definition regex.cpp:759
#define qsnprintf
Definition qcstring.h:49
#define ASSERT(x)
Definition qcstring.h:39
bool literal_at(const char *data, const char(&str)[N])
returns TRUE iff data points to a substring that matches string literal str
Definition stringutil.h:98
commentscanYY_state extra
static QCString stripFromPath(const QCString &p, const StringVector &l)
Definition util.cpp:309
QCString stripLeadingAndTrailingEmptyLines(const QCString &s, int &docLine)
Special version of QCString::stripWhiteSpace() that only strips completely blank lines.
Definition util.cpp:5533
const char * comment