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 "util.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 code.l:3992

Definition at line 111 of file lexcode.l.

◆ YY_NEVER_INTERACTIVE

#define YY_NEVER_INTERACTIVE   1

Definition at line 46 of file lexcode.l.

◆ YY_NO_INPUT

#define YY_NO_INPUT   1

Definition at line 47 of file lexcode.l.

◆ YY_NO_UNISTD_H

#define YY_NO_UNISTD_H   1

Definition at line 48 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()

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

Definition at line 1053 of file lexcode.l.

1054{
1055 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1056 if (text.isEmpty()) return;
1057 const char *p=text.data(),*sp=p;
1058 bool done=false;
1059 while (!done)
1060 {
1061 sp=p;
1062 char c = 0;
1063 while ((c=*p++) && c!='\n') { }
1064 if (c=='\n')
1065 {
1066 yyextra->yyLineNr++;
1067 size_t l = static_cast<size_t>(p-sp-1);
1068 std::string tmp(sp,l);
1069 yyextra->code->codify(tmp.c_str());
1070 nextCodeLine(yyscanner);
1071 }
1072 else
1073 {
1074 yyextra->code->codify(sp);
1075 done=true;
1076 }
1077 }
1078 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:1038
1079}

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

◆ countLines()

int countLines ( yyscan_t yyscanner)
static

counts the number of lines in the input

Definition at line 1094 of file lexcode.l.

1095{
1096 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1097 const char *p=yyextra->inputString;
1098 char c = 0;
1099 int count=1;
1100 while ((c=*p))
1101 {
1102 p++ ;
1103 if (c=='\n') count++;
1104 }
1105 if (p>yyextra->inputString && *(p-1)!='\n')
1106 { // last line does not end with a \n, so we add an extra
1107 count++;
1108 }
1109 return count;
1110}

◆ endCodeLine()

void endCodeLine ( yyscan_t yyscanner)
static

Definition at line 1030 of file lexcode.l.

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

References endFontClass().

◆ endFontClass()

void endFontClass ( yyscan_t yyscanner)
static

Definition at line 1020 of file lexcode.l.

1021{
1022 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1023 if (yyextra->currentFontClass)
1024 {
1025 yyextra->code->endFontClass();
1026 yyextra->currentFontClass=0;
1027 }
1028}

◆ getLexerFILE()

const char * getLexerFILE ( )
inlinestatic

Definition at line 114 of file lexcode.l.

114{return __FILE__;}

◆ handleCCode()

void handleCCode ( yyscan_t yyscanner)
static

Definition at line 1139 of file lexcode.l.

1140{
1141 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1142 if (yyextra->CCodeBuffer.isEmpty()) return;
1143
1144 yyextra->ccodeParser.setInsideCodeLine(yyextra->insideCodeLine);
1145 yyextra->ccodeParser.parseCode(*yyextra->code,
1146 yyextra->classScope,
1147 yyextra->CCodeBuffer,
1148 SrcLangExt::Cpp,
1149 yyextra->stripCodeComments,
1150 yyextra->exampleBlock,
1151 yyextra->exampleName,
1152 yyextra->sourceFileDef,
1153 yyextra->startCCodeLine,
1154 -1, /* endLine will be calculated in called routine */
1155 yyextra->includeCodeFragment,
1156 yyextra->currentMemberDef,
1157 yyextra->lineNumbers,
1158 yyextra->searchCtx,
1159 yyextra->collectXRefs
1160 );
1161 yyextra->CCodeBuffer.clear();
1162 yyextra->insideCodeLine = yyextra->ccodeParser.insideCodeLine();
1163 yyextra->yyLineNr--;
1164 codifyLines(yyscanner,"\n");
static void codifyLines(yyscan_t yyscanner, const QCString &text)
Definition lexcode.l:1053
1165}

References codifyLines().

◆ lineCount()

void lineCount ( yyscan_t yyscanner)
static

Definition at line 1127 of file lexcode.l.

1128{
1129 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1130 for (const char *p = yytext ; *p ; ++p )
1131 {
1132 if (*p=='\n')
1133 {
1134 yyextra->yyLineNr++;
1135 }
1136 }
1137}

◆ nextCodeLine()

void nextCodeLine ( yyscan_t yyscanner)
static

Definition at line 1038 of file lexcode.l.

1039{
1040 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1041 const char *fc = yyextra->currentFontClass;
1042 if (yyextra->insideCodeLine)
1043 {
1044 endCodeLine(yyscanner);
1045 }
1046 if (yyextra->yyLineNr<yyextra->inputLines)
1047 {
1048 yyextra->currentFontClass = fc;
1049 startCodeLine(yyscanner);
1050 }
static void endCodeLine(yyscan_t yyscanner)
Definition lexcode.l:1030
static void startCodeLine(yyscan_t yyscanner)
Definition lexcode.l:972
1051}

References endCodeLine(), and startCodeLine().

◆ setCurrentDoc()

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

Definition at line 952 of file lexcode.l.

953{
954 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
955 if (Doxygen::searchIndex.enabled())
956 {
957 if (yyextra->searchCtx)
958 {
959 Doxygen::searchIndex.setCurrentDoc(yyextra->searchCtx,yyextra->searchCtx->anchor(),false);
960 }
961 else
962 {
963 Doxygen::searchIndex.setCurrentDoc(yyextra->sourceFileDef,anchor,true);
964 }
965 }
static SearchIndexIntf searchIndex
Definition doxygen.h:124
966}

References Doxygen::searchIndex.

◆ startCodeLine()

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 972 of file lexcode.l.

973{
974 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
975 if (yyextra->sourceFileDef && yyextra->lineNumbers)
976 {
977 const Definition *d = yyextra->sourceFileDef->getSourceDefinition(yyextra->yyLineNr);
The common base class of all entity definitions found in the sources.
Definition definition.h:76
978
979 if (!yyextra->includeCodeFragment && d)
980 {
981 yyextra->currentDefinition = d;
982 yyextra->currentMemberDef = yyextra->sourceFileDef->getSourceMember(yyextra->yyLineNr);
983 yyextra->classScope = d->name();
984 QCString lineAnchor;
985 lineAnchor.sprintf("l%05d",yyextra->yyLineNr);
986 if (yyextra->currentMemberDef)
987 {
988 yyextra->code->writeLineNumber(yyextra->currentMemberDef->getReference(),
989 yyextra->currentMemberDef->getOutputFileBase(),
990 yyextra->currentMemberDef->anchor(),yyextra->yyLineNr,
991 !yyextra->includeCodeFragment);
992 setCurrentDoc(yyscanner,lineAnchor);
993 }
994 else
995 {
996 yyextra->code->writeLineNumber(d->getReference(),
998 QCString(),yyextra->yyLineNr,
999 !yyextra->includeCodeFragment);
1000 setCurrentDoc(yyscanner,lineAnchor);
1001 }
1002 }
1003 else
1004 {
1005 yyextra->code->writeLineNumber(QCString(),QCString(),QCString(),yyextra->yyLineNr,
1006 !yyextra->includeCodeFragment);
1007 }
1008 }
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:952
1009
1010 yyextra->code->startCodeLine(yyextra->yyLineNr);
1011 yyextra->insideCodeLine = true;
1012
1013
1014 if (yyextra->currentFontClass)
1015 {
1016 yyextra->code->startFontClass(yyextra->currentFontClass);
1017 }
1018}

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

◆ startFontClass()

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

Definition at line 1081 of file lexcode.l.

1082{
1083 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1084 endFontClass(yyscanner);
1085 if (!yyextra->currentFontClass || !s || strcmp(yyextra->currentFontClass,s))
1086 {
1087 endFontClass(yyscanner);
1088 yyextra->code->startFontClass(s);
1089 yyextra->currentFontClass=s;
1090 }
QCString s
Definition htmlgen.cpp:154
1091}

References endFontClass(), and s.

◆ stateToString()

const char * stateToString ( int state)
static

References s.

◆ yylex()

int yylex ( yyscan_t yyscanner)

Definition at line 196 of file lexcode.l.

199 {TopStart} {
200 handleCCode(yyscanner);
201 codifyLines(yyscanner,yytext);
202 yyextra->lastContext = YY_START;
203 yyextra->startCCodeLine=yyextra->yyLineNr;
204 BEGIN (TopSection);
205 }
static void handleCCode(yyscan_t yyscanner)
Definition lexcode.l:1139
206<DefSection>^{LiteralStart} {
207 handleCCode(yyscanner);
208 codifyLines(yyscanner,yytext);
209 yyextra->lastContext = YY_START;
210 yyextra->startCCodeLine=yyextra->yyLineNr;
211 BEGIN (LiteralSection);
212 }
213<TopSection>^{TopEnd} {
214 handleCCode(yyscanner);
215 codifyLines(yyscanner,yytext);
216 BEGIN( yyextra->lastContext ) ;
217 }
218<TopSection>.*{nl} {
219 yyextra->CCodeBuffer += yytext;
220 yyextra->yyLineNr++;
221 }
222<LiteralSection>^{LiteralEnd} {
223 handleCCode(yyscanner);
224 codifyLines(yyscanner,yytext);
225 BEGIN( yyextra->lastContext ) ;
226 }
227<LiteralSection>.*{nl} {
228 yyextra->CCodeBuffer += yytext;
229 yyextra->yyLineNr++;
230 }
231<DefSection>{CPPC}.*{nl} {
232 yyextra->CCodeBuffer += yytext;
233 yyextra->yyLineNr++;
234 }
235<DefSection>^{ws}*{CCS} {
236 yyextra->CCodeBuffer += yytext;
237 yyextra->lastContext = YY_START;
238 BEGIN(COMMENT);
239 }
240<COMMENT>{CCE}{ws}*{nl} {
241 yyextra->CCodeBuffer+=yytext;
242 yyextra->yyLineNr++;
243 handleCCode(yyscanner);
244 BEGIN(yyextra->lastContext);
245 }
246<COMMENT>{CCE} {
247 yyextra->CCodeBuffer+=yytext;
248 handleCCode(yyscanner);
249 BEGIN(yyextra->lastContext);
250 }
251<COMMENT>[^*\n]+ {
252 yyextra->CCodeBuffer += yytext;
253 }
254<COMMENT>{CPPC}|{CCS} {
255 yyextra->CCodeBuffer += yytext;
256 }
257<COMMENT>{nl} {
258 yyextra->CCodeBuffer += yytext;
259 yyextra->yyLineNr++;
260 }
261<COMMENT>. {
262 yyextra->CCodeBuffer += yytext;
263 }
264<DefSection>^{nl} {
265 handleCCode(yyscanner);
266 codifyLines(yyscanner,yytext);
267 yyextra->startCCodeLine=yyextra->yyLineNr;
268 }
269<DefSection>^{ws}.*{nl} {
270 yyextra->CCodeBuffer += yytext;
271 yyextra->yyLineNr++;
272 }
273<DefSection>^{RulesStart} {
274 handleCCode(yyscanner);
275 codifyLines(yyscanner,yytext);
276 yyextra->startCCodeLine=yyextra->yyLineNr;
277 BEGIN (RulesSectionInit);
278 }
279<DefSection>^{nws} {
280 handleCCode(yyscanner);
281 codifyLines(yyscanner,yytext);
282 BEGIN(DefSectionLine);
283 }
284<DefSectionLine>.*{nl} {
285 codifyLines(yyscanner,yytext);
286 yyextra->startCCodeLine=yyextra->yyLineNr;
287 BEGIN(DefSection);
288 }
289<RulesSectionInit,RulesPattern>^{RulesEnd} {
290 handleCCode(yyscanner);
291 codifyLines(yyscanner,yytext);
292 yyextra->startCCodeLine=yyextra->yyLineNr;
293 BEGIN (UserSection);
294 }
295<RulesSectionInit>^{nws} {
296 handleCCode(yyscanner);
297 unput(*yytext);
298 BEGIN(RulesPattern);
299 }
300<RulesSectionInit>{nl} {
301 yyextra->CCodeBuffer += yytext;
302 yyextra->yyLineNr++;
303 }
304<RulesSectionInit>^{ws}.*{nl} {
305 yyextra->CCodeBuffer += yytext;
306 yyextra->yyLineNr++;
307 }
308<RulesPattern>"<<EOF>>" {
309 yyextra->rulesPatternBuffer += yytext;
310 }
311<RulesPattern>{EscapeRulesChar} {
312 yyextra->rulesPatternBuffer += yytext;
313 }
314<RulesPattern>{RulesSharp} {
315 yyextra->rulesPatternBuffer += yytext;
316 }
317<RulesPattern>{RulesCurly} {
318 yyextra->rulesPatternBuffer += yytext;
319 }
320<RulesPattern>{StartDouble} {
321 yyextra->rulesPatternBuffer += yytext;
322 yyextra->lastContext = YY_START;
323 BEGIN(RulesDouble);
324 }
325<RulesDouble,RulesRoundDouble>"\\\\" {
326 yyextra->rulesPatternBuffer += yytext;
327 }
328<RulesDouble,RulesRoundDouble>"\\\"" {
329 yyextra->rulesPatternBuffer += yytext;
330 }
331<RulesDouble>"\"" {
332 yyextra->rulesPatternBuffer += yytext;
333 BEGIN( yyextra->lastContext ) ;
334 }
335<RulesRoundDouble>"\"" {
336 yyextra->rulesPatternBuffer += yytext;
337 BEGIN(RulesRound) ;
338 }
339<RulesDouble,RulesRoundDouble>. {
340 yyextra->rulesPatternBuffer += yytext;
341 }
342<RulesPattern>{StartSquare} {
343 yyextra->rulesPatternBuffer += yytext;
344 yyextra->lastContext = YY_START;
345 BEGIN(RulesSquare);
346 }
347<RulesSquare,RulesRoundSquare>{CHARCE} {
348 yyextra->rulesPatternBuffer += yytext;
349 }
350<RulesSquare,RulesRoundSquare>"\\[" |
351<RulesSquare,RulesRoundSquare>"\\]" {
352 yyextra->rulesPatternBuffer += yytext;
353 }
354<RulesSquare>"]" {
355 yyextra->rulesPatternBuffer += yytext;
356 BEGIN(RulesPattern) ;
357 }
358<RulesRoundSquare>"]" {
359 yyextra->rulesPatternBuffer += yytext;
360 BEGIN(RulesRound) ;
361 }
362<RulesSquare,RulesRoundSquare>"\\\\" {
363 yyextra->rulesPatternBuffer += yytext;
364 }
365<RulesSquare,RulesRoundSquare>. {
366 yyextra->rulesPatternBuffer += yytext;
367 }
368<RulesPattern>{StartRoundQuest} {
369 yyextra->rulesPatternBuffer += yytext;
370 yyextra->lastContext = YY_START;
371 BEGIN(RulesRoundQuest);
372 }
373<RulesRoundQuest>{nl} {
374 yyextra->rulesPatternBuffer += yytext;
375 if (!yyextra->rulesPatternBuffer.isEmpty())
376 {
377 startFontClass(yyscanner,"stringliteral");
378 codifyLines(yyscanner,yyextra->rulesPatternBuffer.data());
379 yyextra->rulesPatternBuffer.clear();
380 endFontClass(yyscanner);
381 }
382 }
static void startFontClass(yyscan_t yyscanner, const char *s)
Definition lexcode.l:1081
383<RulesRoundQuest>[^)] {
384 yyextra->rulesPatternBuffer += yytext;
385 }
386<RulesRoundQuest>")" {
387 yyextra->rulesPatternBuffer += yytext;
388 BEGIN(yyextra->lastContext);
389 }
390<RulesPattern>{StartRound} {
391 yyextra->roundCount++;
392 yyextra->rulesPatternBuffer += yytext;
393 yyextra->lastContext = YY_START;
394 BEGIN(RulesRound);
395 }
396<RulesRound>{RulesCurly} {
397 yyextra->rulesPatternBuffer += yytext;
398 }
399<RulesRound>{StartSquare} {
400 yyextra->rulesPatternBuffer += yytext;
401 BEGIN(RulesRoundSquare);
402 }
403<RulesRound>{StartDouble} {
404 yyextra->rulesPatternBuffer += yytext;
405 BEGIN(RulesRoundDouble);
406 }
407<RulesRound>{EscapeRulesChar} {
408 yyextra->rulesPatternBuffer += yytext;
409 }
410<RulesRound>"(" {
411 yyextra->roundCount++;
412 yyextra->rulesPatternBuffer += yytext;
413 }
414<RulesRound>")" {
415 yyextra->roundCount--;
416 yyextra->rulesPatternBuffer += yytext;
417 if (!yyextra->roundCount) BEGIN( yyextra->lastContext ) ;
418 }
419<RulesRound>{nl} {
420 yyextra->rulesPatternBuffer += yytext;
421 yyextra->yyLineNr++;
422 }
423<RulesRound>{ws} {
424 yyextra->rulesPatternBuffer += yytext;
425 }
426<RulesRound>. {
427 yyextra->rulesPatternBuffer += yytext;
428 }
429<RulesPattern>{ws}+"|" {
430 if (!yyextra->rulesPatternBuffer.isEmpty())
431 {
432 startFontClass(yyscanner,"stringliteral");
433 codifyLines(yyscanner,yyextra->rulesPatternBuffer);
434 yyextra->rulesPatternBuffer.clear();
435 endFontClass(yyscanner);
436 }
437 codifyLines(yyscanner,yytext);
438 yyextra->startCCodeLine=yyextra->yyLineNr;
439 yyextra->curlyCount = 0;
440 BEGIN(SkipCurly);
441 }
442<RulesPattern>^{ws}*{nl} {
443 codifyLines(yyscanner,"\n");
444 }
445<RulesPattern>^{ws}+ {
446 codifyLines(yyscanner,yytext);
447 }
448<RulesPattern>({ws}|{nl}) {
449 unput(*yytext);
450 if (!yyextra->rulesPatternBuffer.isEmpty())
451 {
452 startFontClass(yyscanner,"stringliteral");
453 codifyLines(yyscanner,yyextra->rulesPatternBuffer);
454 yyextra->rulesPatternBuffer.clear();
455 endFontClass(yyscanner);
456 }
457 yyextra->startCCodeLine=yyextra->yyLineNr;
458 yyextra->curlyCount = 0;
459 BEGIN(SkipCurly);
460 }
461<RulesPattern>"\\\\" {
462 yyextra->rulesPatternBuffer += yytext;
463 }
464<RulesPattern>{CCS} {
465 if (!yyextra->rulesPatternBuffer.isEmpty())
466 {
467 startFontClass(yyscanner,"stringliteral");
468 codifyLines(yyscanner,yyextra->rulesPatternBuffer);
469 yyextra->rulesPatternBuffer.clear();
470 endFontClass(yyscanner);
471 }
472 yyextra->CCodeBuffer += yytext;
473 yyextra->lastContext = YY_START;
474 BEGIN(COMMENT);
475 }
476<RulesPattern>. {
477 yyextra->rulesPatternBuffer += yytext;
478 }
479<SkipCurly>{B}*"#"{B}+[0-9]+{B}+/"\"" { /* line control directive */
480 yyextra->CCodeBuffer += yytext;
481 yyextra->lastPreLineCtrlContext = YY_START;
482 BEGIN( PreLineCtrl );
483 }
484<PreLineCtrl>"\""[^\n\"]*"\"" {
485 yyextra->CCodeBuffer += yytext;
486 }
487<PreLineCtrl>. {
488 yyextra->CCodeBuffer += yytext;
489 }
490<PreLineCtrl>\n {
491 yyextra->CCodeBuffer += yytext;
492 yyextra->yyLineNr++;
493 BEGIN( yyextra->lastPreLineCtrlContext );
494 }
495<SkipCurly>"{" {
496 yyextra->CCodeBuffer += yytext;
497 ++yyextra->curlyCount ;
498 }
499<SkipCurly>"}"/{BN}*{DCOMM}"<!--" | /* see bug710917 */
500<SkipCurly>"}" {
501 yyextra->CCodeBuffer += yytext;
502 lineCount(yyscanner);
503 if( yyextra->curlyCount )
504 {
505 --yyextra->curlyCount ;
506 }
507 }
#define lineCount(s, len)
508<SkipCurly>"}"{BN}*{DCOMM}"<" {
509 yyextra->CCodeBuffer += yytext;
510 lineCount(yyscanner);
511 if ( yyextra->curlyCount )
512 {
513 --yyextra->curlyCount ;
514 }
515 else
516 {
517 yyextra->docBlockContext = SkipCurlyEndDoc;
518 if (yytext[yyleng-3]=='/')
519 {
520 BEGIN( DocLine );
521 }
522 else
523 {
524 BEGIN( DocBlock );
525 }
526 }
527 }
528<SkipCurly>\" {
529 yyextra->CCodeBuffer += yytext;
530 yyextra->lastStringContext=SkipCurly;
531 BEGIN( SkipString );
532 }
533<SkipCurly>^{B}*"#" {
534 yyextra->CCodeBuffer += yytext;
535 yyextra->lastPreLineCtrlContext = YY_START;
536 BEGIN( PreLineCtrl );
537 }
538<SkipCurly>{B}*{RAWBEGIN} {
539 char *p = yytext;
540 while (*p && qisspace(*p)) p++;
541 yyextra->delimiter = extractBeginRawStringDelimiter(p);
542 yyextra->lastRawStringContext = YY_START;
543 yyextra->CCodeBuffer += yytext;
544 BEGIN(RawString);
545 }
bool qisspace(char c)
Definition qcstring.h:81
QCString extractBeginRawStringDelimiter(const char *rawStart)
Definition util.cpp:7451
546<SkipCurly>[^\n#"'@\\/{}<]+ {
547 yyextra->CCodeBuffer += yytext;
548 }
549<SkipCurly>{CCS} {
550 yyextra->CCodeBuffer += yytext;
551 yyextra->lastCContext = YY_START;
552 BEGIN(SkipComment);
553 }
554<SkipCurly>{CPPC} {
555 yyextra->CCodeBuffer += yytext;
556 yyextra->lastCContext = YY_START;
557 BEGIN(SkipCxxComment);
558 }
559<SkipCurly>{CHARLIT} {
560 yyextra->CCodeBuffer += yytext;
561 }
562<SkipCurly>\' {
563 yyextra->CCodeBuffer += yytext;
564 }
565<SkipCurly>. {
566 yyextra->CCodeBuffer += yytext;
567 }
568<SkipCurly>({CPPC}{B}*)?{CCS}"!" {
569 yyextra->CCodeBuffer += yytext;
570 yyextra->docBlockContext = YY_START;
571 BEGIN( DocBlock );
572 }
573<SkipCurly>{CCS}"*"[*]+{BL} {
574 bool javadocBanner = Config_getBool(JAVADOC_BANNER);
575 yyextra->CCodeBuffer += yytext;
576 yyextra->yyLineNr++;
577 if( javadocBanner )
578 {
579 yyextra->docBlockContext = YY_START;
580 BEGIN( DocBlock );
581 }
582 else
583 {
584 BEGIN( Comment ) ;
585 }
586 }
#define Config_getBool(name)
Definition config.h:33
587<SkipCurly>({CPPC}{B}*)?{CCS}"*"/{NCOMM} {
588 yyextra->CCodeBuffer += yytext;
589 yyextra->docBlockContext = YY_START;
590 BEGIN( DocBlock );
591 }
592<SkipCurly>{CPPC}"!" {
593 yyextra->CCodeBuffer += yytext;
594 yyextra->docBlockContext = YY_START;
595 BEGIN( DocLine );
596 }
597<SkipCurly>{CPPC}"/"/[^/] {
598 yyextra->CCodeBuffer += yytext;
599 yyextra->docBlockContext = YY_START;
600 BEGIN( DocLine );
601 }
602
603<SkipCurly>\n {
604 yyextra->CCodeBuffer += yytext;
605 yyextra->yyLineNr++;
606 if (yyextra->curlyCount<=0)
607 {
608 handleCCode(yyscanner);
609 BEGIN(RulesPattern);
610 }
611 }
612<SkipString>\\. {
613 yyextra->CCodeBuffer += yytext;
614 }
615<SkipString>\" {
616 yyextra->CCodeBuffer += yytext;
617 BEGIN( yyextra->lastStringContext );
618 }
619<SkipString>{CCS}|{CCE}|{CPPC} {
620 yyextra->CCodeBuffer += yytext;
621 }
622<SkipString>\n {
623 yyextra->CCodeBuffer += yytext;
624 yyextra->yyLineNr++;
625 }
626<SkipString>. {
627 yyextra->CCodeBuffer += yytext;
628 }
629<SkipCxxComment>.*"\\\n" { // line continuation
630 yyextra->CCodeBuffer += yytext;
631 yyextra->yyLineNr++;
632 }
633<SkipCxxComment>{ANYopt}/\n {
634 yyextra->CCodeBuffer += yytext;
635 BEGIN( yyextra->lastCContext ) ;
636 }
637<Comment>{BN}+ {
638 yyextra->CCodeBuffer += yytext ;
639 lineCount(yyscanner);
640 }
641<Comment>{CCS} { yyextra->CCodeBuffer += yytext ; }
642<Comment>{CPPC} { yyextra->CCodeBuffer += yytext ; }
643<Comment>{CMD}("code"|"verbatim"|"iliteral") {
644 yyextra->insideCode=TRUE;
645 yyextra->CCodeBuffer += yytext ;
646 }
#define TRUE
Definition qcstring.h:37
647<Comment>{CMD}("endcode"|"endverbatim"|"endiliteral") {
648 yyextra->insideCode=FALSE;
649 yyextra->CCodeBuffer += yytext ;
650 }
#define FALSE
Definition qcstring.h:34
651<Comment>[^ \.\t\r\n\/\*]+ { yyextra->CCodeBuffer += yytext ; }
652<Comment>{CCE} {
653 yyextra->CCodeBuffer += yytext ;
654 if (!yyextra->insideCode) BEGIN( yyextra->lastContext ) ;
655 }
656<Comment>. { yyextra->CCodeBuffer += *yytext ; }
657
658<SkipComment>{CPPC}|{CCS} {
659 yyextra->CCodeBuffer += yytext;
660 }
661<SkipComment>[^\*\n]+ {
662 yyextra->CCodeBuffer += yytext;
663 }
664<SkipComment>\n {
665 yyextra->CCodeBuffer += yytext;
666 yyextra->yyLineNr++;
667 }
668<SkipComment>{B}*{CCE} {
669 yyextra->CCodeBuffer += yytext;
670 BEGIN( yyextra->lastCContext );
671 }
672<SkipComment>"*" {
673 yyextra->CCodeBuffer += yytext;
674 }
675<RawString>{RAWEND} {
676 yyextra->CCodeBuffer += yytext;
677 if (extractEndRawStringDelimiter(yytext)==yyextra->delimiter)
678 {
679 BEGIN(yyextra->lastRawStringContext);
680 }
681 }
QCString extractEndRawStringDelimiter(const char *rawEnd)
Definition util.cpp:7459
682<RawString>[^)\n]+ {
683 yyextra->CCodeBuffer += yytext;
684 }
685<RawString>. {
686 yyextra->CCodeBuffer += yytext;
687 }
688<RawString>\n {
689 yyextra->CCodeBuffer += yytext;
690 yyextra->yyLineNr++;
691 }
692
693
694 /* ---- Single line comments ------ */
695<DocLine>[^\n]*"\n"[ \t]*{CPPC}[/!][<]? { // continuation of multiline C++-style comment
696 yyextra->CCodeBuffer += yytext;
697 lineCount(yyscanner);
698 }
699<DocLine>{B}*{CPPC}"/"[/]+{Bopt}/"\n" { // ignore marker line (see bug700345)
700 yyextra->CCodeBuffer += yytext;
701 BEGIN( yyextra->docBlockContext );
702 }
703<DocLine>{NONLopt}/"\n"{B}*{CPPC}[!/]{B}*{CMD}"}" { // next line is an end group marker, see bug 752712
704 yyextra->CCodeBuffer += yytext;
705 BEGIN( yyextra->docBlockContext );
706 }
707<DocLine>{NONLopt}/"\n" { // whole line
708 yyextra->CCodeBuffer += yytext;
709 BEGIN( yyextra->docBlockContext );
710 }
711
712 /* ---- Comments blocks ------ */
713
714<DocBlock>"*"*{CCE} { // end of comment block
715 yyextra->CCodeBuffer += yytext;
716 BEGIN(yyextra->docBlockContext);
717 }
718<DocBlock>^{B}*"*"+/[^/] {
719 yyextra->CCodeBuffer += yytext;
720 }
721<DocBlock>^{B}*({CPPC})?{B}*"*"+/[^/a-z_A-Z0-9*] { // start of a comment line
722 yyextra->CCodeBuffer += yytext;
723 }
724<DocBlock>^{B}*({CPPC}){B}* { // strip embedded C++ comments if at the start of a line
725 yyextra->CCodeBuffer += yytext;
726 }
727<DocBlock>{CPPC} { // slashes in the middle of a comment block
728 yyextra->CCodeBuffer += yytext;
729 }
730<DocBlock>{CCS} { // start of a new comment in the
731 // middle of a comment block
732 yyextra->CCodeBuffer += yytext;
733 }
734<DocBlock>({CMD}{CMD}){ID}/[^a-z_A-Z0-9] { // escaped command
735 yyextra->CCodeBuffer += yytext;
736 }
737<DocBlock>{CMD}("f$"|"f["|"f{"|"f(") {
738 yyextra->CCodeBuffer += yytext;
739 yyextra->docBlockName=&yytext[1];
740 if (yyextra->docBlockName.at(1)=='[')
741 {
742 yyextra->docBlockName.at(1)=']';
743 }
744 if (yyextra->docBlockName.at(1)=='{')
745 {
746 yyextra->docBlockName.at(1)='}';
747 }
748 if (yyextra->docBlockName.at(1)=='(')
749 {
750 yyextra->docBlockName.at(1)=')';
751 }
752 yyextra->fencedSize=0;
753 yyextra->nestedComment=FALSE;
754 BEGIN(DocCopyBlock);
755 }
756<DocBlock>{B}*"<"{PRE}">" {
757 yyextra->CCodeBuffer += yytext;
758 yyextra->docBlockName="<pre>";
759 yyextra->fencedSize=0;
760 yyextra->nestedComment=FALSE;
761 BEGIN(DocCopyBlock);
762 }
763<DocBlock>{CMD}"startuml"/[^a-z_A-Z0-9\-] { // verbatim type command (which could contain nested comments!)
764 yyextra->CCodeBuffer += yytext;
765 yyextra->docBlockName="uml";
766 yyextra->fencedSize=0;
767 yyextra->nestedComment=FALSE;
768 BEGIN(DocCopyBlock);
769 }
770<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!)
771 yyextra->CCodeBuffer += yytext;
772 yyextra->docBlockName=&yytext[1];
773 yyextra->fencedSize=0;
774 yyextra->nestedComment=FALSE;
775 BEGIN(DocCopyBlock);
776 }
777<DocBlock>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
778 yyextra->CCodeBuffer += yytext;
779 QCString pat = substitute(yytext,"*"," ");
780 yyextra->docBlockName="~~~";
781 yyextra->fencedSize=pat.stripWhiteSpace().length();
782 yyextra->nestedComment=FALSE;
783 BEGIN(DocCopyBlock);
784 }
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:153
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
Definition qcstring.h:245
QCString substitute(const QCString &s, const QCString &src, const QCString &dst)
substitute all occurrences of src in s by dst
Definition qcstring.cpp:477
785<DocBlock>^({B}*"*"+)?{B}{0,3}"```"[`]* {
786 yyextra->CCodeBuffer += yytext;
787 QCString pat = substitute(yytext,"*"," ");
788 yyextra->docBlockName="```";
789 yyextra->fencedSize=pat.stripWhiteSpace().length();
790 yyextra->nestedComment=FALSE;
791 BEGIN(DocCopyBlock);
792 }
793<DocBlock>{B}*"<code>" {
794 REJECT;
795 }
796<DocBlock>[^@*~\/\\\n]+ { // any character that isn't special
797 yyextra->CCodeBuffer += yytext;
798 }
799<DocBlock>\n { // newline
800 yyextra->CCodeBuffer += yytext;
801 lineCount(yyscanner);
802 }
803<DocBlock>. { // command block
804 yyextra->CCodeBuffer += yytext;
805 }
806 /* ---- Copy verbatim sections ------ */
807
808<DocCopyBlock>"</"{PRE}">" { // end of a <pre> block
809 yyextra->CCodeBuffer += yytext;
810 if (yyextra->docBlockName=="<pre>")
811 {
812 BEGIN(DocBlock);
813 }
814 }
815<DocCopyBlock>"</"{CODE}">" { // end of a <code> block
816 yyextra->CCodeBuffer += yytext;
817 if (yyextra->docBlockName=="<code>")
818 {
819 BEGIN(DocBlock);
820 }
821 }
822<DocCopyBlock>{CMD}("f$"|"f]"|"f}"|"f)") {
823 yyextra->CCodeBuffer += yytext;
824 if (yyextra->docBlockName==&yytext[1])
825 {
826 BEGIN(DocBlock);
827 }
828 }
829<DocCopyBlock>{CMD}("endverbatim"|"endiliteral"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endmanonly"|"endrtfonly"|"enddot"|"endmsc"|"enduml"|"endcode")/[^a-z_A-Z0-9] { // end of verbatim block
830 yyextra->CCodeBuffer += yytext;
831 if (&yytext[4]==yyextra->docBlockName)
832 {
833 BEGIN(DocBlock);
834 }
835 }
836<DocCopyBlock>^{B}*"*"+/{BN}+ { // start of a comment line
837 yyextra->CCodeBuffer += yytext;
838 if ((yyextra->docBlockName=="verbatim") || (yyextra->docBlockName=="code") || (yyextra->docBlockName=="iliteral"))
839 {
840 REJECT;
841 }
842 else
843 {
844 yyextra->CCodeBuffer += yytext;
845 }
846 }
847<DocCopyBlock>^{B}*"*"+/{B}+"*"{BN}* { // start of a comment line with two *'s
848 if ((yyextra->docBlockName=="code") || (yyextra->docBlockName=="iliteral"))
849 {
850 yyextra->CCodeBuffer += yytext;
851 }
852 else
853 {
854 REJECT;
855 }
856 }
857<DocCopyBlock>^{B}*"*"+/({ID}|"(") { // Assume *var or *(... is part of source code (see bug723516)
858 if ((yyextra->docBlockName=="code") || (yyextra->docBlockName=="iliteral"))
859 {
860 yyextra->CCodeBuffer += yytext;
861 }
862 else
863 {
864 REJECT;
865 }
866 }
867<DocCopyBlock>^{B}*"*"+/{BN}* { // start of a comment line with one *
868 if ((yyextra->docBlockName=="code") || (yyextra->docBlockName=="iliteral"))
869 {
870 if (yyextra->nestedComment) // keep * it is part of the code
871 {
872 yyextra->CCodeBuffer += yytext;
873 }
874 else // remove * it is part of the comment block
875 {
876 yyextra->CCodeBuffer += yytext;
877 }
878 }
879 else
880 {
881 REJECT;
882 }
883 }
884<DocCopyBlock>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
885 yyextra->CCodeBuffer += yytext;
886 QCString pat = substitute(yytext,"*"," ");
887 if (yyextra->fencedSize==pat.stripWhiteSpace().length())
888 {
889 BEGIN(DocBlock);
890 }
891 }
892<DocCopyBlock>^({B}*"*"+)?{B}{0,3}"```"[`]* {
893 yyextra->CCodeBuffer += yytext;
894 QCString pat = substitute(yytext,"*"," ");
895 if (yyextra->fencedSize==pat.stripWhiteSpace().length())
896 {
897 BEGIN(DocBlock);
898 }
899 }
900<DocCopyBlock>[^<@/\*\]~\$\\\n]+ { // any character that is not special
901 yyextra->CCodeBuffer += yytext;
902 }
903<DocCopyBlock>{CCS}|{CCE}|{CPPC} {
904 if (yytext[1]=='*')
905 {
906 yyextra->nestedComment=TRUE;
907 }
908 else if (yytext[0]=='*')
909 {
910 yyextra->nestedComment=FALSE;
911 }
912 yyextra->CCodeBuffer += yytext;
913 }
914<DocCopyBlock>\n { // newline
915 yyextra->CCodeBuffer += yytext;
916 lineCount(yyscanner);
917 }
918<DocCopyBlock>. { // any other character
919 yyextra->CCodeBuffer += yytext;
920 }
921<SkipCurlyEndDoc>"}"{BN}*{DCOMM}"<" { // desc is followed by another one
922 yyextra->docBlockContext = SkipCurlyEndDoc;
923 yyextra->CCodeBuffer += yytext;
924 if (yytext[yyleng-3]=='/')
925 {
926 BEGIN( DocLine );
927 }
928 else
929 {
930 BEGIN( DocBlock );
931 }
932 }
933<SkipCurlyEndDoc>"}" {
934 yyextra->CCodeBuffer += yytext;
935 BEGIN(SkipCurly);
936 }
937
938<UserSection>.*{nl} {
939 yyextra->CCodeBuffer += yytext;
940 yyextra->yyLineNr++;
941 }
942 /*
943<*>. { fprintf(stderr,"Lex code scanner Def rule for %s: #%s#\n",stateToString(YY_START),yytext);}
944<*>{nl} { fprintf(stderr,"Lex code scanner Def rule for newline %s: #%s#\n",stateToString(YY_START),yytext); yyextra->yyLineNr++;}
945 */
946<*><<EOF>> {
947 handleCCode(yyscanner);
948 yyterminate();
949 }
#define yyterminate()
950%%

◆ yyread()

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

Definition at line 1112 of file lexcode.l.

1113{
1114 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1115 int inputPosition = yyextra->inputPosition;
1116 const char *s = yyextra->inputString + inputPosition;
1117 int c=0;
1118 while( c < max_size && *s )
1119 {
1120 *buf++ = *s++;
1121 c++;
1122 }
1123 yyextra->inputPosition += c;
1124 return c;
1125}

References s.