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

Go to the source code of this file.

Classes

struct  xmlcodeYY_state
struct  XMLCodeParser::Private

Macros

#define YY_TYPEDEF_YY_SCANNER_T
#define yyguts_t   xmlcodeYYguts_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 codify (yyscan_t yyscanner, const char *text)
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 char *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 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 xmlcode.l:213

Definition at line 107 of file xmlcode.l.

◆ YY_NEVER_INTERACTIVE

#define YY_NEVER_INTERACTIVE   1

Definition at line 54 of file xmlcode.l.

◆ YY_NO_INPUT

#define YY_NO_INPUT   1

Definition at line 55 of file xmlcode.l.

◆ YY_NO_UNISTD_H

#define YY_NO_UNISTD_H   1

Definition at line 56 of file xmlcode.l.

◆ YY_TYPEDEF_YY_SCANNER_T

#define YY_TYPEDEF_YY_SCANNER_T

Definition at line 30 of file xmlcode.l.

◆ yyguts_t

#define yyguts_t   xmlcodeYYguts_t

Definition at line 31 of file xmlcode.l.

Typedef Documentation

◆ yyscan_t

typedef yyguts_t* yyscan_t

Definition at line 33 of file xmlcode.l.

Function Documentation

◆ codify()

void codify ( yyscan_t yyscanner,
const char * text )
static

Definition at line 228 of file xmlcode.l.

229{
230 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
231 yyextra->code->codify(text);
#define yyguts_t
Definition code.l:23
232}

References yyguts_t.

◆ codifyLines()

void codifyLines ( yyscan_t yyscanner,
const char * text )
static

Definition at line 335 of file xmlcode.l.

336{
337 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
338 const char *p=text,*sp=p;
339 char c;
340 bool done=false;
341 while (!done)
342 {
343 sp=p;
344 while ((c=*p++) && c!='\n') { }
345 if (c=='\n')
346 {
347 yyextra->yyLineNr++;
348 size_t l = static_cast<size_t>(p-sp-1);
349 yyextra->code->codify(DString(sp,l));
350 nextCodeLine(yyscanner);
351 }
352 else
353 {
354 yyextra->code->codify(sp);
355 done=true;
356 }
357 }
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:84
static void nextCodeLine(yyscan_t yyscanner)
Definition xmlcode.l:320
358}

References nextCodeLine(), and yyguts_t.

◆ countLines()

int countLines ( yyscan_t yyscanner)
static

counts the number of lines in the input

Definition at line 369 of file xmlcode.l.

370{
371 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
372 const char *p=yyextra->inputString;
373 char c;
374 int count=1;
375 while ((c=*p))
376 {
377 p++ ;
378 if (c=='\n') count++;
379 }
380 if (p>yyextra->inputString && *(p-1)!='\n')
381 { // last line does not end with a \n, so we add an extra
382 // line and explicitly terminate the line after parsing.
383 count++;
384 }
385 return count;
386}

References yyguts_t.

Referenced by XMLCodeParser::parseCode().

◆ endCodeLine()

void endCodeLine ( yyscan_t yyscanner)
static

Definition at line 312 of file xmlcode.l.

313{
314 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
315 endFontClass(yyscanner);
316 yyextra->code->endCodeLine();
317 yyextra->insideCodeLine = false;
static void endFontClass(yyscan_t yyscanner)
Definition xmlcode.l:302
318}

References endFontClass(), and yyguts_t.

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

◆ endFontClass()

void endFontClass ( yyscan_t yyscanner)
static

Definition at line 302 of file xmlcode.l.

303{
304 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
305 if (yyextra->currentFontClass)
306 {
307 yyextra->code->endFontClass();
308 yyextra->currentFontClass=0;
309 }
310}

References yyguts_t.

Referenced by endCodeLine(), and startFontClass().

◆ getLexerFILE()

const char * getLexerFILE ( )
inlinestatic

Definition at line 110 of file xmlcode.l.

110{return __FILE__;}

◆ nextCodeLine()

void nextCodeLine ( yyscan_t yyscanner)
static

Definition at line 320 of file xmlcode.l.

321{
322 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
323 const char *fc = yyextra->currentFontClass;
324 if (yyextra->insideCodeLine)
325 {
326 endCodeLine(yyscanner);
327 }
328 if (yyextra->yyLineNr<yyextra->inputLines)
329 {
330 yyextra->currentFontClass = fc;
331 startCodeLine(yyscanner);
332 }
static void endCodeLine(yyscan_t yyscanner)
Definition xmlcode.l:312
static void startCodeLine(yyscan_t yyscanner)
Definition xmlcode.l:254
333}

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

Referenced by codifyLines().

◆ setCurrentDoc()

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

Definition at line 234 of file xmlcode.l.

235{
236 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
237 if (Doxygen::searchIndex.enabled())
238 {
239 if (yyextra->searchCtx)
240 {
241 Doxygen::searchIndex.setCurrentDoc(yyextra->searchCtx,yyextra->searchCtx->anchor(),false);
242 }
243 else
244 {
245 Doxygen::searchIndex.setCurrentDoc(yyextra->sourceFileDef,anchor,true);
246 }
247 }
static SearchIndexIntf searchIndex
Definition doxygen.h:117
void setCurrentDoc(const Definition *ctx, const DString &anchor, bool isSourceFile)
248}

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

Referenced by XMLCodeParser::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 254 of file xmlcode.l.

255{
256 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
257 if (yyextra->sourceFileDef && yyextra->lineNumbers)
258 {
259 const Definition *d = yyextra->sourceFileDef->getSourceDefinition(yyextra->yyLineNr);
The common base class of all entity definitions found in the sources.
Definition definition.h:77
260
261 if (!yyextra->includeCodeFragment && d && d->isLinkableInProject())
262 {
263 yyextra->currentDefinition = d;
264 yyextra->currentMemberDef = yyextra->sourceFileDef->getSourceMember(yyextra->yyLineNr);
265 //yyextra->insideBody = false;
266 yyextra->classScope = d->name();
267 DString lineAnchor;
268 lineAnchor.sprintf("l%05d",yyextra->yyLineNr);
269 if (yyextra->currentMemberDef)
270 {
271 yyextra->code->writeLineNumber(yyextra->currentMemberDef->getReference(),
272 yyextra->currentMemberDef->getOutputFileBase(),
273 yyextra->currentMemberDef->anchor(),yyextra->yyLineNr,
274 !yyextra->includeCodeFragment);
275 setCurrentDoc(yyscanner,lineAnchor);
276 }
277 else
278 {
279 yyextra->code->writeLineNumber(d->getReference(),
281 DString(),yyextra->yyLineNr,
282 !yyextra->includeCodeFragment);
283 setCurrentDoc(yyscanner,lineAnchor);
284 }
285 }
286 else
287 {
288 yyextra->code->writeLineNumber(DString(),DString(),DString(),yyextra->yyLineNr,
289 !yyextra->includeCodeFragment);
290 }
291 }
DString & sprintf(const char *format,...)
Definition dstring.cpp:34
virtual const DString & name() const =0
virtual bool isLinkableInProject() const =0
virtual DString getReference() const =0
virtual DString getOutputFileBase() const =0
static void setCurrentDoc(yyscan_t yyscanner, const DString &anchor)
Definition xmlcode.l:234
292
293 yyextra->code->startCodeLine(yyextra->yyLineNr);
294 yyextra->insideCodeLine = true;
295
296 if (yyextra->currentFontClass)
297 {
298 yyextra->code->startFontClass(yyextra->currentFontClass);
299 }
300}

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

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

◆ startFontClass()

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

Definition at line 360 of file xmlcode.l.

361{
362 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
363 endFontClass(yyscanner);
364 yyextra->code->startFontClass(s);
365 yyextra->currentFontClass=s;
366}

References endFontClass(), and yyguts_t.

◆ stateToString()

const char * stateToString ( int state)
static

◆ yylex()

int yylex ( yyscan_t yyscanner)

Definition at line 130 of file xmlcode.l.

132 {ws} {
133 codifyLines(yyscanner,yytext);
134 }
static void codifyLines(yyscan_t yyscanner, const char *text)
Definition xmlcode.l:335
135<INITIAL>"/" {
136 endFontClass(yyscanner);
137 codify(yyscanner,yytext);
138 }
static void codify(yyscan_t yyscanner, const char *text)
Definition xmlcode.l:228
139<INITIAL>"=" {
140 endFontClass(yyscanner);
141 codify(yyscanner,yytext);
142 }
143<INITIAL>{close} {
144 endFontClass(yyscanner);
145 codify(yyscanner,yytext);
146 }
147<INITIAL>{name} {
148 startFontClass(yyscanner,"keyword");
149 codify(yyscanner,yytext);
150 endFontClass(yyscanner);
151 }
static void startFontClass(yyscan_t yyscanner, const char *s)
Definition xmlcode.l:360
152<INITIAL>{string} {
153 startFontClass(yyscanner,"stringliteral");
154 codifyLines(yyscanner,yytext);
155 endFontClass(yyscanner);
156 }
157{cdata} {
158 startFontClass(yyscanner,"xmlcdata");
159 codifyLines(yyscanner,yytext);
160 endFontClass(yyscanner);
161 }
162
163{open}{ws}?{name} {
164 // Write the < in a different color
165 char openBracket[] = { yytext[0], '\0' };
166 codify(yyscanner,openBracket);
167
168 // Then write the rest
169 yytext++;
170 startFontClass(yyscanner,"keywordtype");
171 codify(yyscanner,yytext);
172 endFontClass(yyscanner);
173
174 BEGIN(INITIAL);
175 }
176{open}{ws}?"/"{name} {
177 // Write the "</" in a different color
178 char closeBracket[] = { yytext[0], yytext[1], '\0' };
179 endFontClass(yyscanner);
180 codify(yyscanner,closeBracket);
181
182 // Then write the rest
183 yytext++; // skip the '<'
184 yytext++; // skip the '/'
185 startFontClass(yyscanner,"keywordtype");
186 codify(yyscanner,yytext);
187 endFontClass(yyscanner);
188
189 BEGIN(INITIAL);
190 }
191{comment} {
192 // Strip off the extra '!'
193 // yytext++; // <
194 // *yytext = '<'; // replace '!' with '<'
195
196 startFontClass(yyscanner,"comment");
197 codifyLines(yyscanner,yytext);
198 endFontClass(yyscanner);
199 }
200{nl} {
201 codifyLines(yyscanner,yytext);
202 }
203
204. {
205 //printf("!ERROR(%c)\n", *yytext);
206 codifyLines(yyscanner,yytext);
207 }
208
209%%

◆ yyread()

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

Definition at line 213 of file xmlcode.l.

214{
215 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
216 int inputPosition = yyextra->inputPosition;
217 const char *s = yyextra->inputString + inputPosition;
218 int c=0;
219 while( c < max_size && *s)
220 {
221 *buf++ = *s++;
222 c++;
223 }
224 yyextra->inputPosition += c;
225 return c;
226}

References yyguts_t.