Doxygen
Loading...
Searching...
No Matches
lexcode.l
Go to the documentation of this file.
-1/******************************************************************************
2 *
3 * Copyright (C) 1997-2021 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 */
13
14%option never-interactive
15%option prefix="lexcodeYY"
16%option noyywrap
17%option reentrant
18%option extra-type="struct lexcodeYY_state *"
19%top{
20#include <stdint.h>
21// forward declare yyscan_t to improve type safety
22#define YY_TYPEDEF_YY_SCANNER_T
23struct yyguts_t;
24typedef yyguts_t *yyscan_t;
yyguts_t * yyscan_t
Definition code.l:24
25}
27%{
28
29#include <memory>
30#include <stdio.h>
31
32#include "config.h"
33#include "doxygen.h"
34#include "outputgen.h"
35#include "outputlist.h"
36#include "code.h"
37#include "lexcode.h"
38#include "filedef.h"
39#include "message.h"
40#include "debug.h"
41#include "searchindex.h"
42#include "util.h"
43
44#define YY_NEVER_INTERACTIVE 1
45#define YY_NO_INPUT 1
46#define YY_NO_UNISTD_H 1
49{
52 const char *inputString; //!< the code fragment as text
53 int inputPosition; //!< read offset during parsing
54 int inputLines; //!< number of line in the code fragment
56 int yyLineNr; //!< current line number
57 bool insideCodeLine = false;
60 const Definition *searchCtx;
63 int lastContext = 0;
64 int lastCContext = 0;
69 int curlyCount = 0;
74 int roundCount = 0;
78 size_t fencedSize = 0;
79 bool nestedComment = false;
82 bool exampleBlock;
86 std::unique_ptr<FileDef> exampleFileDef;
87 const FileDef *sourceFileDef = nullptr;
88 const Definition *currentDefinition = nullptr;
89 const MemberDef *currentMemberDef = nullptr;
91 const char *currentFontClass = nullptr;
92};
94[[maybe_unused]] static const char *stateToString(int state);
95
96static void setCurrentDoc(yyscan_t yyscanner,const QCString &anchor);
97static void startCodeLine(yyscan_t yyscanner);
98static void endFontClass(yyscan_t yyscanner);
99static void endCodeLine(yyscan_t yyscanner);
100static void nextCodeLine(yyscan_t yyscanner);
101static void codifyLines(yyscan_t yyscanner,const QCString &text);
102static void startFontClass(yyscan_t yyscanner,const char *s);
103static int countLines(yyscan_t yyscanner);
104static int yyread(yyscan_t yyscanner,char *buf,int max_size);
105static void lineCount(yyscan_t yyscanner);
106static void handleCCode(yyscan_t yyscanner);
107
108#undef YY_INPUT
109#define YY_INPUT(buf,result,max_size) result=yyread(yyscanner,buf,max_size);
110
111// otherwise the filename would be the name of the converted file (*.cpp instead of *.l)
112static inline const char *getLexerFILE() {return __FILE__;}
113#include "doxygen_lex.h"
The common base class of all entity definitions found in the sources.
Definition definition.h:76
A model of a file symbol.
Definition filedef.h:99
A model of a class/file/namespace member symbol.
Definition memberdef.h:48
Class representing a list of different code generators.
Definition outputlist.h:165
This is an alternative implementation of QCString.
Definition qcstring.h:101
static void endCodeLine(yyscan_t yyscanner)
Definition code.l:2478
static void nextCodeLine(yyscan_t yyscanner)
Definition code.l:2487
static void startCodeLine(yyscan_t yyscanner)
Definition code.l:2409
static void codifyLines(yyscan_t yyscanner, const QCString &text)
Definition code.l:2505
static int yyread(yyscan_t yyscanner, char *buf, int max_size)
Definition code.l:3971
static int countLines(yyscan_t yyscanner)
Definition code.l:3462
static const char * stateToString(int state)
static void startFontClass(yyscan_t yyscanner, const char *s, bool specialComment=false)
Definition code.l:3495
static void endFontClass(yyscan_t yyscanner, bool specialComment=false)
Definition code.l:3480
static const char * getLexerFILE()
Definition code.l:263
static void setCurrentDoc(yyscan_t yyscanner, const QCString &anchor)
Definition code.l:2277
#define lineCount(s, len)
static void handleCCode(yyscan_t yyscanner)
Definition lexcode.l:1138
#define FALSE
Definition qcstring.h:34
Web server based search engine.
QCString docBlockName
Definition lexcode.l:79
int lastRawStringContext
Definition lexcode.l:70
std::unique_ptr< FileDef > exampleFileDef
Definition lexcode.l:88
bool exampleBlock
Definition lexcode.l:84
const FileDef * sourceFileDef
Definition lexcode.l:89
int inputPosition
read offset during parsing
Definition lexcode.l:55
bool stripCodeComments
Definition lexcode.l:83
QCString rulesPatternBuffer
Definition lexcode.l:73
bool insideCodeLine
Definition lexcode.l:59
bool nestedComment
Definition lexcode.l:81
const char * currentFontClass
Definition lexcode.l:93
int lastStringContext
Definition lexcode.l:67
int lastPreLineCtrlContext
Definition lexcode.l:69
const Definition * currentDefinition
Definition lexcode.l:90
QCString fileName
Definition lexcode.l:57
QCString exampleName
Definition lexcode.l:85
QCString classScope
Definition lexcode.l:86
const char * inputString
the code fragment as text
Definition lexcode.l:54
OutputCodeList * code
Definition lexcode.l:52
bool insideCode
Definition lexcode.l:77
QCString CCodeBuffer
Definition lexcode.l:74
int inputLines
number of line in the code fragment
Definition lexcode.l:56
CCodeParser ccodeParser
Definition lexcode.l:53
const MemberDef * currentMemberDef
Definition lexcode.l:91
size_t fencedSize
Definition lexcode.l:80
const Definition * searchCtx
Definition lexcode.l:62
bool includeCodeFragment
Definition lexcode.l:92
bool collectXRefs
Definition lexcode.l:63
int docBlockContext
Definition lexcode.l:68
bool lineNumbers
Definition lexcode.l:61
int yyLineNr
current line number
Definition lexcode.l:58
QCString delimiter
Definition lexcode.l:78
int startCCodeLine
Definition lexcode.l:75
A bunch of utility functions.
115%}
116
117nl (\r\n|\r|\n)
118ws [ \t]
119nws [^ \t\n]
120TopStart "%top{"{nl}
121TopEnd "}"{nl}
122LiteralStart "%{"{nl}
123LiteralEnd "%}"{nl}
124RulesStart "%%"{nl}
125RulesEnd "%%"{nl}
126RulesSharp "<"[^>\n]*">"
127RulesCurly "{"[^{}\n]*"}"
128StartSquare "["
129StartDouble "\""
130StartRound "("
131StartRoundQuest "(?"
132EscapeRulesCharOpen "\\‍["|"\<"|"\\{"|"\\‍("|"\\\""|"\\ "|"\\\\"
133EscapeRulesCharClose "\\‍]"|"\>"|"\\}"|"\\‍)"
134EscapeRulesChar {EscapeRulesCharOpen}|{EscapeRulesCharClose}
135
136CMD ("\\"|"@")
137BN [ \t\n\r]
138BL [ \t\r]*"\n"
139B [ \t]
140Bopt {B}*
141ID [$a-z_A-Z\x80-\xFF][$a-z_A-Z0-9\x80-\xFF]*
142PRE [pP][rR][eE]
143CODE [cC][oO][dD][eE]
144RAWBEGIN (u|U|L|u8)?R\"[^ \t\‍(\‍)\\‍]{0,16}"("
145RAWEND ")"[^ \t\‍(\‍)\\‍]{0,16}\"
146CHARLIT (("'"\\‍[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'"))
147CHARCE "[:"[^:]*":]"
148
149 /* no comment start / end signs inside square brackets */
150NCOMM [^/\*]
151 // C start comment
152CCS "/\*"
153 // C end comment
154CCE "*\/"
155 // Cpp comment
156CPPC "/\/"
157 // doxygen start comment
158DCOMM ("/\*!"|"/\**"|"/\/!"|"/\/\/")
159
160 // Optional any character
161ANYopt .*
162 // Optional all but newline
163NONLopt [^\n]*
164
165%x DefSection
166%x DefSectionLine
167%x RulesSectionInit
168%x RulesPattern
169%x RulesDouble
170%x RulesRoundDouble
171%x RulesSquare
172%x RulesRoundSquare
173%x RulesRound
174%x RulesRoundQuest
175%x UserSection
176
177%x TopSection
178%x LiteralSection
179
180%x COMMENT
181
182%x SkipCurly
183%x SkipCurlyEndDoc
184%x PreLineCtrl
185%x DocLine
186%x DocBlock
187%x DocCopyBlock
188%x SkipString
189%x RawString
190%x SkipComment
191%x SkipCxxComment
192%x Comment
193
194%%
195
196<*>\x0d
197<DefSection>^{TopStart} {
198 handleCCode(yyscanner);
199 codifyLines(yyscanner,yytext);
200 yyextra->lastContext = YY_START;
201 yyextra->startCCodeLine=yyextra->yyLineNr;
202 BEGIN (TopSection);
203 }
204<DefSection>^{LiteralStart} {
205 handleCCode(yyscanner);
206 codifyLines(yyscanner,yytext);
207 yyextra->lastContext = YY_START;
208 yyextra->startCCodeLine=yyextra->yyLineNr;
209 BEGIN (LiteralSection);
210 }
211<TopSection>^{TopEnd} {
212 handleCCode(yyscanner);
213 codifyLines(yyscanner,yytext);
214 BEGIN( yyextra->lastContext ) ;
215 }
216<TopSection>.*{nl} {
217 yyextra->CCodeBuffer += yytext;
218 yyextra->yyLineNr++;
219 }
220<LiteralSection>^{LiteralEnd} {
221 handleCCode(yyscanner);
222 codifyLines(yyscanner,yytext);
223 BEGIN( yyextra->lastContext ) ;
224 }
225<LiteralSection>.*{nl} {
226 yyextra->CCodeBuffer += yytext;
227 yyextra->yyLineNr++;
228 }
229<DefSection>{CPPC}.*{nl} {
230 yyextra->CCodeBuffer += yytext;
231 yyextra->yyLineNr++;
232 }
233<DefSection>^{ws}*{CCS} {
234 yyextra->CCodeBuffer += yytext;
235 yyextra->lastContext = YY_START;
236 BEGIN(COMMENT);
237 }
238<COMMENT>{CCE}{ws}*{nl} {
239 yyextra->CCodeBuffer+=yytext;
240 yyextra->yyLineNr++;
241 handleCCode(yyscanner);
242 BEGIN(yyextra->lastContext);
243 }
244<COMMENT>{CCE} {
245 yyextra->CCodeBuffer+=yytext;
246 handleCCode(yyscanner);
247 BEGIN(yyextra->lastContext);
248 }
249<COMMENT>[^*\n]+ {
250 yyextra->CCodeBuffer += yytext;
251 }
252<COMMENT>{CPPC}|{CCS} {
253 yyextra->CCodeBuffer += yytext;
254 }
255<COMMENT>{nl} {
256 yyextra->CCodeBuffer += yytext;
257 yyextra->yyLineNr++;
258 }
259<COMMENT>. {
260 yyextra->CCodeBuffer += yytext;
261 }
262<DefSection>^{nl} {
263 handleCCode(yyscanner);
264 codifyLines(yyscanner,yytext);
265 yyextra->startCCodeLine=yyextra->yyLineNr;
266 }
267<DefSection>^{ws}.*{nl} {
268 yyextra->CCodeBuffer += yytext;
269 yyextra->yyLineNr++;
270 }
271<DefSection>^{RulesStart} {
272 handleCCode(yyscanner);
273 codifyLines(yyscanner,yytext);
274 yyextra->startCCodeLine=yyextra->yyLineNr;
275 BEGIN (RulesSectionInit);
276 }
277<DefSection>^{nws} {
278 handleCCode(yyscanner);
279 codifyLines(yyscanner,yytext);
280 BEGIN(DefSectionLine);
281 }
282<DefSectionLine>.*{nl} {
283 codifyLines(yyscanner,yytext);
284 yyextra->startCCodeLine=yyextra->yyLineNr;
285 BEGIN(DefSection);
286 }
287<RulesSectionInit,RulesPattern>^{RulesEnd} {
288 handleCCode(yyscanner);
289 codifyLines(yyscanner,yytext);
290 yyextra->startCCodeLine=yyextra->yyLineNr;
291 BEGIN (UserSection);
292 }
293<RulesSectionInit>^{nws} {
294 handleCCode(yyscanner);
295 unput(*yytext);
296 BEGIN(RulesPattern);
297 }
298<RulesSectionInit>{nl} {
299 yyextra->CCodeBuffer += yytext;
300 yyextra->yyLineNr++;
301 }
302<RulesSectionInit>^{ws}.*{nl} {
303 yyextra->CCodeBuffer += yytext;
304 yyextra->yyLineNr++;
305 }
306<RulesPattern>"<<EOF>>" {
307 yyextra->rulesPatternBuffer += yytext;
308 }
309<RulesPattern>{EscapeRulesChar} {
310 yyextra->rulesPatternBuffer += yytext;
311 }
312<RulesPattern>{RulesSharp} {
313 yyextra->rulesPatternBuffer += yytext;
314 }
315<RulesPattern>{RulesCurly} {
316 yyextra->rulesPatternBuffer += yytext;
317 }
318<RulesPattern>{StartDouble} {
319 yyextra->rulesPatternBuffer += yytext;
320 yyextra->lastContext = YY_START;
321 BEGIN(RulesDouble);
322 }
323<RulesDouble,RulesRoundDouble>"\\\\" {
324 yyextra->rulesPatternBuffer += yytext;
325 }
326<RulesDouble,RulesRoundDouble>"\\\"" {
327 yyextra->rulesPatternBuffer += yytext;
328 }
329<RulesDouble>"\"" {
330 yyextra->rulesPatternBuffer += yytext;
331 BEGIN( yyextra->lastContext ) ;
332 }
333<RulesRoundDouble>"\"" {
334 yyextra->rulesPatternBuffer += yytext;
335 BEGIN(RulesRound) ;
336 }
337<RulesDouble,RulesRoundDouble>. {
338 yyextra->rulesPatternBuffer += yytext;
339 }
340<RulesPattern>{StartSquare} {
341 yyextra->rulesPatternBuffer += yytext;
342 yyextra->lastContext = YY_START;
343 BEGIN(RulesSquare);
344 }
345<RulesSquare,RulesRoundSquare>{CHARCE} {
346 yyextra->rulesPatternBuffer += yytext;
347 }
348<RulesSquare,RulesRoundSquare>"\\‍[" |
349<RulesSquare,RulesRoundSquare>"\\‍]" {
350 yyextra->rulesPatternBuffer += yytext;
351 }
352<RulesSquare>"]" {
353 yyextra->rulesPatternBuffer += yytext;
354 BEGIN(RulesPattern) ;
355 }
356<RulesRoundSquare>"]" {
357 yyextra->rulesPatternBuffer += yytext;
358 BEGIN(RulesRound) ;
359 }
360<RulesSquare,RulesRoundSquare>"\\\\" {
361 yyextra->rulesPatternBuffer += yytext;
362 }
363<RulesSquare,RulesRoundSquare>. {
364 yyextra->rulesPatternBuffer += yytext;
365 }
366<RulesPattern>{StartRoundQuest} {
367 yyextra->rulesPatternBuffer += yytext;
368 yyextra->lastContext = YY_START;
369 BEGIN(RulesRoundQuest);
370 }
371<RulesRoundQuest>{nl} {
372 yyextra->rulesPatternBuffer += yytext;
373 if (!yyextra->rulesPatternBuffer.isEmpty())
374 {
375 startFontClass(yyscanner,"stringliteral");
376 codifyLines(yyscanner,yyextra->rulesPatternBuffer.data());
377 yyextra->rulesPatternBuffer.clear();
378 endFontClass(yyscanner);
379 }
380 }
381<RulesRoundQuest>[^)] {
382 yyextra->rulesPatternBuffer += yytext;
383 }
384<RulesRoundQuest>")" {
385 yyextra->rulesPatternBuffer += yytext;
386 BEGIN(yyextra->lastContext);
387 }
388<RulesPattern>{StartRound} {
389 yyextra->roundCount++;
390 yyextra->rulesPatternBuffer += yytext;
391 yyextra->lastContext = YY_START;
392 BEGIN(RulesRound);
393 }
394<RulesRound>{RulesCurly} {
395 yyextra->rulesPatternBuffer += yytext;
396 }
397<RulesRound>{StartSquare} {
398 yyextra->rulesPatternBuffer += yytext;
399 BEGIN(RulesRoundSquare);
400 }
401<RulesRound>{StartDouble} {
402 yyextra->rulesPatternBuffer += yytext;
403 BEGIN(RulesRoundDouble);
404 }
405<RulesRound>{EscapeRulesChar} {
406 yyextra->rulesPatternBuffer += yytext;
407 }
408<RulesRound>"(" {
409 yyextra->roundCount++;
410 yyextra->rulesPatternBuffer += yytext;
411 }
412<RulesRound>")" {
413 yyextra->roundCount--;
414 yyextra->rulesPatternBuffer += yytext;
415 if (!yyextra->roundCount) BEGIN( yyextra->lastContext ) ;
416 }
417<RulesRound>{nl} {
418 yyextra->rulesPatternBuffer += yytext;
419 yyextra->yyLineNr++;
420 }
421<RulesRound>{ws} {
422 yyextra->rulesPatternBuffer += yytext;
423 }
424<RulesRound>. {
425 yyextra->rulesPatternBuffer += yytext;
426 }
427<RulesPattern>{ws}+"|" {
428 if (!yyextra->rulesPatternBuffer.isEmpty())
429 {
430 startFontClass(yyscanner,"stringliteral");
431 codifyLines(yyscanner,yyextra->rulesPatternBuffer);
432 yyextra->rulesPatternBuffer.clear();
433 endFontClass(yyscanner);
434 }
435 codifyLines(yyscanner,yytext);
436 yyextra->startCCodeLine=yyextra->yyLineNr;
437 yyextra->curlyCount = 0;
438 BEGIN(SkipCurly);
439 }
440<RulesPattern>^{ws}*{nl} {
441 codifyLines(yyscanner,"\n");
442 }
443<RulesPattern>^{ws}+ {
444 codifyLines(yyscanner,yytext);
445 }
446<RulesPattern>({ws}|{nl}) {
447 unput(*yytext);
448 if (!yyextra->rulesPatternBuffer.isEmpty())
449 {
450 startFontClass(yyscanner,"stringliteral");
451 codifyLines(yyscanner,yyextra->rulesPatternBuffer);
452 yyextra->rulesPatternBuffer.clear();
453 endFontClass(yyscanner);
454 }
455 yyextra->startCCodeLine=yyextra->yyLineNr;
456 yyextra->curlyCount = 0;
457 BEGIN(SkipCurly);
458 }
459<RulesPattern>"\\\\" {
460 yyextra->rulesPatternBuffer += yytext;
461 }
462<RulesPattern>{CCS} {
463 if (!yyextra->rulesPatternBuffer.isEmpty())
464 {
465 startFontClass(yyscanner,"stringliteral");
466 codifyLines(yyscanner,yyextra->rulesPatternBuffer);
467 yyextra->rulesPatternBuffer.clear();
468 endFontClass(yyscanner);
469 }
470 yyextra->CCodeBuffer += yytext;
471 yyextra->lastContext = YY_START;
472 BEGIN(COMMENT);
473 }
474<RulesPattern>. {
475 yyextra->rulesPatternBuffer += yytext;
476 }
477<SkipCurly>{B}*"#"{B}+[0-9]+{B}+/"\"" { /* line control directive */
478 yyextra->CCodeBuffer += yytext;
479 yyextra->lastPreLineCtrlContext = YY_START;
480 BEGIN( PreLineCtrl );
481 }
482<PreLineCtrl>"\""[^\n\"]*"\"" {
483 yyextra->CCodeBuffer += yytext;
484 }
485<PreLineCtrl>. {
486 yyextra->CCodeBuffer += yytext;
487 }
488<PreLineCtrl>\n {
489 yyextra->CCodeBuffer += yytext;
490 yyextra->yyLineNr++;
491 BEGIN( yyextra->lastPreLineCtrlContext );
492 }
493<SkipCurly>"{" {
494 yyextra->CCodeBuffer += yytext;
495 ++yyextra->curlyCount ;
496 }
497<SkipCurly>"}"/{BN}*{DCOMM}"<!--" | /* see bug710917 */
498<SkipCurly>"}" {
499 yyextra->CCodeBuffer += yytext;
500 lineCount(yyscanner);
501 if( yyextra->curlyCount )
502 {
503 --yyextra->curlyCount ;
504 }
505 }
506<SkipCurly>"}"{BN}*{DCOMM}"<" {
507 yyextra->CCodeBuffer += yytext;
508 lineCount(yyscanner);
509 if ( yyextra->curlyCount )
510 {
511 --yyextra->curlyCount ;
512 }
513 else
514 {
515 yyextra->docBlockContext = SkipCurlyEndDoc;
516 if (yytext[yyleng-3]=='/')
517 {
518 BEGIN( DocLine );
519 }
520 else
521 {
522 BEGIN( DocBlock );
523 }
524 }
525 }
526<SkipCurly>\" {
527 yyextra->CCodeBuffer += yytext;
528 yyextra->lastStringContext=SkipCurly;
529 BEGIN( SkipString );
530 }
531<SkipCurly>^{B}*"#" {
532 yyextra->CCodeBuffer += yytext;
533 yyextra->lastPreLineCtrlContext = YY_START;
534 BEGIN( PreLineCtrl );
535 }
536<SkipCurly>{B}*{RAWBEGIN} {
537 char *p = yytext;
538 while (*p && qisspace(*p)) p++;
539 yyextra->delimiter = extractBeginRawStringDelimiter(p);
540 yyextra->lastRawStringContext = YY_START;
541 yyextra->CCodeBuffer += yytext;
542 BEGIN(RawString);
543 }
bool qisspace(char c)
Definition qcstring.h:81
QCString extractBeginRawStringDelimiter(const char *rawStart)
Definition util.cpp:6903
544<SkipCurly>[^\n#"'@\\/{}<]+ {
545 yyextra->CCodeBuffer += yytext;
546 }
547<SkipCurly>{CCS} {
548 yyextra->CCodeBuffer += yytext;
549 yyextra->lastCContext = YY_START;
550 BEGIN(SkipComment);
551 }
552<SkipCurly>{CPPC} {
553 yyextra->CCodeBuffer += yytext;
554 yyextra->lastCContext = YY_START;
555 BEGIN(SkipCxxComment);
556 }
557<SkipCurly>{CHARLIT} {
558 yyextra->CCodeBuffer += yytext;
559 }
560<SkipCurly>\' {
561 yyextra->CCodeBuffer += yytext;
562 }
563<SkipCurly>. {
564 yyextra->CCodeBuffer += yytext;
565 }
566<SkipCurly>({CPPC}{B}*)?{CCS}"!" {
567 yyextra->CCodeBuffer += yytext;
568 yyextra->docBlockContext = YY_START;
569 BEGIN( DocBlock );
570 }
571<SkipCurly>{CCS}"*"[*]+{BL} {
572 bool javadocBanner = Config_getBool(JAVADOC_BANNER);
573 yyextra->CCodeBuffer += yytext;
574 yyextra->yyLineNr++;
575 if( javadocBanner )
576 {
577 yyextra->docBlockContext = YY_START;
578 BEGIN( DocBlock );
579 }
580 else
581 {
582 BEGIN( Comment ) ;
583 }
584 }
#define Config_getBool(name)
Definition config.h:33
585<SkipCurly>({CPPC}{B}*)?{CCS}"*"/{NCOMM} {
586 yyextra->CCodeBuffer += yytext;
587 yyextra->docBlockContext = YY_START;
588 BEGIN( DocBlock );
589 }
590<SkipCurly>{CPPC}"!" {
591 yyextra->CCodeBuffer += yytext;
592 yyextra->docBlockContext = YY_START;
593 BEGIN( DocLine );
594 }
595<SkipCurly>{CPPC}"/"/[^/] {
596 yyextra->CCodeBuffer += yytext;
597 yyextra->docBlockContext = YY_START;
598 BEGIN( DocLine );
599 }
600
601<SkipCurly>\n {
602 yyextra->CCodeBuffer += yytext;
603 yyextra->yyLineNr++;
604 if (yyextra->curlyCount<=0)
605 {
606 handleCCode(yyscanner);
607 BEGIN(RulesPattern);
608 }
609 }
610<SkipString>\\. {
611 yyextra->CCodeBuffer += yytext;
612 }
613<SkipString>\" {
614 yyextra->CCodeBuffer += yytext;
615 BEGIN( yyextra->lastStringContext );
616 }
617<SkipString>{CCS}|{CCE}|{CPPC} {
618 yyextra->CCodeBuffer += yytext;
619 }
620<SkipString>\n {
621 yyextra->CCodeBuffer += yytext;
622 yyextra->yyLineNr++;
623 }
624<SkipString>. {
625 yyextra->CCodeBuffer += yytext;
626 }
627<SkipCxxComment>.*"\\\n" { // line continuation
628 yyextra->CCodeBuffer += yytext;
629 yyextra->yyLineNr++;
630 }
631<SkipCxxComment>{ANYopt}/\n {
632 yyextra->CCodeBuffer += yytext;
633 BEGIN( yyextra->lastCContext ) ;
634 }
635<Comment>{BN}+ {
636 yyextra->CCodeBuffer += yytext ;
637 lineCount(yyscanner);
638 }
639<Comment>{CCS} { yyextra->CCodeBuffer += yytext ; }
640<Comment>{CPPC} { yyextra->CCodeBuffer += yytext ; }
641<Comment>{CMD}("code"|"verbatim"|"iliteral") {
642 yyextra->insideCode=TRUE;
643 yyextra->CCodeBuffer += yytext ;
644 }
#define TRUE
Definition qcstring.h:37
645<Comment>{CMD}("endcode"|"endverbatim"|"endiliteral") {
646 yyextra->insideCode=FALSE;
647 yyextra->CCodeBuffer += yytext ;
648 }
649<Comment>[^ \.\t\r\n\/\*]+ { yyextra->CCodeBuffer += yytext ; }
650<Comment>{CCE} {
651 yyextra->CCodeBuffer += yytext ;
652 if (!yyextra->insideCode) BEGIN( yyextra->lastContext ) ;
653 }
654<Comment>. { yyextra->CCodeBuffer += *yytext ; }
655
656<SkipComment>{CPPC}|{CCS} {
657 yyextra->CCodeBuffer += yytext;
658 }
659<SkipComment>[^\*\n]+ {
660 yyextra->CCodeBuffer += yytext;
661 }
662<SkipComment>\n {
663 yyextra->CCodeBuffer += yytext;
664 yyextra->yyLineNr++;
665 }
666<SkipComment>{B}*{CCE} {
667 yyextra->CCodeBuffer += yytext;
668 BEGIN( yyextra->lastCContext );
669 }
670<SkipComment>"*" {
671 yyextra->CCodeBuffer += yytext;
672 }
673<RawString>{RAWEND} {
674 yyextra->CCodeBuffer += yytext;
675 if (extractEndRawStringDelimiter(yytext)==yyextra->delimiter)
676 {
677 BEGIN(yyextra->lastRawStringContext);
678 }
679 }
QCString extractEndRawStringDelimiter(const char *rawEnd)
Definition util.cpp:6911
680<RawString>[^)\n]+ {
681 yyextra->CCodeBuffer += yytext;
682 }
683<RawString>. {
684 yyextra->CCodeBuffer += yytext;
685 }
686<RawString>\n {
687 yyextra->CCodeBuffer += yytext;
688 yyextra->yyLineNr++;
689 }
690
691
692 /* ---- Single line comments ------ */
693<DocLine>[^\n]*"\n"[ \t]*{CPPC}[/!][<]? { // continuation of multiline C++-style comment
694 yyextra->CCodeBuffer += yytext;
695 lineCount(yyscanner);
696 }
697<DocLine>{B}*{CPPC}"/"[/]+{Bopt}/"\n" { // ignore marker line (see bug700345)
698 yyextra->CCodeBuffer += yytext;
699 BEGIN( yyextra->docBlockContext );
700 }
701<DocLine>{NONLopt}/"\n"{B}*{CPPC}[!/]{B}*{CMD}"}" { // next line is an end group marker, see bug 752712
702 yyextra->CCodeBuffer += yytext;
703 BEGIN( yyextra->docBlockContext );
704 }
705<DocLine>{NONLopt}/"\n" { // whole line
706 yyextra->CCodeBuffer += yytext;
707 BEGIN( yyextra->docBlockContext );
708 }
709
710 /* ---- Comments blocks ------ */
711
712<DocBlock>"*"*{CCE} { // end of comment block
713 yyextra->CCodeBuffer += yytext;
714 BEGIN(yyextra->docBlockContext);
715 }
716<DocBlock>^{B}*"*"+/[^/] {
717 yyextra->CCodeBuffer += yytext;
718 }
719<DocBlock>^{B}*({CPPC})?{B}*"*"+/[^/a-z_A-Z0-9*] { // start of a comment line
720 yyextra->CCodeBuffer += yytext;
721 }
722<DocBlock>^{B}*({CPPC}){B}* { // strip embedded C++ comments if at the start of a line
723 yyextra->CCodeBuffer += yytext;
724 }
725<DocBlock>{CPPC} { // slashes in the middle of a comment block
726 yyextra->CCodeBuffer += yytext;
727 }
728<DocBlock>{CCS} { // start of a new comment in the
729 // middle of a comment block
730 yyextra->CCodeBuffer += yytext;
731 }
732<DocBlock>({CMD}{CMD}){ID}/[^a-z_A-Z0-9] { // escaped command
733 yyextra->CCodeBuffer += yytext;
734 }
735<DocBlock>{CMD}("f$"|"f["|"f{"|"f(") {
736 yyextra->CCodeBuffer += yytext;
737 yyextra->docBlockName=&yytext[1];
738 if (yyextra->docBlockName.at(1)=='[')
739 {
740 yyextra->docBlockName.at(1)=']';
741 }
742 if (yyextra->docBlockName.at(1)=='{')
743 {
744 yyextra->docBlockName.at(1)='}';
745 }
746 if (yyextra->docBlockName.at(1)=='(')
747 {
748 yyextra->docBlockName.at(1)=')';
749 }
750 yyextra->fencedSize=0;
751 yyextra->nestedComment=FALSE;
752 BEGIN(DocCopyBlock);
753 }
754<DocBlock>{B}*"<"{PRE}">" {
755 yyextra->CCodeBuffer += yytext;
756 yyextra->docBlockName="<pre>";
757 yyextra->fencedSize=0;
758 yyextra->nestedComment=FALSE;
759 BEGIN(DocCopyBlock);
760 }
761<DocBlock>{CMD}"startuml"/[^a-z_A-Z0-9\-] { // verbatim type command (which could contain nested comments!)
762 yyextra->CCodeBuffer += yytext;
763 yyextra->docBlockName="uml";
764 yyextra->fencedSize=0;
765 yyextra->nestedComment=FALSE;
766 BEGIN(DocCopyBlock);
767 }
768<DocBlock>{CMD}("verbatim"|"iliteral"|"latexonly"|"htmlonly"|"xmlonly"|"manonly"|"rtfonly"|"docbookonly"|"dot"|"msc"|"code")/[^a-z_A-Z0-9\-] { // verbatim command (which could contain nested comments!)
769 yyextra->CCodeBuffer += yytext;
770 yyextra->docBlockName=&yytext[1];
771 yyextra->fencedSize=0;
772 yyextra->nestedComment=FALSE;
773 BEGIN(DocCopyBlock);
774 }
775<DocBlock>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
776 yyextra->CCodeBuffer += yytext;
777 QCString pat = substitute(yytext,"*"," ");
778 yyextra->docBlockName="~~~";
779 yyextra->fencedSize=pat.stripWhiteSpace().length();
780 yyextra->nestedComment=FALSE;
781 BEGIN(DocCopyBlock);
782 }
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:166
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
Definition qcstring.h:260
QCString substitute(const QCString &s, const QCString &src, const QCString &dst)
substitute all occurrences of src in s by dst
Definition qcstring.cpp:571
783<DocBlock>^({B}*"*"+)?{B}{0,3}"```"[`]* {
784 yyextra->CCodeBuffer += yytext;
785 QCString pat = substitute(yytext,"*"," ");
786 yyextra->docBlockName="```";
787 yyextra->fencedSize=pat.stripWhiteSpace().length();
788 yyextra->nestedComment=FALSE;
789 BEGIN(DocCopyBlock);
790 }
791<DocBlock>{B}*"<code>" {
792 REJECT;
793 }
794<DocBlock>[^@*~\/\\\n]+ { // any character that isn't special
795 yyextra->CCodeBuffer += yytext;
796 }
797<DocBlock>\n { // newline
798 yyextra->CCodeBuffer += yytext;
799 lineCount(yyscanner);
800 }
801<DocBlock>. { // command block
802 yyextra->CCodeBuffer += yytext;
803 }
804 /* ---- Copy verbatim sections ------ */
805
806<DocCopyBlock>"</"{PRE}">" { // end of a <pre> block
807 yyextra->CCodeBuffer += yytext;
808 if (yyextra->docBlockName=="<pre>")
809 {
810 BEGIN(DocBlock);
811 }
812 }
813<DocCopyBlock>"</"{CODE}">" { // end of a <code> block
814 yyextra->CCodeBuffer += yytext;
815 if (yyextra->docBlockName=="<code>")
816 {
817 BEGIN(DocBlock);
818 }
819 }
820<DocCopyBlock>{CMD}("f$"|"f]"|"f}"|"f)") {
821 yyextra->CCodeBuffer += yytext;
822 if (yyextra->docBlockName==&yytext[1])
823 {
824 BEGIN(DocBlock);
825 }
826 }
827<DocCopyBlock>{CMD}("endverbatim"|"endiliteral"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endmanonly"|"endrtfonly"|"enddot"|"endmsc"|"enduml"|"endcode")/[^a-z_A-Z0-9] { // end of verbatim block
828 yyextra->CCodeBuffer += yytext;
829 if (&yytext[4]==yyextra->docBlockName)
830 {
831 BEGIN(DocBlock);
832 }
833 }
834<DocCopyBlock>^{B}*"*"+/{BN}+ { // start of a comment line
835 yyextra->CCodeBuffer += yytext;
836 if ((yyextra->docBlockName=="verbatim") || (yyextra->docBlockName=="code") || (yyextra->docBlockName=="iliteral"))
837 {
838 REJECT;
839 }
840 else
841 {
842 yyextra->CCodeBuffer += yytext;
843 }
844 }
845<DocCopyBlock>^{B}*"*"+/{B}+"*"{BN}* { // start of a comment line with two *'s
846 if ((yyextra->docBlockName=="code") || (yyextra->docBlockName=="iliteral"))
847 {
848 yyextra->CCodeBuffer += yytext;
849 }
850 else
851 {
852 REJECT;
853 }
854 }
855<DocCopyBlock>^{B}*"*"+/({ID}|"(") { // Assume *var or *(... is part of source code (see bug723516)
856 if ((yyextra->docBlockName=="code") || (yyextra->docBlockName=="iliteral"))
857 {
858 yyextra->CCodeBuffer += yytext;
859 }
860 else
861 {
862 REJECT;
863 }
864 }
865<DocCopyBlock>^{B}*"*"+/{BN}* { // start of a comment line with one *
866 if ((yyextra->docBlockName=="code") || (yyextra->docBlockName=="iliteral"))
867 {
868 if (yyextra->nestedComment) // keep * it is part of the code
869 {
870 yyextra->CCodeBuffer += yytext;
871 }
872 else // remove * it is part of the comment block
873 {
874 yyextra->CCodeBuffer += yytext;
875 }
876 }
877 else
878 {
879 REJECT;
880 }
881 }
882<DocCopyBlock>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
883 yyextra->CCodeBuffer += yytext;
884 QCString pat = substitute(yytext,"*"," ");
885 if (yyextra->fencedSize==pat.stripWhiteSpace().length())
886 {
887 BEGIN(DocBlock);
888 }
889 }
890<DocCopyBlock>^({B}*"*"+)?{B}{0,3}"```"[`]* {
891 yyextra->CCodeBuffer += yytext;
892 QCString pat = substitute(yytext,"*"," ");
893 if (yyextra->fencedSize==pat.stripWhiteSpace().length())
894 {
895 BEGIN(DocBlock);
896 }
897 }
898<DocCopyBlock>[^<@/\*\‍]~\$\\\n]+ { // any character that is not special
899 yyextra->CCodeBuffer += yytext;
900 }
901<DocCopyBlock>{CCS}|{CCE}|{CPPC} {
902 if (yytext[1]=='*')
903 {
904 yyextra->nestedComment=TRUE;
905 }
906 else if (yytext[0]=='*')
907 {
908 yyextra->nestedComment=FALSE;
909 }
910 yyextra->CCodeBuffer += yytext;
911 }
912<DocCopyBlock>\n { // newline
913 yyextra->CCodeBuffer += yytext;
914 lineCount(yyscanner);
915 }
916<DocCopyBlock>. { // any other character
917 yyextra->CCodeBuffer += yytext;
918 }
919<SkipCurlyEndDoc>"}"{BN}*{DCOMM}"<" { // desc is followed by another one
920 yyextra->docBlockContext = SkipCurlyEndDoc;
921 yyextra->CCodeBuffer += yytext;
922 if (yytext[yyleng-3]=='/')
923 {
924 BEGIN( DocLine );
925 }
926 else
927 {
928 BEGIN( DocBlock );
929 }
930 }
931<SkipCurlyEndDoc>"}" {
932 yyextra->CCodeBuffer += yytext;
933 BEGIN(SkipCurly);
934 }
935
936<UserSection>.*{nl} {
937 yyextra->CCodeBuffer += yytext;
938 yyextra->yyLineNr++;
939 }
940 /*
941<*>. { fprintf(stderr,"Lex code scanner Def rule for %s: #%s#\n",stateToString(YY_START),yytext);}
942<*>{nl} { fprintf(stderr,"Lex code scanner Def rule for newline %s: #%s#\n",stateToString(YY_START),yytext); yyextra->yyLineNr++;}
943 */
944<*><<EOF>> {
945 handleCCode(yyscanner);
946 yyterminate();
947 }
#define yyterminate()
948%%
949
950static void setCurrentDoc(yyscan_t yyscanner,const QCString &anchor)
951{
952 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
953 if (Doxygen::searchIndex.enabled())
954 {
955 if (yyextra->searchCtx)
956 {
957 Doxygen::searchIndex.setCurrentDoc(yyextra->searchCtx,yyextra->searchCtx->anchor(),false);
958 }
959 else
960 {
961 Doxygen::searchIndex.setCurrentDoc(yyextra->sourceFileDef,anchor,true);
962 }
963 }
964}
965
966/*! start a new line of code, inserting a line number if yyextra->sourceFileDef
967 * is true. If a definition starts at the current line, then the line
968 * number is linked to the documentation of that definition.
969 */
970static void startCodeLine(yyscan_t yyscanner)
971{
972 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
973 if (yyextra->sourceFileDef && yyextra->lineNumbers)
974 {
975 const Definition *d = yyextra->sourceFileDef->getSourceDefinition(yyextra->yyLineNr);
976
977 if (!yyextra->includeCodeFragment && d)
978 {
979 yyextra->currentDefinition = d;
980 yyextra->currentMemberDef = yyextra->sourceFileDef->getSourceMember(yyextra->yyLineNr);
981 yyextra->classScope = d->name();
982 QCString lineAnchor;
983 lineAnchor.sprintf("l%05d",yyextra->yyLineNr);
984 if (yyextra->currentMemberDef)
985 {
986 yyextra->code->writeLineNumber(yyextra->currentMemberDef->getReference(),
987 yyextra->currentMemberDef->getOutputFileBase(),
988 yyextra->currentMemberDef->anchor(),yyextra->yyLineNr,
989 !yyextra->includeCodeFragment);
990 setCurrentDoc(yyscanner,lineAnchor);
991 }
992 else
993 {
994 yyextra->code->writeLineNumber(d->getReference(),
996 QCString(),yyextra->yyLineNr,
997 !yyextra->includeCodeFragment);
998 setCurrentDoc(yyscanner,lineAnchor);
999 }
1000 }
1001 else
1002 {
1003 yyextra->code->writeLineNumber(QCString(),QCString(),QCString(),yyextra->yyLineNr,
1004 !yyextra->includeCodeFragment);
1005 }
1006 }
1007
1008 yyextra->code->startCodeLine(yyextra->yyLineNr);
1009 yyextra->insideCodeLine = true;
1010
1011
1012 if (yyextra->currentFontClass)
1013 {
1014 yyextra->code->startFontClass(yyextra->currentFontClass);
1015 }
1016}
1017
1018static void endFontClass(yyscan_t yyscanner)
1019{
1020 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1021 if (yyextra->currentFontClass)
1022 {
1023 yyextra->code->endFontClass();
1024 yyextra->currentFontClass=0;
1025 }
1026}
1027
1028static void endCodeLine(yyscan_t yyscanner)
1029{
1030 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1031 endFontClass(yyscanner);
1032 yyextra->code->endCodeLine();
1033 yyextra->insideCodeLine = false;
1034}
1035
1036static void nextCodeLine(yyscan_t yyscanner)
1037{
1038 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1039 const char *fc = yyextra->currentFontClass;
1040 if (yyextra->insideCodeLine)
1041 {
1042 endCodeLine(yyscanner);
1043 }
1044 if (yyextra->yyLineNr<yyextra->inputLines)
1045 {
1046 yyextra->currentFontClass = fc;
1047 startCodeLine(yyscanner);
1048 }
1049}
1050
1051static void codifyLines(yyscan_t yyscanner,const QCString &text)
1052{
1053 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1054 if (text.isEmpty()) return;
1055 const char *p=text.data(),*sp=p;
1056 bool done=false;
1057 while (!done)
1058 {
1059 sp=p;
1060 char c = 0;
1061 while ((c=*p++) && c!='\n') { }
1062 if (c=='\n')
1063 {
1064 yyextra->yyLineNr++;
1065 size_t l = static_cast<size_t>(p-sp-1);
1066 yyextra->code->codify(QCString(sp,l));
1067 nextCodeLine(yyscanner);
1068 }
1069 else
1070 {
1071 yyextra->code->codify(sp);
1072 done=true;
1073 }
1074 }
1075 yyextra->startCCodeLine = yyextra->yyLineNr;
1076}
1077
1078static void startFontClass(yyscan_t yyscanner,const char *s)
1079{
1080 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1081 endFontClass(yyscanner);
1082 if (!yyextra->currentFontClass || !s || strcmp(yyextra->currentFontClass,s))
1083 {
1084 endFontClass(yyscanner);
1085 yyextra->code->startFontClass(s);
1086 yyextra->currentFontClass=s;
1087 }
1088}
1089
1090/*! counts the number of lines in the input */
1091static int countLines(yyscan_t yyscanner)
1092{
1093 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1094 const char *p=yyextra->inputString;
1095 char c = 0;
1096 int count=1;
1097 while ((c=*p))
1098 {
1099 p++ ;
1100 if (c=='\n') count++;
1101 }
1102 if (p>yyextra->inputString && *(p-1)!='\n')
1103 { // last line does not end with a \n, so we add an extra
1104 count++;
1105 }
1106 return count;
1107}
1108
1109static int yyread(yyscan_t yyscanner,char *buf,int max_size)
1110{
1111 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1112 int inputPosition = yyextra->inputPosition;
1113 const char *s = yyextra->inputString + inputPosition;
1114 int c=0;
1115 while( c < max_size && *s )
1116 {
1117 *buf++ = *s++;
1118 c++;
1119 }
1120 yyextra->inputPosition += c;
1121 return c;
1122}
1123
1124static void lineCount(yyscan_t yyscanner)
1125{
1126 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1127 for (const char *p = yytext ; *p ; ++p )
1128 {
1129 if (*p=='\n')
1130 {
1131 yyextra->yyLineNr++;
1132 }
1133 }
1134}
1135
1136static void handleCCode(yyscan_t yyscanner)
1137{
1138 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1139 if (yyextra->CCodeBuffer.isEmpty()) return;
1140
1141 yyextra->ccodeParser.setInsideCodeLine(yyextra->insideCodeLine);
1142 yyextra->ccodeParser.parseCode(*yyextra->code,
1143 yyextra->classScope,
1144 yyextra->CCodeBuffer,
1145 SrcLangExt::Cpp,
1146 yyextra->stripCodeComments,
1148 .setExample(yyextra->exampleBlock,yyextra->exampleName)
1149 .setFileDef(yyextra->sourceFileDef)
1150 .setStartLine(yyextra->startCCodeLine)
1151 .setInlineFragment(yyextra->includeCodeFragment)
1152 .setMemberDef(yyextra->currentMemberDef)
1153 .setShowLineNumbers(yyextra->lineNumbers)
1154 .setSearchCtx(yyextra->searchCtx)
1155 .setCollectXRefs(yyextra->collectXRefs)
1156 );
1157 yyextra->CCodeBuffer.clear();
1158 yyextra->insideCodeLine = yyextra->ccodeParser.insideCodeLine();
1159 yyextra->yyLineNr--;
1160 codifyLines(yyscanner,"\n");
1161}
1162
1163// public interface -----------------------------------------------------------
1164
1166{
1172{
1173 lexcodeYYlex_init_extra(&p->state, &p->yyscanner);
1174#ifdef FLEX_DEBUG
1175 lexcodeYYset_debug(Debug::isFlagSet(Debug::Lex_lexcode)?1:0,p->yyscanner);
1176#endif
1178}
1179
1181{
1182 lexcodeYYlex_destroy(p->yyscanner);
1183}
1184
1186{
1187 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
1188 yyextra->currentDefinition = nullptr;
1189 yyextra->currentMemberDef = nullptr;
1190}
1191
1193 const QCString &scopeName,
1194 const QCString &input,
1195 SrcLangExt,
1196 bool stripCodeComments,
1197 const CodeParserOptions &options
1198 )
1199{
1200 yyscan_t yyscanner = p->yyscanner;
1201 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1202
1203 if (input.isEmpty()) return;
1204
1205 DebugLex debugLex(Debug::Lex_lexcode, __FILE__, options.fileDef() ? qPrint(options.fileDef()->fileName()) : nullptr);
1206
1207 yyextra->code = &codeOutIntf;
1208 yyextra->inputString = input.data();
1209 yyextra->inputPosition = 0;
1210 yyextra->fileName = options.fileDef() ? options.fileDef()->fileName():"";
1211 yyextra->currentFontClass = nullptr;
1212 yyextra->insideCodeLine = false;
1213 yyextra->classScope = scopeName;
1214 yyextra->currentMemberDef = options.memberDef();
1215 yyextra->searchCtx = options.searchCtx();
1216 yyextra->collectXRefs = options.collectXRefs();
1217 yyextra->yyLineNr = options.startLine()!=1 ? options.startLine() : 1;
1218 yyextra->inputLines = options.endLine()!=-1 ? options.endLine()+1 : yyextra->yyLineNr + countLines(yyscanner) - 1;
1219 yyextra->startCCodeLine = yyextra->yyLineNr;
1220 yyextra->stripCodeComments = stripCodeComments;
1221 yyextra->exampleBlock = options.isExample();
1222 yyextra->exampleName = options.exampleName();
1223 yyextra->sourceFileDef = options.fileDef();
1224 yyextra->lineNumbers = options.fileDef()!=nullptr && options.showLineNumbers();
1225
1226 if (options.isExample() && options.fileDef()==nullptr)
1227 {
1228 // create a dummy filedef for the example
1229 yyextra->exampleFileDef = createFileDef(QCString(),!options.exampleName().isEmpty() ? options.exampleName() : QCString("generated"));
1230 yyextra->sourceFileDef = yyextra->exampleFileDef.get();
1231 }
1232
1233 if (yyextra->sourceFileDef)
1234 {
1235 setCurrentDoc(yyscanner,"l00001");
1236 }
1237
1238 yyextra->includeCodeFragment = options.inlineFragment();
1239 // Starts line 1 on the output
1240 startCodeLine(yyscanner);
1241
1242 lexcodeYYrestart( nullptr, yyscanner );
1243 BEGIN( DefSection );
1244 lexcodeYYlex(yyscanner);
1245
1246 if (yyextra->insideCodeLine)
1247 {
1248 endCodeLine(yyscanner);
1249 }
1250 if (yyextra->exampleFileDef)
1251 {
1252 // delete the temporary file definition used for this example
1253 yyextra->exampleFileDef.reset();
1254 yyextra->sourceFileDef=0;
1255 }
1256}
1257
1258//---------------------------------------------------------------------------------
1259
1260#include "lexcode.l.h"
@ Lex_lexcode
Definition debug.h:62
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:132
virtual QCString getReference() const =0
virtual QCString getOutputFileBase() const =0
virtual const QCString & name() const =0
static SearchIndexIntf searchIndex
Definition doxygen.h:123
virtual QCString fileName() const =0
std::unique_ptr< Private > p
Definition lexcode.h:46
void resetCodeParserState() override
Resets the state of the code parser.
Definition lexcode.l:1187
void parseCode(OutputCodeList &codeOutIntf, const QCString &scopeName, const QCString &input, SrcLangExt, bool stripCodeComments, const CodeParserOptions &options) override
Parses a source file or fragment with the goal to produce highlighted and cross-referenced output.
Definition lexcode.l:1194
~LexCodeParser() override
Definition lexcode.l:1182
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:163
QCString & sprintf(const char *format,...)
Definition qcstring.cpp:29
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition qcstring.h:172
std::unique_ptr< FileDef > createFileDef(const QCString &p, const QCString &n, const QCString &ref, const QCString &dn)
Definition filedef.cpp:268
const char * qPrint(const char *s)
Definition qcstring.h:687
Options to configure the code parser.
Definition parserintf.h:78
CodeParserOptions & setSearchCtx(const Definition *d)
Definition parserintf.h:116
bool isExample() const
Definition parserintf.h:81
CodeParserOptions & setStartLine(int lineNr)
Definition parserintf.h:101
const Definition * searchCtx() const
Definition parserintf.h:89
const FileDef * fileDef() const
Definition parserintf.h:83
int endLine() const
Definition parserintf.h:85
CodeParserOptions & setInlineFragment(bool enable)
Definition parserintf.h:107
const MemberDef * memberDef() const
Definition parserintf.h:87
CodeParserOptions & setCollectXRefs(bool enable)
Definition parserintf.h:119
bool showLineNumbers() const
Definition parserintf.h:88
bool inlineFragment() const
Definition parserintf.h:86
QCString exampleName() const
Definition parserintf.h:82
int startLine() const
Definition parserintf.h:84
CodeParserOptions & setMemberDef(const MemberDef *md)
Definition parserintf.h:110
bool collectXRefs() const
Definition parserintf.h:90
CodeParserOptions & setShowLineNumbers(bool enable)
Definition parserintf.h:113
CodeParserOptions & setFileDef(const FileDef *fd)
Definition parserintf.h:98
lexcodeYY_state state
Definition lexcode.l:1170
SrcLangExt
Definition types.h:207