Doxygen
Loading...
Searching...
No Matches
xmlcode.l File Reference
#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"
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 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 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 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 code.l:3982

Definition at line 106 of file xmlcode.l.

◆ YY_NEVER_INTERACTIVE

#define YY_NEVER_INTERACTIVE   1

Definition at line 53 of file xmlcode.l.

◆ YY_NO_INPUT

#define YY_NO_INPUT   1

Definition at line 54 of file xmlcode.l.

◆ YY_NO_UNISTD_H

#define YY_NO_UNISTD_H   1

Definition at line 55 of file xmlcode.l.

◆ YY_TYPEDEF_YY_SCANNER_T

#define YY_TYPEDEF_YY_SCANNER_T

Definition at line 30 of file xmlcode.l.

Typedef Documentation

◆ yyscan_t

typedef yyguts_t* yyscan_t

Definition at line 32 of file xmlcode.l.

Function Documentation

◆ codify()

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

Definition at line 227 of file xmlcode.l.

228{
229 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
230 yyextra->code->codify(text);
231}

◆ codifyLines()

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

Definition at line 334 of file xmlcode.l.

335{
336 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
337 const char *p=text,*sp=p;
338 char c;
339 bool done=false;
340 while (!done)
341 {
342 sp=p;
343 while ((c=*p++) && c!='\n') { }
344 if (c=='\n')
345 {
346 yyextra->yyLineNr++;
347 size_t l = static_cast<size_t>(p-sp-1);
348 yyextra->code->codify(QCString(sp,l));
349 nextCodeLine(yyscanner);
350 }
351 else
352 {
353 yyextra->code->codify(sp);
354 done=true;
355 }
356 }
This is an alternative implementation of QCString.
Definition qcstring.h:101
static void nextCodeLine(yyscan_t yyscanner)
Definition xmlcode.l:319
357}

References nextCodeLine().

◆ countLines()

int countLines ( yyscan_t yyscanner)
static

counts the number of lines in the input

Definition at line 368 of file xmlcode.l.

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

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

◆ endFontClass()

void endFontClass ( yyscan_t yyscanner)
static

Definition at line 301 of file xmlcode.l.

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

◆ getLexerFILE()

const char * getLexerFILE ( )
inlinestatic

Definition at line 109 of file xmlcode.l.

109{return __FILE__;}

◆ nextCodeLine()

void nextCodeLine ( yyscan_t yyscanner)
static

Definition at line 319 of file xmlcode.l.

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

References endCodeLine().

◆ setCurrentDoc()

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

Definition at line 233 of file xmlcode.l.

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

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

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

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.

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

◆ stateToString()

const char * stateToString ( int state)
static

◆ yylex()

int yylex ( yyscan_t yyscanner)

Definition at line 129 of file xmlcode.l.

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

◆ yyread()

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

Definition at line 212 of file xmlcode.l.

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