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 code.l:3982

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

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

Definition at line 311 of file sqlcode.l.

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

References nextCodeLine().

◆ countLines()

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

void endCodeLine ( yyscan_t yyscanner)
static

Definition at line 288 of file sqlcode.l.

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

◆ endFontClass()

void endFontClass ( yyscan_t yyscanner)
static

Definition at line 278 of file sqlcode.l.

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

◆ getLexerFILE()

const char * getLexerFILE ( )
inlinestatic

Definition at line 93 of file sqlcode.l.

93{return __FILE__;}

◆ nextCodeLine()

void nextCodeLine ( yyscan_t yyscanner)
static

Definition at line 296 of file sqlcode.l.

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

References endCodeLine().

◆ setCurrentDoc()

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

Definition at line 211 of file sqlcode.l.

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

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

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

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

◆ stateToString()

const char * stateToString ( int state)
static

◆ yylex()

int yylex ( yyscan_t yyscanner)

Definition at line 134 of file sqlcode.l.

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

◆ yyread()

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}