Doxygen
Loading...
Searching...
No Matches
lexcode.l File Reference
#include <stdint.h>
#include <memory>
#include <stdio.h>
#include "config.h"
#include "doxygen.h"
#include "outputgen.h"
#include "outputlist.h"
#include "code.h"
#include "lexcode.h"
#include "filedef.h"
#include "message.h"
#include "debug.h"
#include "searchindex.h"
#include "doxygen_lex.h"
#include "lexcode.l.h"
+ Include dependency graph for lexcode.l:

Go to the source code of this file.

Classes

struct  lexcodeYY_state
 
struct  LexCodeParser::Private
 

Macros

#define YY_TYPEDEF_YY_SCANNER_T
 
#define YY_NEVER_INTERACTIVE   1
 
#define YY_NO_INPUT   1
 
#define YY_NO_UNISTD_H   1
 
#define YY_INPUT(buf, result, max_size)
 

Typedefs

typedef yyguts_t * yyscan_t
 

Functions

static const char * stateToString (int state)
 
static void setCurrentDoc (yyscan_t yyscanner, const QCString &anchor)
 
static void startCodeLine (yyscan_t yyscanner)
 
static void endFontClass (yyscan_t yyscanner)
 
static void endCodeLine (yyscan_t yyscanner)
 
static void nextCodeLine (yyscan_t yyscanner)
 
static void codifyLines (yyscan_t yyscanner, const QCString &text)
 
static void startFontClass (yyscan_t yyscanner, const char *s)
 
static int countLines (yyscan_t yyscanner)
 
static int yyread (yyscan_t yyscanner, char *buf, int max_size)
 
static void lineCount (yyscan_t yyscanner)
 
static void handleCCode (yyscan_t yyscanner)
 
static const char * getLexerFILE ()
 
int yylex (yyscan_t yyscanner)
 

Macro Definition Documentation

◆ YY_INPUT

#define YY_INPUT ( buf,
result,
max_size )
Value:
result=yyread(yyscanner,buf,max_size);
static int yyread(yyscan_t yyscanner, char *buf, int max_size)
Definition lexcode.l:1113

Definition at line 110 of file lexcode.l.

◆ YY_NEVER_INTERACTIVE

#define YY_NEVER_INTERACTIVE   1

Definition at line 45 of file lexcode.l.

◆ YY_NO_INPUT

#define YY_NO_INPUT   1

Definition at line 46 of file lexcode.l.

◆ YY_NO_UNISTD_H

#define YY_NO_UNISTD_H   1

Definition at line 47 of file lexcode.l.

◆ YY_TYPEDEF_YY_SCANNER_T

#define YY_TYPEDEF_YY_SCANNER_T

Definition at line 24 of file lexcode.l.

Typedef Documentation

◆ yyscan_t

typedef yyguts_t* yyscan_t

Definition at line 26 of file lexcode.l.

Function Documentation

◆ codifyLines()

static void codifyLines ( yyscan_t yyscanner,
const QCString & text )
static

Definition at line 1054 of file lexcode.l.

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;
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
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 nextCodeLine(yyscan_t yyscanner)
Definition lexcode.l:1039
1080}

References QCString::data(), QCString::isEmpty(), and nextCodeLine().

◆ countLines()

static int countLines ( yyscan_t yyscanner)
static

counts the number of lines in the input

Definition at line 1095 of file lexcode.l.

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}

◆ endCodeLine()

static void endCodeLine ( yyscan_t yyscanner)
static

Definition at line 1031 of file lexcode.l.

1032{
1033 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1034 endFontClass(yyscanner);
1035 yyextra->code->endCodeLine();
1036 yyextra->insideCodeLine = false;
static void endFontClass(yyscan_t yyscanner)
Definition lexcode.l:1021
1037}

References endFontClass().

◆ endFontClass()

static void endFontClass ( yyscan_t yyscanner)
static

Definition at line 1021 of file lexcode.l.

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}

◆ getLexerFILE()

static const char * getLexerFILE ( )
inlinestatic

Definition at line 113 of file lexcode.l.

113{return __FILE__;}

◆ handleCCode()

static void handleCCode ( yyscan_t yyscanner)
static

Definition at line 1140 of file lexcode.l.

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");
static void codifyLines(yyscan_t yyscanner, const QCString &text)
Definition lexcode.l:1054
1166}

References codifyLines(), and Cpp.

◆ lineCount()

static void lineCount ( yyscan_t yyscanner)
static

Definition at line 1128 of file lexcode.l.

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}

◆ nextCodeLine()

static void nextCodeLine ( yyscan_t yyscanner)
static

Definition at line 1039 of file lexcode.l.

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 }
static void endCodeLine(yyscan_t yyscanner)
Definition lexcode.l:1031
static void startCodeLine(yyscan_t yyscanner)
Definition lexcode.l:973
1052}

References endCodeLine(), and startCodeLine().

◆ setCurrentDoc()

static void setCurrentDoc ( yyscan_t yyscanner,
const QCString & anchor )
static

Definition at line 953 of file lexcode.l.

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 }
static SearchIndexIntf searchIndex
Definition doxygen.h:124
967}

References Doxygen::searchIndex.

◆ startCodeLine()

static void startCodeLine ( yyscan_t yyscanner)
static

start a new line of code, inserting a line number if yyextra->sourceFileDef is true. If a definition starts at the current line, then the line number is linked to the documentation of that definition.

Definition at line 973 of file lexcode.l.

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);
The common base class of all entity definitions found in the sources.
Definition definition.h:76
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 }
virtual QCString getReference() const =0
virtual QCString getOutputFileBase() const =0
virtual const QCString & name() const =0
This is an alternative implementation of QCString.
Definition qcstring.h:101
QCString & sprintf(const char *format,...)
Definition qcstring.cpp:29
static void setCurrentDoc(yyscan_t yyscanner, const QCString &anchor)
Definition lexcode.l:953
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}

References Definition::getOutputFileBase(), Definition::getReference(), Definition::name(), setCurrentDoc(), and QCString::sprintf().

◆ startFontClass()

static void startFontClass ( yyscan_t yyscanner,
const char * s )
static

Definition at line 1082 of file lexcode.l.

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}

References endFontClass().

◆ stateToString()

static const char * stateToString ( int state)
static

◆ yylex()

int yylex ( yyscan_t yyscanner)

Definition at line 195 of file lexcode.l.

198 {TopStart} {
199 handleCCode(yyscanner);
200 codifyLines(yyscanner,yytext);
201 yyextra->lastContext = YY_START;
202 yyextra->startCCodeLine=yyextra->yyLineNr;
203 BEGIN (TopSection);
204 }
static void handleCCode(yyscan_t yyscanner)
Definition lexcode.l:1140
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)
Definition lexcode.l:1082
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 }
#define lineCount(s, len)
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 }
#define FALSE
Definition qcstring.h:34
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%%

◆ yyread()

static int yyread ( yyscan_t yyscanner,
char * buf,
int max_size )
static

Definition at line 1113 of file lexcode.l.

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}