Doxygen
Loading...
Searching...
No Matches
lexcode.l File Reference
#include <stdint.h>
#include "lexcode.h"
#include <memory>
#include "code.h"
#include "config.h"
#include "debug.h"
#include "doxygen.h"
#include "filedef.h"
#include "message.h"
#include "outputlist.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 yyguts_t   lexcodeYYguts_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 DString &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 DString &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 113 of file lexcode.l.

◆ YY_NEVER_INTERACTIVE

#define YY_NEVER_INTERACTIVE   1

Definition at line 48 of file lexcode.l.

◆ YY_NO_INPUT

#define YY_NO_INPUT   1

Definition at line 49 of file lexcode.l.

◆ YY_NO_UNISTD_H

#define YY_NO_UNISTD_H   1

Definition at line 50 of file lexcode.l.

◆ YY_TYPEDEF_YY_SCANNER_T

#define YY_TYPEDEF_YY_SCANNER_T

Definition at line 24 of file lexcode.l.

◆ yyguts_t

#define yyguts_t   lexcodeYYguts_t

Definition at line 25 of file lexcode.l.

Typedef Documentation

◆ yyscan_t

typedef yyguts_t* yyscan_t

Definition at line 27 of file lexcode.l.

Function Documentation

◆ codifyLines()

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

Definition at line 1055 of file lexcode.l.

1056{
1057 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1058 if (text.empty()) return;
1059 const char *p=text.data(),*sp=p;
1060 bool done=false;
1061 while (!done)
1062 {
1063 sp=p;
1064 char c = 0;
1065 while ((c=*p++) && c!='\n') { }
1066 if (c=='\n')
1067 {
1068 yyextra->yyLineNr++;
1069 size_t l = static_cast<size_t>(p-sp-1);
1070 yyextra->code->codify(DString(sp,l));
1071 nextCodeLine(yyscanner);
1072 }
1073 else
1074 {
1075 yyextra->code->codify(sp);
1076 done=true;
1077 }
1078 }
1079 yyextra->startCCodeLine = yyextra->yyLineNr;
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:84
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:148
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition dstring.h:157
#define yyguts_t
Definition code.l:23
static void nextCodeLine(yyscan_t yyscanner)
Definition lexcode.l:1040
1080}

References DString::data(), DString::empty(), nextCodeLine(), and yyguts_t.

Referenced by handleCCode().

◆ countLines()

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}

References yyguts_t.

Referenced by LexCodeParser::parseCode().

◆ endCodeLine()

void endCodeLine ( yyscan_t yyscanner)
static

Definition at line 1032 of file lexcode.l.

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

References endFontClass(), and yyguts_t.

Referenced by nextCodeLine(), and LexCodeParser::parseCode().

◆ endFontClass()

void endFontClass ( yyscan_t yyscanner)
static

Definition at line 1022 of file lexcode.l.

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

References yyguts_t.

Referenced by endCodeLine(), and startFontClass().

◆ getLexerFILE()

const char * getLexerFILE ( )
inlinestatic

Definition at line 116 of file lexcode.l.

116{return __FILE__;}

◆ handleCCode()

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.empty()) return;
1144
1145 yyextra->ccodeParser.setInsideCodeLine(yyextra->insideCodeLine);
1146 yyextra->ccodeParser.parseCode(*yyextra->code,
1147 yyextra->classScope,
1148 yyextra->CCodeBuffer,
1149 SrcLangExt::Cpp,
1150 yyextra->stripCodeComments,
1152 .setExample(yyextra->exampleBlock,yyextra->exampleName)
1153 .setFileDef(yyextra->sourceFileDef)
1154 .setStartLine(yyextra->startCCodeLine)
1155 .setInlineFragment(yyextra->includeCodeFragment)
1156 .setMemberDef(yyextra->currentMemberDef)
1157 .setShowLineNumbers(yyextra->lineNumbers)
1158 .setSearchCtx(yyextra->searchCtx)
1159 .setCollectXRefs(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 DString &text)
Definition lexcode.l:1055
Options to configure the code parser.
Definition parserintf.h:77
CodeParserOptions & setSearchCtx(const Definition *d)
Definition parserintf.h:115
CodeParserOptions & setStartLine(int lineNr)
Definition parserintf.h:100
CodeParserOptions & setInlineFragment(bool enable)
Definition parserintf.h:106
CodeParserOptions & setCollectXRefs(bool enable)
Definition parserintf.h:118
CodeParserOptions & setMemberDef(const MemberDef *md)
Definition parserintf.h:109
CodeParserOptions & setShowLineNumbers(bool enable)
Definition parserintf.h:112
CodeParserOptions & setFileDef(const FileDef *fd)
Definition parserintf.h:97
1165}

References codifyLines(), CodeParserOptions::setCollectXRefs(), CodeParserOptions::setFileDef(), CodeParserOptions::setInlineFragment(), CodeParserOptions::setMemberDef(), CodeParserOptions::setSearchCtx(), CodeParserOptions::setShowLineNumbers(), CodeParserOptions::setStartLine(), and yyguts_t.

◆ lineCount()

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}

References yyguts_t.

◆ nextCodeLine()

void nextCodeLine ( yyscan_t yyscanner)
static

Definition at line 1040 of file lexcode.l.

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

References endCodeLine(), startCodeLine(), and yyguts_t.

Referenced by codifyLines().

◆ setCurrentDoc()

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

Definition at line 954 of file lexcode.l.

955{
956 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
957 if (Doxygen::searchIndex.enabled())
958 {
959 if (yyextra->searchCtx)
960 {
961 Doxygen::searchIndex.setCurrentDoc(yyextra->searchCtx,yyextra->searchCtx->anchor(),false);
962 }
963 else
964 {
965 Doxygen::searchIndex.setCurrentDoc(yyextra->sourceFileDef,anchor,true);
966 }
967 }
static SearchIndexIntf searchIndex
Definition doxygen.h:117
void setCurrentDoc(const Definition *ctx, const DString &anchor, bool isSourceFile)
968}

References Doxygen::searchIndex, SearchIndexIntf::setCurrentDoc(), and yyguts_t.

Referenced by LexCodeParser::parseCode(), and startCodeLine().

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

975{
976 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
977 if (yyextra->sourceFileDef && yyextra->lineNumbers)
978 {
979 const Definition *d = yyextra->sourceFileDef->getSourceDefinition(yyextra->yyLineNr);
The common base class of all entity definitions found in the sources.
Definition definition.h:77
980
981 if (!yyextra->includeCodeFragment && d)
982 {
983 yyextra->currentDefinition = d;
984 yyextra->currentMemberDef = yyextra->sourceFileDef->getSourceMember(yyextra->yyLineNr);
985 yyextra->classScope = d->name();
986 DString lineAnchor;
987 lineAnchor.sprintf("l%05d",yyextra->yyLineNr);
988 if (yyextra->currentMemberDef)
989 {
990 yyextra->code->writeLineNumber(yyextra->currentMemberDef->getReference(),
991 yyextra->currentMemberDef->getOutputFileBase(),
992 yyextra->currentMemberDef->anchor(),yyextra->yyLineNr,
993 !yyextra->includeCodeFragment);
994 setCurrentDoc(yyscanner,lineAnchor);
995 }
996 else
997 {
998 yyextra->code->writeLineNumber(d->getReference(),
1000 DString(),yyextra->yyLineNr,
1001 !yyextra->includeCodeFragment);
1002 setCurrentDoc(yyscanner,lineAnchor);
1003 }
1004 }
1005 else
1006 {
1007 yyextra->code->writeLineNumber(DString(),DString(),DString(),yyextra->yyLineNr,
1008 !yyextra->includeCodeFragment);
1009 }
1010 }
DString & sprintf(const char *format,...)
Definition dstring.cpp:34
virtual const DString & name() const =0
virtual DString getReference() const =0
virtual DString getOutputFileBase() const =0
static void setCurrentDoc(yyscan_t yyscanner, const DString &anchor)
Definition lexcode.l:954
1011
1012 yyextra->code->startCodeLine(yyextra->yyLineNr);
1013 yyextra->insideCodeLine = true;
1014
1015
1016 if (yyextra->currentFontClass)
1017 {
1018 yyextra->code->startFontClass(yyextra->currentFontClass);
1019 }
1020}

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

Referenced by nextCodeLine(), and LexCodeParser::parseCode().

◆ startFontClass()

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(), and yyguts_t.

◆ stateToString()

const char * stateToString ( int state)
static

◆ yylex()

int yylex ( yyscan_t yyscanner)

Definition at line 198 of file lexcode.l.

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

◆ yyread()

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}

References yyguts_t.