Doxygen
Loading...
Searching...
No Matches
sqlcode.l File Reference
#include <stdint.h>
#include "sqlcode.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 "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 yyguts_t   sqlcodeYYguts_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 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 sqlcode.l:365

Definition at line 91 of file sqlcode.l.

◆ YY_NEVER_INTERACTIVE

#define YY_NEVER_INTERACTIVE   1

Definition at line 49 of file sqlcode.l.

◆ YY_NO_INPUT

#define YY_NO_INPUT   1

Definition at line 50 of file sqlcode.l.

◆ YY_NO_UNISTD_H

#define YY_NO_UNISTD_H   1

Definition at line 51 of file sqlcode.l.

◆ YY_TYPEDEF_YY_SCANNER_T

#define YY_TYPEDEF_YY_SCANNER_T

Definition at line 25 of file sqlcode.l.

◆ yyguts_t

#define yyguts_t   sqlcodeYYguts_t

Definition at line 26 of file sqlcode.l.

Typedef Documentation

◆ yyscan_t

typedef yyguts_t* yyscan_t

Definition at line 28 of file sqlcode.l.

Function Documentation

◆ codifyLines()

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

Definition at line 312 of file sqlcode.l.

313{
314 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
315 const char *p=text,*sp=p;
316 char c;
317 bool done=false;
318 while (!done)
319 {
320 sp=p;
321 while ((c=*p++) && c!='\n') { }
322 if (c=='\n')
323 {
324 yyextra->yyLineNr++;
325 size_t l = static_cast<size_t>(p-sp-1);
326 yyextra->code->codify(DString(sp,l));
327 nextCodeLine(yyscanner);
328 }
329 else
330 {
331 yyextra->code->codify(sp);
332 done=true;
333 }
334 }
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:84
#define yyguts_t
Definition code.l:23
static void nextCodeLine(yyscan_t yyscanner)
Definition sqlcode.l:297
335}

References nextCodeLine(), and yyguts_t.

◆ countLines()

int countLines ( yyscan_t yyscanner)
static

counts the number of lines in the input

Definition at line 346 of file sqlcode.l.

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

References yyguts_t.

Referenced by SQLCodeParser::parseCode().

◆ endCodeLine()

void endCodeLine ( yyscan_t yyscanner)
static

Definition at line 289 of file sqlcode.l.

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

References endFontClass(), and yyguts_t.

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

◆ endFontClass()

void endFontClass ( yyscan_t yyscanner)
static

Definition at line 279 of file sqlcode.l.

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

References yyguts_t.

Referenced by endCodeLine(), and startFontClass().

◆ getLexerFILE()

const char * getLexerFILE ( )
inlinestatic

Definition at line 94 of file sqlcode.l.

94{return __FILE__;}

◆ nextCodeLine()

void nextCodeLine ( yyscan_t yyscanner)
static

Definition at line 297 of file sqlcode.l.

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

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

Referenced by codifyLines().

◆ setCurrentDoc()

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

Definition at line 212 of file sqlcode.l.

213{
214 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
215 if (Doxygen::searchIndex.enabled())
216 {
217 if (yyextra->searchCtx)
218 {
219 Doxygen::searchIndex.setCurrentDoc(yyextra->searchCtx,yyextra->searchCtx->anchor(),false);
220 }
221 else
222 {
223 Doxygen::searchIndex.setCurrentDoc(yyextra->sourceFileDef,anchor,true);
224 }
225 }
static SearchIndexIntf searchIndex
Definition doxygen.h:117
void setCurrentDoc(const Definition *ctx, const DString &anchor, bool isSourceFile)
226}

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

Referenced by SQLCodeParser::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 232 of file sqlcode.l.

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

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

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

◆ startFontClass()

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

Definition at line 337 of file sqlcode.l.

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

References endFontClass(), and yyguts_t.

◆ stateToString()

const char * stateToString ( int state)
static

◆ yylex()

int yylex ( yyscan_t yyscanner)

Definition at line 135 of file sqlcode.l.

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

◆ yyread()

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

Definition at line 365 of file sqlcode.l.

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

References yyguts_t.