Skip to main content

The xmlcode.l File Reference

Included Headers

#include <stdint.h> #include <stdio.h> #include "xmlcode.h" #include "entry.h" #include "doxygen.h" #include "outputlist.h" #include "util.h" #include "membername.h" #include "searchindex.h" #include "config.h" #include "filedef.h" #include "tooltip.h" #include "message.h" #include "debug.h" #include "doxygen_lex.h" #include "xmlcode.l.h"

Classes Index

structxmlcodeYY_state
structPrivate

Typedefs Index

typedefyyguts_t * yyscan_t

Functions Index

static const char *stateToString (int state)
static voidcodify (yyscan_t yyscanner, const char *text)
static voidsetCurrentDoc (yyscan_t yyscanner, const QCString &anchor)
static voidstartCodeLine (yyscan_t yyscanner)
static voidendFontClass (yyscan_t yyscanner)
static voidendCodeLine (yyscan_t yyscanner)
static voidnextCodeLine (yyscan_t yyscanner)
static voidcodifyLines (yyscan_t yyscanner, const char *text)
static voidstartFontClass (yyscan_t yyscanner, const char *s)
static intcountLines (yyscan_t yyscanner)
static intyyread (yyscan_t yyscanner, char *buf, int max_size)
static const char *getLexerFILE ()
intyylex (yyscan_t yyscanner)

Macro Definitions Index

#defineYY_TYPEDEF_YY_SCANNER_T
#defineYY_NEVER_INTERACTIVE   1
#defineYY_NO_INPUT   1
#defineYY_NO_UNISTD_H   1
#defineYY_INPUT(buf, result, max_size)   result=yyread(yyscanner,buf,max_size);

Typedefs

yyscan_t

typedef yyguts_t* yyscan_t

Definition at line 32 of file xmlcode.l.

32typedef yyguts_t *yyscan_t;

Functions

codify()

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

Definition at line 226 of file xmlcode.l.

226static void codify(yyscan_t yyscanner,const char* text)
227{
228 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
229 yyextra->code->codify(text);
230}

codifyLines()

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

Definition at line 333 of file xmlcode.l.

333static void codifyLines(yyscan_t yyscanner,const char *text)
334{
335 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
336 const char *p=text,*sp=p;
337 char c;
338 bool done=false;
339 while (!done)
340 {
341 sp=p;
342 while ((c=*p++) && c!='\n') { }
343 if (c=='\n')
344 {
345 yyextra->yyLineNr++;
346 size_t l = static_cast<size_t>(p-sp-1);
347 std::string tmp(sp,l);
348 yyextra->code->codify(tmp.c_str());
349 nextCodeLine(yyscanner);
350 }
351 else
352 {
353 yyextra->code->codify(sp);
354 done=true;
355 }
356 }
357}

Reference nextCodeLine.

countLines()

int countLines (yyscan_t yyscanner)
static

counts the number of lines in the input

Definition at line 368 of file xmlcode.l.

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

endCodeLine()

void endCodeLine (yyscan_t yyscanner)
static

Definition at line 310 of file xmlcode.l.

310static void endCodeLine(yyscan_t yyscanner)
311{
312 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
313 endFontClass(yyscanner);
314 yyextra->code->endCodeLine();
315 yyextra->insideCodeLine = false;
316}

Reference endFontClass.

endFontClass()

void endFontClass (yyscan_t yyscanner)
static

Definition at line 300 of file xmlcode.l.

300static void endFontClass(yyscan_t yyscanner)
301{
302 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
303 if (yyextra->currentFontClass)
304 {
305 yyextra->code->endFontClass();
306 yyextra->currentFontClass=0;
307 }
308}

getLexerFILE()

const char * getLexerFILE ()
inline static

Definition at line 108 of file xmlcode.l.

108static inline const char *getLexerFILE() {return __FILE__;}

nextCodeLine()

void nextCodeLine (yyscan_t yyscanner)
static

Definition at line 318 of file xmlcode.l.

318static void nextCodeLine(yyscan_t yyscanner)
319{
320 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
321 const char *fc = yyextra->currentFontClass;
322 if (yyextra->insideCodeLine)
323 {
324 endCodeLine(yyscanner);
325 }
326 if (yyextra->yyLineNr<yyextra->inputLines)
327 {
328 yyextra->currentFontClass = fc;
329 startCodeLine(yyscanner);
330 }
331}

References endCodeLine and startCodeLine.

setCurrentDoc()

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

Definition at line 232 of file xmlcode.l.

232static void setCurrentDoc(yyscan_t yyscanner,const QCString &anchor)
233{
234 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
235 if (Doxygen::searchIndex.enabled())
236 {
237 if (yyextra->searchCtx)
238 {
239 Doxygen::searchIndex.setCurrentDoc(yyextra->searchCtx,yyextra->searchCtx->anchor(),false);
240 }
241 else
242 {
243 Doxygen::searchIndex.setCurrentDoc(yyextra->sourceFileDef,anchor,true);
244 }
245 }
246}

Reference 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 252 of file xmlcode.l.

252static void startCodeLine(yyscan_t yyscanner)
253{
254 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
255 if (yyextra->sourceFileDef)
256 {
257 const Definition *d = yyextra->sourceFileDef->getSourceDefinition(yyextra->yyLineNr);
258
259 if (!yyextra->includeCodeFragment && d && d->isLinkableInProject())
260 {
261 yyextra->currentDefinition = d;
262 yyextra->currentMemberDef = yyextra->sourceFileDef->getSourceMember(yyextra->yyLineNr);
263 //yyextra->insideBody = false;
264 yyextra->classScope = d->name();
265 QCString lineAnchor;
266 lineAnchor.sprintf("l%05d",yyextra->yyLineNr);
267 if (yyextra->currentMemberDef)
268 {
269 yyextra->code->writeLineNumber(yyextra->currentMemberDef->getReference(),
270 yyextra->currentMemberDef->getOutputFileBase(),
271 yyextra->currentMemberDef->anchor(),yyextra->yyLineNr,
272 !yyextra->includeCodeFragment);
273 setCurrentDoc(yyscanner,lineAnchor);
274 }
275 else
276 {
277 yyextra->code->writeLineNumber(d->getReference(),
279 QCString(),yyextra->yyLineNr,
280 !yyextra->includeCodeFragment);
281 setCurrentDoc(yyscanner,lineAnchor);
282 }
283 }
284 else
285 {
286 yyextra->code->writeLineNumber(QCString(),QCString(),QCString(),yyextra->yyLineNr,
287 !yyextra->includeCodeFragment);
288 }
289 }
290
291 yyextra->code->startCodeLine(yyextra->yyLineNr);
292 yyextra->insideCodeLine = true;
293
294 if (yyextra->currentFontClass)
295 {
296 yyextra->code->startFontClass(yyextra->currentFontClass);
297 }
298}

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

startFontClass()

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

Definition at line 359 of file xmlcode.l.

359static void startFontClass(yyscan_t yyscanner,const char *s)
360{
361 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
362 endFontClass(yyscanner);
363 yyextra->code->startFontClass(s);
364 yyextra->currentFontClass=s;
365}

Reference endFontClass.

stateToString()

const char * stateToString (int state)
static

Definition at line 91 of file xmlcode.l.

yylex()

int yylex (yyscan_t yyscanner)

Definition at line 128 of file xmlcode.l.

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

yyread()

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

Definition at line 211 of file xmlcode.l.

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

Macro Definitions

YY_INPUT

#define YY_INPUT(buf, result, max_size)   result=yyread(yyscanner,buf,max_size);

Definition at line 105 of file xmlcode.l.

105#define YY_INPUT(buf,result,max_size) result=yyread(yyscanner,buf,max_size);

YY_NEVER_INTERACTIVE

#define YY_NEVER_INTERACTIVE   1

Definition at line 53 of file xmlcode.l.

53#define YY_NEVER_INTERACTIVE 1

YY_NO_INPUT

#define YY_NO_INPUT   1

Definition at line 54 of file xmlcode.l.

54#define YY_NO_INPUT 1

YY_NO_UNISTD_H

#define YY_NO_UNISTD_H   1

Definition at line 55 of file xmlcode.l.

55#define YY_NO_UNISTD_H 1

YY_TYPEDEF_YY_SCANNER_T

#define YY_TYPEDEF_YY_SCANNER_T

Definition at line 30 of file xmlcode.l.

30#define YY_TYPEDEF_YY_SCANNER_T

Generated via doxygen2docusaurus by Doxygen 1.14.0.