Doxygen
Loading...
Searching...
No Matches
sqlcode.l File Reference
#include <stdint.h>
#include <stdio.h>
#include "sqlcode.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 "sqlcode.l.h"
+ Include dependency graph for sqlcode.l:

Go to the source code of this file.

Classes

struct  sqlcodeYY_state
 
struct  SQLCodeParser::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 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 sqlcode.l:364

Definition at line 89 of file sqlcode.l.

◆ YY_NEVER_INTERACTIVE

#define YY_NEVER_INTERACTIVE   1

Definition at line 48 of file sqlcode.l.

◆ YY_NO_INPUT

#define YY_NO_INPUT   1

Definition at line 49 of file sqlcode.l.

◆ YY_NO_UNISTD_H

#define YY_NO_UNISTD_H   1

Definition at line 50 of file sqlcode.l.

◆ YY_TYPEDEF_YY_SCANNER_T

#define YY_TYPEDEF_YY_SCANNER_T

Definition at line 25 of file sqlcode.l.

Typedef Documentation

◆ yyscan_t

typedef yyguts_t* yyscan_t

Definition at line 27 of file sqlcode.l.

Function Documentation

◆ codifyLines()

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

Definition at line 310 of file sqlcode.l.

311{
312 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
313 const char *p=text,*sp=p;
314 char c;
315 bool done=false;
316 while (!done)
317 {
318 sp=p;
319 while ((c=*p++) && c!='\n') { }
320 if (c=='\n')
321 {
322 yyextra->yyLineNr++;
323 size_t l = static_cast<size_t>(p-sp-1);
324 std::string tmp(sp,l);
325 yyextra->code->codify(tmp.c_str());
326 nextCodeLine(yyscanner);
327 }
328 else
329 {
330 yyextra->code->codify(sp);
331 done=true;
332 }
333 }
static void nextCodeLine(yyscan_t yyscanner)
Definition sqlcode.l:295
334}

References nextCodeLine().

◆ countLines()

static int countLines ( yyscan_t yyscanner)
static

counts the number of lines in the input

Definition at line 345 of file sqlcode.l.

346{
347 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
348 const char *p=yyextra->inputString;
349 char c;
350 int count=1;
351 while ((c=*p))
352 {
353 p++ ;
354 if (c=='\n') count++;
355 }
356 if (p>yyextra->inputString && *(p-1)!='\n')
357 { // last line does not end with a \n, so we add an extra
358 // line and explicitly terminate the line after parsing.
359 count++;
360 }
361 return count;
362}

◆ endCodeLine()

static void endCodeLine ( yyscan_t yyscanner)
static

Definition at line 287 of file sqlcode.l.

288{
289 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
290 endFontClass(yyscanner);
291 yyextra->code->endCodeLine();
292 yyextra->insideCodeLine=false;
static void endFontClass(yyscan_t yyscanner)
Definition sqlcode.l:277
293}

References endFontClass().

◆ endFontClass()

static void endFontClass ( yyscan_t yyscanner)
static

Definition at line 277 of file sqlcode.l.

278{
279 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
280 if (yyextra->currentFontClass)
281 {
282 yyextra->code->endFontClass();
283 yyextra->currentFontClass=0;
284 }
285}

◆ getLexerFILE()

static const char * getLexerFILE ( )
inlinestatic

Definition at line 92 of file sqlcode.l.

92{return __FILE__;}

◆ nextCodeLine()

static void nextCodeLine ( yyscan_t yyscanner)
static

Definition at line 295 of file sqlcode.l.

296{
297 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
298 const char *fc = yyextra->currentFontClass;
299 if (yyextra->insideCodeLine)
300 {
301 endCodeLine(yyscanner);
302 }
303 if (yyextra->yyLineNr<yyextra->inputLines)
304 {
305 yyextra->currentFontClass = fc;
306 startCodeLine(yyscanner);
307 }
static void endCodeLine(yyscan_t yyscanner)
Definition sqlcode.l:287
static void startCodeLine(yyscan_t yyscanner)
Definition sqlcode.l:230
308}

References endCodeLine(), and startCodeLine().

◆ setCurrentDoc()

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

Definition at line 210 of file sqlcode.l.

211{
212 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
213 if (Doxygen::searchIndex.enabled())
214 {
215 if (yyextra->searchCtx)
216 {
217 Doxygen::searchIndex.setCurrentDoc(yyextra->searchCtx,yyextra->searchCtx->anchor(),false);
218 }
219 else
220 {
221 Doxygen::searchIndex.setCurrentDoc(yyextra->sourceFileDef,anchor,true);
222 }
223 }
static SearchIndexIntf searchIndex
Definition doxygen.h:124
224}

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 230 of file sqlcode.l.

231{
232 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
233 if (yyextra->sourceFileDef)
234 {
235 const Definition *d = yyextra->sourceFileDef->getSourceDefinition(yyextra->yyLineNr);
The common base class of all entity definitions found in the sources.
Definition definition.h:76
236
237 if (!yyextra->includeCodeFragment && d && d->isLinkableInProject())
238 {
239 yyextra->currentDefinition = d;
240 yyextra->currentMemberDef = yyextra->sourceFileDef->getSourceMember(yyextra->yyLineNr);
241 yyextra->classScope = d->name();
242 QCString lineAnchor;
243 lineAnchor.sprintf("l%05d",yyextra->yyLineNr);
244 if (yyextra->currentMemberDef)
245 {
246 yyextra->code->writeLineNumber(yyextra->currentMemberDef->getReference(),
247 yyextra->currentMemberDef->getOutputFileBase(),
248 yyextra->currentMemberDef->anchor(),yyextra->yyLineNr,
249 !yyextra->includeCodeFragment);
250 setCurrentDoc(yyscanner,lineAnchor);
251 }
252 else
253 {
254 yyextra->code->writeLineNumber(d->getReference(),
256 QCString(),yyextra->yyLineNr,
257 !yyextra->includeCodeFragment);
258 setCurrentDoc(yyscanner,lineAnchor);
259 }
260 }
261 else
262 {
263 yyextra->code->writeLineNumber(QCString(),QCString(),QCString(),yyextra->yyLineNr,
264 !yyextra->includeCodeFragment);
265 }
266 }
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 sqlcode.l:210
267
268 yyextra->code->startCodeLine(yyextra->yyLineNr);
269 yyextra->insideCodeLine=true;
270
271 if (yyextra->currentFontClass)
272 {
273 yyextra->code->startFontClass(yyextra->currentFontClass);
274 }
275}

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 336 of file sqlcode.l.

337{
338 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
339 endFontClass(yyscanner);
340 yyextra->code->startFontClass(s);
341 yyextra->currentFontClass=s;
342}

References endFontClass().

◆ stateToString()

static const char * stateToString ( int state)
static

◆ yylex()

int yylex ( yyscan_t yyscanner)

Definition at line 133 of file sqlcode.l.

135{literals} {
136 startFontClass(yyscanner,"stringliteral");
137 codifyLines(yyscanner,yytext);
138 endFontClass(yyscanner);
139 }
static void startFontClass(yyscan_t yyscanner, const char *s)
Definition sqlcode.l:336
static void codifyLines(yyscan_t yyscanner, const char *text)
Definition sqlcode.l:310
140
141
142{keyword} {
143 startFontClass(yyscanner,"keyword");
144 codifyLines(yyscanner,yytext);
145 endFontClass(yyscanner);
146 }
147
148{flowkeyword} {
149 startFontClass(yyscanner,"keywordflow");
150 codifyLines(yyscanner,yytext);
151 endFontClass(yyscanner);
152 }
153
154{typekeyword} {
155 startFontClass(yyscanner,"keywordtype");
156 codifyLines(yyscanner,yytext);
157 endFontClass(yyscanner);
158 }
159
160{variable} {
161 startFontClass(yyscanner,"preprocessor");
162 codifyLines(yyscanner,yytext);
163 endFontClass(yyscanner);
164 }
165
166{simplecomment} {
167 startFontClass(yyscanner,"comment");
168 codifyLines(yyscanner,yytext);
169 endFontClass(yyscanner);
170 }
171
172{commentopen} {
173 startFontClass(yyscanner,"comment");
174 codifyLines(yyscanner,yytext);
175 BEGIN(COMMENT);
176 }
177
178<COMMENT>. {
179 codifyLines(yyscanner,yytext);
180
181 }
182<COMMENT>{nl} {
183 codifyLines(yyscanner,yytext);
184 }
185
186<COMMENT>{commentclose} {
187 codifyLines(yyscanner,yytext);
188 endFontClass(yyscanner);
189 BEGIN(INITIAL);
190 }
191
192{idchar} {
193 codifyLines(yyscanner,yytext);
194 }
195
196{nl} {
197 codifyLines(yyscanner,yytext);
198 }
199
200[\x80-\xFF]* { // keep utf8 characters together...
201 codifyLines(yyscanner,yytext);
202 }
203. {
204 codifyLines(yyscanner,yytext);
205 }
206
207%%

◆ yyread()

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

Definition at line 364 of file sqlcode.l.

365{
366 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
367 int inputPosition = yyextra->inputPosition;
368 const char *s = yyextra->inputString + inputPosition;
369 int c=0;
370 while( c < max_size && *s )
371 {
372 *buf++ = *s++;
373 c++;
374 }
375 yyextra->inputPosition += c;
376 return c;
377}