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