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 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 xml.l:230

Definition at line 112 of file lexcode.l.

◆ YY_NEVER_INTERACTIVE

#define YY_NEVER_INTERACTIVE   1

Definition at line 47 of file lexcode.l.

◆ YY_NO_INPUT

#define YY_NO_INPUT   1

Definition at line 48 of file lexcode.l.

◆ YY_NO_UNISTD_H

#define YY_NO_UNISTD_H   1

Definition at line 49 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 DString & text )
static

Definition at line 1054 of file lexcode.l.

1055{
1056 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1057 if (text.empty()) 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 yyextra->code->codify(DString(sp,l));
1070 nextCodeLine(yyscanner);
1071 }
1072 else
1073 {
1074 yyextra->code->codify(sp);
1075 done=true;
1076 }
1077 }
1078 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
static void nextCodeLine(yyscan_t yyscanner)
Definition lexcode.l:1039
1079}

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

Referenced by handleCCode().

◆ 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}

Referenced by LexCodeParser::parseCode().

◆ endCodeLine()

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().

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

◆ endFontClass()

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}

Referenced by endCodeLine(), endCodeLine(), startFontClass(), and startFontClass().

◆ getLexerFILE()

const char * getLexerFILE ( )
inlinestatic

Definition at line 115 of file lexcode.l.

115{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.empty()) 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,
1151 .setExample(yyextra->exampleBlock,yyextra->exampleName)
1152 .setFileDef(yyextra->sourceFileDef)
1153 .setStartLine(yyextra->startCCodeLine)
1154 .setInlineFragment(yyextra->includeCodeFragment)
1155 .setMemberDef(yyextra->currentMemberDef)
1156 .setShowLineNumbers(yyextra->lineNumbers)
1157 .setSearchCtx(yyextra->searchCtx)
1158 .setCollectXRefs(yyextra->collectXRefs)
1159 );
1160 yyextra->CCodeBuffer.clear();
1161 yyextra->insideCodeLine = yyextra->ccodeParser.insideCodeLine();
1162 yyextra->yyLineNr--;
1163 codifyLines(yyscanner,"\n");
static void codifyLines(yyscan_t yyscanner, const DString &text)
Definition lexcode.l:1054
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
1164}

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

◆ 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 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().

Referenced by codifyLines(), and codifyLines().

◆ setCurrentDoc()

void setCurrentDoc ( yyscan_t yyscanner,
const DString & 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:117
void setCurrentDoc(const Definition *ctx, const DString &anchor, bool isSourceFile)
967}

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

Referenced by LexCodeParser::parseCode(), startCodeLine(), 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 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:77
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 DString 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 DString(),yyextra->yyLineNr,
1000 !yyextra->includeCodeFragment);
1001 setCurrentDoc(yyscanner,lineAnchor);
1002 }
1003 }
1004 else
1005 {
1006 yyextra->code->writeLineNumber(DString(),DString(),DString(),yyextra->yyLineNr,
1007 !yyextra->includeCodeFragment);
1008 }
1009 }
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: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 DString::sprintf().

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

◆ 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 }
1091}

References endFontClass().

◆ stateToString()

const char * stateToString ( int state)
static

◆ yylex()

int yylex ( yyscan_t yyscanner)

Definition at line 197 of file lexcode.l.

200 {TopStart} {
201 handleCCode(yyscanner);
202 codifyLines(yyscanner,yytext);
203 yyextra->lastContext = YY_START;
204 yyextra->startCCodeLine=yyextra->yyLineNr;
205 BEGIN (TopSection);
206 }
static void handleCCode(yyscan_t yyscanner)
Definition lexcode.l:1139
207<DefSection>^{LiteralStart} {
208 handleCCode(yyscanner);
209 codifyLines(yyscanner,yytext);
210 yyextra->lastContext = YY_START;
211 yyextra->startCCodeLine=yyextra->yyLineNr;
212 BEGIN (LiteralSection);
213 }
214<TopSection>^{TopEnd} {
215 handleCCode(yyscanner);
216 codifyLines(yyscanner,yytext);
217 BEGIN( yyextra->lastContext ) ;
218 }
219<TopSection>.*{nl} {
220 yyextra->CCodeBuffer += yytext;
221 yyextra->yyLineNr++;
222 }
223<LiteralSection>^{LiteralEnd} {
224 handleCCode(yyscanner);
225 codifyLines(yyscanner,yytext);
226 BEGIN( yyextra->lastContext ) ;
227 }
228<LiteralSection>.*{nl} {
229 yyextra->CCodeBuffer += yytext;
230 yyextra->yyLineNr++;
231 }
232<DefSection>{CPPC}.*{nl} {
233 yyextra->CCodeBuffer += yytext;
234 yyextra->yyLineNr++;
235 }
236<DefSection>^{ws}*{CCS} {
237 yyextra->CCodeBuffer += yytext;
238 yyextra->lastContext = YY_START;
239 BEGIN(COMMENT);
240 }
241<COMMENT>{CCE}{ws}*{nl} {
242 yyextra->CCodeBuffer+=yytext;
243 yyextra->yyLineNr++;
244 handleCCode(yyscanner);
245 BEGIN(yyextra->lastContext);
246 }
247<COMMENT>{CCE} {
248 yyextra->CCodeBuffer+=yytext;
249 handleCCode(yyscanner);
250 BEGIN(yyextra->lastContext);
251 }
252<COMMENT>[^*\n]+ {
253 yyextra->CCodeBuffer += yytext;
254 }
255<COMMENT>{CPPC}|{CCS} {
256 yyextra->CCodeBuffer += yytext;
257 }
258<COMMENT>{nl} {
259 yyextra->CCodeBuffer += yytext;
260 yyextra->yyLineNr++;
261 }
262<COMMENT>. {
263 yyextra->CCodeBuffer += yytext;
264 }
265<DefSection>^{nl} {
266 handleCCode(yyscanner);
267 codifyLines(yyscanner,yytext);
268 yyextra->startCCodeLine=yyextra->yyLineNr;
269 }
270<DefSection>^{ws}.*{nl} {
271 yyextra->CCodeBuffer += yytext;
272 yyextra->yyLineNr++;
273 }
274<DefSection>^{RulesStart} {
275 handleCCode(yyscanner);
276 codifyLines(yyscanner,yytext);
277 yyextra->startCCodeLine=yyextra->yyLineNr;
278 BEGIN (RulesSectionInit);
279 }
280<DefSection>^{nws} {
281 handleCCode(yyscanner);
282 codifyLines(yyscanner,yytext);
283 BEGIN(DefSectionLine);
284 }
285<DefSectionLine>.*{nl} {
286 codifyLines(yyscanner,yytext);
287 yyextra->startCCodeLine=yyextra->yyLineNr;
288 BEGIN(DefSection);
289 }
290<RulesSectionInit,RulesPattern>^{RulesEnd} {
291 handleCCode(yyscanner);
292 codifyLines(yyscanner,yytext);
293 yyextra->startCCodeLine=yyextra->yyLineNr;
294 BEGIN (UserSection);
295 }
296<RulesSectionInit>^{nws} {
297 handleCCode(yyscanner);
298 unput(*yytext);
299 BEGIN(RulesPattern);
300 }
301<RulesSectionInit>{nl} {
302 yyextra->CCodeBuffer += yytext;
303 yyextra->yyLineNr++;
304 }
305<RulesSectionInit>^{ws}.*{nl} {
306 yyextra->CCodeBuffer += yytext;
307 yyextra->yyLineNr++;
308 }
309<RulesPattern>"<<EOF>>" {
310 yyextra->rulesPatternBuffer += yytext;
311 }
312<RulesPattern>{EscapeRulesChar} {
313 yyextra->rulesPatternBuffer += yytext;
314 }
315<RulesPattern>{RulesSharp} {
316 yyextra->rulesPatternBuffer += yytext;
317 }
318<RulesPattern>{RulesCurly} {
319 yyextra->rulesPatternBuffer += yytext;
320 }
321<RulesPattern>{StartDouble} {
322 yyextra->rulesPatternBuffer += yytext;
323 yyextra->lastContext = YY_START;
324 BEGIN(RulesDouble);
325 }
326<RulesDouble,RulesRoundDouble>"\\\\" {
327 yyextra->rulesPatternBuffer += yytext;
328 }
329<RulesDouble,RulesRoundDouble>"\\\"" {
330 yyextra->rulesPatternBuffer += yytext;
331 }
332<RulesDouble>"\"" {
333 yyextra->rulesPatternBuffer += yytext;
334 BEGIN( yyextra->lastContext ) ;
335 }
336<RulesRoundDouble>"\"" {
337 yyextra->rulesPatternBuffer += yytext;
338 BEGIN(RulesRound) ;
339 }
340<RulesDouble,RulesRoundDouble>. {
341 yyextra->rulesPatternBuffer += yytext;
342 }
343<RulesPattern>{StartSquare} {
344 yyextra->rulesPatternBuffer += yytext;
345 yyextra->lastContext = YY_START;
346 BEGIN(RulesSquare);
347 }
348<RulesSquare,RulesRoundSquare>{CHARCE} {
349 yyextra->rulesPatternBuffer += yytext;
350 }
351<RulesSquare,RulesRoundSquare>"\\‍[" |
352<RulesSquare,RulesRoundSquare>"\\‍]" {
353 yyextra->rulesPatternBuffer += yytext;
354 }
355<RulesSquare>"]" {
356 yyextra->rulesPatternBuffer += yytext;
357 BEGIN(RulesPattern) ;
358 }
359<RulesRoundSquare>"]" {
360 yyextra->rulesPatternBuffer += yytext;
361 BEGIN(RulesRound) ;
362 }
363<RulesSquare,RulesRoundSquare>"\\\\" {
364 yyextra->rulesPatternBuffer += yytext;
365 }
366<RulesSquare,RulesRoundSquare>. {
367 yyextra->rulesPatternBuffer += yytext;
368 }
369<RulesPattern>{StartRoundQuest} {
370 yyextra->rulesPatternBuffer += yytext;
371 yyextra->lastContext = YY_START;
372 BEGIN(RulesRoundQuest);
373 }
374<RulesRoundQuest>{nl} {
375 yyextra->rulesPatternBuffer += yytext;
376 if (!yyextra->rulesPatternBuffer.empty())
377 {
378 startFontClass(yyscanner,"stringliteral");
379 codifyLines(yyscanner,yyextra->rulesPatternBuffer.data());
380 yyextra->rulesPatternBuffer.clear();
381 endFontClass(yyscanner);
382 }
383 }
static void startFontClass(yyscan_t yyscanner, const char *s)
Definition lexcode.l:1081
384<RulesRoundQuest>[^)] {
385 yyextra->rulesPatternBuffer += yytext;
386 }
387<RulesRoundQuest>")" {
388 yyextra->rulesPatternBuffer += yytext;
389 BEGIN(yyextra->lastContext);
390 }
391<RulesPattern>{StartRound} {
392 yyextra->roundCount++;
393 yyextra->rulesPatternBuffer += yytext;
394 yyextra->lastContext = YY_START;
395 BEGIN(RulesRound);
396 }
397<RulesRound>{RulesCurly} {
398 yyextra->rulesPatternBuffer += yytext;
399 }
400<RulesRound>{StartSquare} {
401 yyextra->rulesPatternBuffer += yytext;
402 BEGIN(RulesRoundSquare);
403 }
404<RulesRound>{StartDouble} {
405 yyextra->rulesPatternBuffer += yytext;
406 BEGIN(RulesRoundDouble);
407 }
408<RulesRound>{EscapeRulesChar} {
409 yyextra->rulesPatternBuffer += yytext;
410 }
411<RulesRound>"(" {
412 yyextra->roundCount++;
413 yyextra->rulesPatternBuffer += yytext;
414 }
415<RulesRound>")" {
416 yyextra->roundCount--;
417 yyextra->rulesPatternBuffer += yytext;
418 if (!yyextra->roundCount) BEGIN( yyextra->lastContext ) ;
419 }
420<RulesRound>{nl} {
421 yyextra->rulesPatternBuffer += yytext;
422 yyextra->yyLineNr++;
423 }
424<RulesRound>{ws} {
425 yyextra->rulesPatternBuffer += yytext;
426 }
427<RulesRound>. {
428 yyextra->rulesPatternBuffer += yytext;
429 }
430<RulesPattern>{ws}+"|" {
431 if (!yyextra->rulesPatternBuffer.empty())
432 {
433 startFontClass(yyscanner,"stringliteral");
434 codifyLines(yyscanner,yyextra->rulesPatternBuffer);
435 yyextra->rulesPatternBuffer.clear();
436 endFontClass(yyscanner);
437 }
438 codifyLines(yyscanner,yytext);
439 yyextra->startCCodeLine=yyextra->yyLineNr;
440 yyextra->curlyCount = 0;
441 BEGIN(SkipCurly);
442 }
443<RulesPattern>^{ws}*{nl} {
444 codifyLines(yyscanner,"\n");
445 }
446<RulesPattern>^{ws}+ {
447 codifyLines(yyscanner,yytext);
448 }
449<RulesPattern>({ws}|{nl}) {
450 unput(*yytext);
451 if (!yyextra->rulesPatternBuffer.empty())
452 {
453 startFontClass(yyscanner,"stringliteral");
454 codifyLines(yyscanner,yyextra->rulesPatternBuffer);
455 yyextra->rulesPatternBuffer.clear();
456 endFontClass(yyscanner);
457 }
458 yyextra->startCCodeLine=yyextra->yyLineNr;
459 yyextra->curlyCount = 0;
460 BEGIN(SkipCurly);
461 }
462<RulesPattern>"\\\\" {
463 yyextra->rulesPatternBuffer += yytext;
464 }
465<RulesPattern>{CCS} {
466 if (!yyextra->rulesPatternBuffer.empty())
467 {
468 startFontClass(yyscanner,"stringliteral");
469 codifyLines(yyscanner,yyextra->rulesPatternBuffer);
470 yyextra->rulesPatternBuffer.clear();
471 endFontClass(yyscanner);
472 }
473 yyextra->CCodeBuffer += yytext;
474 yyextra->lastContext = YY_START;
475 BEGIN(COMMENT);
476 }
477<RulesPattern>. {
478 yyextra->rulesPatternBuffer += yytext;
479 }
480<SkipCurly>{B}*"#"{B}+[0-9]+{B}+/"\"" { /* line control directive */
481 yyextra->CCodeBuffer += yytext;
482 yyextra->lastPreLineCtrlContext = YY_START;
483 BEGIN( PreLineCtrl );
484 }
485<PreLineCtrl>"\""[^\n\"]*"\"" {
486 yyextra->CCodeBuffer += yytext;
487 }
488<PreLineCtrl>. {
489 yyextra->CCodeBuffer += yytext;
490 }
491<PreLineCtrl>\n {
492 yyextra->CCodeBuffer += yytext;
493 yyextra->yyLineNr++;
494 BEGIN( yyextra->lastPreLineCtrlContext );
495 }
496<SkipCurly>"{" {
497 yyextra->CCodeBuffer += yytext;
498 ++yyextra->curlyCount ;
499 }
500<SkipCurly>"}"/{BN}*{DCOMM}"<!--" | /* see bug710917 */
501<SkipCurly>"}" {
502 yyextra->CCodeBuffer += yytext;
503 lineCount(yyscanner);
504 if( yyextra->curlyCount )
505 {
506 --yyextra->curlyCount ;
507 }
508 }
#define lineCount(s, len)
509<SkipCurly>"}"{BN}*{DCOMM}"<" {
510 yyextra->CCodeBuffer += yytext;
511 lineCount(yyscanner);
512 if ( yyextra->curlyCount )
513 {
514 --yyextra->curlyCount ;
515 }
516 else
517 {
518 yyextra->docBlockContext = SkipCurlyEndDoc;
519 if (yytext[yyleng-3]=='/')
520 {
521 BEGIN( DocLine );
522 }
523 else
524 {
525 BEGIN( DocBlock );
526 }
527 }
528 }
529<SkipCurly>\" {
530 yyextra->CCodeBuffer += yytext;
531 yyextra->lastStringContext=SkipCurly;
532 BEGIN( SkipString );
533 }
534<SkipCurly>^{B}*"#" {
535 yyextra->CCodeBuffer += yytext;
536 yyextra->lastPreLineCtrlContext = YY_START;
537 BEGIN( PreLineCtrl );
538 }
539<SkipCurly>{B}*{RAWBEGIN} {
540 char *p = yytext;
541 while (*p && disspace(*p)) p++;
542 yyextra->delimiter = extractBeginRawStringDelimiter(p);
543 yyextra->lastRawStringContext = YY_START;
544 yyextra->CCodeBuffer += yytext;
545 BEGIN(RawString);
546 }
bool disspace(char c)
Definition dstring.h:62
DString extractBeginRawStringDelimiter(const char *rawStart)
Definition util.cpp:5339
547<SkipCurly>[^\n#"'@\\/{}<]+ {
548 yyextra->CCodeBuffer += yytext;
549 }
550<SkipCurly>{CCS} {
551 yyextra->CCodeBuffer += yytext;
552 yyextra->lastCContext = YY_START;
553 BEGIN(SkipComment);
554 }
555<SkipCurly>{CPPC} {
556 yyextra->CCodeBuffer += yytext;
557 yyextra->lastCContext = YY_START;
558 BEGIN(SkipCxxComment);
559 }
560<SkipCurly>{CHARLIT} {
561 yyextra->CCodeBuffer += yytext;
562 }
563<SkipCurly>\' {
564 yyextra->CCodeBuffer += yytext;
565 }
566<SkipCurly>. {
567 yyextra->CCodeBuffer += yytext;
568 }
569<SkipCurly>({CPPC}{B}*)?{CCS}"!" {
570 yyextra->CCodeBuffer += yytext;
571 yyextra->docBlockContext = YY_START;
572 BEGIN( DocBlock );
573 }
574<SkipCurly>{CCS}"*"[*]+{BL} {
575 bool javadocBanner = Config_getBool(JAVADOC_BANNER);
576 yyextra->CCodeBuffer += yytext;
577 yyextra->yyLineNr++;
578 if( javadocBanner )
579 {
580 yyextra->docBlockContext = YY_START;
581 BEGIN( DocBlock );
582 }
583 else
584 {
585 BEGIN( Comment ) ;
586 }
587 }
#define Config_getBool(name)
Definition config.h:33
588<SkipCurly>({CPPC}{B}*)?{CCS}"*"/{NCOMM} {
589 yyextra->CCodeBuffer += yytext;
590 yyextra->docBlockContext = YY_START;
591 BEGIN( DocBlock );
592 }
593<SkipCurly>{CPPC}"!" {
594 yyextra->CCodeBuffer += yytext;
595 yyextra->docBlockContext = YY_START;
596 BEGIN( DocLine );
597 }
598<SkipCurly>{CPPC}"/"/[^/] {
599 yyextra->CCodeBuffer += yytext;
600 yyextra->docBlockContext = YY_START;
601 BEGIN( DocLine );
602 }
603
604<SkipCurly>\n {
605 yyextra->CCodeBuffer += yytext;
606 yyextra->yyLineNr++;
607 if (yyextra->curlyCount<=0)
608 {
609 handleCCode(yyscanner);
610 BEGIN(RulesPattern);
611 }
612 }
613<SkipString>\\. {
614 yyextra->CCodeBuffer += yytext;
615 }
616<SkipString>\" {
617 yyextra->CCodeBuffer += yytext;
618 BEGIN( yyextra->lastStringContext );
619 }
620<SkipString>{CCS}|{CCE}|{CPPC} {
621 yyextra->CCodeBuffer += yytext;
622 }
623<SkipString>\n {
624 yyextra->CCodeBuffer += yytext;
625 yyextra->yyLineNr++;
626 }
627<SkipString>. {
628 yyextra->CCodeBuffer += yytext;
629 }
630<SkipCxxComment>.*"\\\n" { // line continuation
631 yyextra->CCodeBuffer += yytext;
632 yyextra->yyLineNr++;
633 }
634<SkipCxxComment>{ANYopt}/\n {
635 yyextra->CCodeBuffer += yytext;
636 BEGIN( yyextra->lastCContext ) ;
637 }
638<Comment>{BN}+ {
639 yyextra->CCodeBuffer += yytext ;
640 lineCount(yyscanner);
641 }
642<Comment>{CCS} { yyextra->CCodeBuffer += yytext ; }
643<Comment>{CPPC} { yyextra->CCodeBuffer += yytext ; }
644<Comment>{CMD}("code"|"verbatim"|"iliteral") {
645 yyextra->insideCode=true;
646 yyextra->CCodeBuffer += yytext ;
647 }
648<Comment>{CMD}("endcode"|"endverbatim"|"endiliteral") {
649 yyextra->insideCode=false;
650 yyextra->CCodeBuffer += yytext ;
651 }
652<Comment>[^ \.\t\r\n\/\*]+ { yyextra->CCodeBuffer += yytext ; }
653<Comment>{CCE} {
654 yyextra->CCodeBuffer += yytext ;
655 if (!yyextra->insideCode) BEGIN( yyextra->lastContext ) ;
656 }
657<Comment>. { yyextra->CCodeBuffer += *yytext ; }
658
659<SkipComment>{CPPC}|{CCS} {
660 yyextra->CCodeBuffer += yytext;
661 }
662<SkipComment>[^\*\n]+ {
663 yyextra->CCodeBuffer += yytext;
664 }
665<SkipComment>\n {
666 yyextra->CCodeBuffer += yytext;
667 yyextra->yyLineNr++;
668 }
669<SkipComment>{B}*{CCE} {
670 yyextra->CCodeBuffer += yytext;
671 BEGIN( yyextra->lastCContext );
672 }
673<SkipComment>"*" {
674 yyextra->CCodeBuffer += yytext;
675 }
676<RawString>{RAWEND} {
677 yyextra->CCodeBuffer += yytext;
678 if (extractEndRawStringDelimiter(yytext)==yyextra->delimiter)
679 {
680 BEGIN(yyextra->lastRawStringContext);
681 }
682 }
DString extractEndRawStringDelimiter(const char *rawEnd)
Definition util.cpp:5347
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"|"mermaid"|"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 DString pat = substitute(yytext,"*"," ");
781 yyextra->docBlockName="~~~";
782 yyextra->fencedSize=pat.stripWhiteSpace().length();
783 yyextra->nestedComment=false;
784 BEGIN(DocCopyBlock);
785 }
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
786<DocBlock>^({B}*"*"+)?{B}{0,3}"```"[`]* {
787 yyextra->CCodeBuffer += yytext;
788 DString 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>{CMD}("f$"|"f]"|"f}"|"f)") {
824 yyextra->CCodeBuffer += yytext;
825 if (yyextra->docBlockName==&yytext[1])
826 {
827 BEGIN(DocBlock);
828 }
829 }
830<DocCopyBlock>{CMD}("endverbatim"|"endiliteral"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endmanonly"|"endrtfonly"|"enddot"|"endmsc"|"endmermaid"|"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 DString 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 DString 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()

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}