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 xmlcode.l:211

Definition at line 105 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()

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

Definition at line 226 of file xmlcode.l.

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

◆ codifyLines()

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

Definition at line 333 of file xmlcode.l.

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 }
static void nextCodeLine(yyscan_t yyscanner)
Definition xmlcode.l:318
357}

References nextCodeLine().

◆ countLines()

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

static void endCodeLine ( yyscan_t yyscanner)
static

Definition at line 310 of file xmlcode.l.

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

References endFontClass().

◆ endFontClass()

static void endFontClass ( yyscan_t yyscanner)
static

Definition at line 300 of file xmlcode.l.

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

static const char * getLexerFILE ( )
inlinestatic

Definition at line 108 of file xmlcode.l.

108{return __FILE__;}

◆ nextCodeLine()

static void nextCodeLine ( yyscan_t yyscanner)
static

Definition at line 318 of file xmlcode.l.

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 }
static void endCodeLine(yyscan_t yyscanner)
Definition xmlcode.l:310
static void startCodeLine(yyscan_t yyscanner)
Definition xmlcode.l:252
331}

References endCodeLine(), and startCodeLine().

◆ setCurrentDoc()

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

Definition at line 232 of file xmlcode.l.

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 }
static SearchIndexIntf searchIndex
Definition doxygen.h:124
246}

References Doxygen::searchIndex.

◆ startCodeLine()

static 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.

253{
254 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
255 if (yyextra->sourceFileDef)
256 {
257 const Definition *d = yyextra->sourceFileDef->getSourceDefinition(yyextra->yyLineNr);
The common base class of all entity definitions found in the sources.
Definition definition.h:76
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 }
virtual bool isLinkableInProject() const =0
virtual QCString getReference() const =0
virtual QCString getOutputFileBase() const =0
virtual const QCString & name() const =0
This is an alternative implementation of QCString.
Definition qcstring.h:101
QCString & sprintf(const char *format,...)
Definition qcstring.cpp:29
static void setCurrentDoc(yyscan_t yyscanner, const QCString &anchor)
Definition xmlcode.l:232
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()

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

References endFontClass().

◆ stateToString()

static const char * stateToString ( int state)
static

◆ yylex()

int yylex ( yyscan_t yyscanner)

Definition at line 128 of file xmlcode.l.

130 {ws} {
131 codifyLines(yyscanner,yytext);
132 }
static void codifyLines(yyscan_t yyscanner, const char *text)
Definition xmlcode.l:333
133<INITIAL>"/" {
134 endFontClass(yyscanner);
135 codify(yyscanner,yytext);
136 }
static void codify(yyscan_t yyscanner, const char *text)
Definition xmlcode.l:226
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 }
static void startFontClass(yyscan_t yyscanner, const char *s)
Definition xmlcode.l:359
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()

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

Definition at line 211 of file xmlcode.l.

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}