Doxygen
Loading...
Searching...
No Matches
declinfo.l File Reference
#include <stdint.h>
#include <stdio.h>
#include <assert.h>
#include <ctype.h>
#include "declinfo.h"
#include "util.h"
#include "message.h"
#include "types.h"
#include "debug.h"
#include "doxygen_lex.h"
#include "declinfo.l.h"
+ Include dependency graph for declinfo.l:

Go to the source code of this file.

Classes

struct  declinfoYY_state
 

Macros

#define YY_TYPEDEF_YY_SCANNER_T
 
#define YY_NO_INPUT   1
 
#define YY_NO_UNISTD_H   1
 
#define YY_NEVER_INTERACTIVE   1
 
#define YY_INPUT(buf, result, max_size)
 
#define LEX_NO_INPUT_FILENAME
 

Typedefs

typedef yyguts_t * yyscan_t
 

Functions

static const char * stateToString (int state)
 
static void addType (yyscan_t yyscanner)
 
static void addTypeName (yyscan_t yyscanner)
 
static int yyread (char *buf, int max_size, yyscan_t yyscanner)
 
static const char * getLexerFILE ()
 
int yylex (yyscan_t yyscanner)
 
void parseFuncDecl (const QCString &decl, const SrcLangExt lang, QCString &cl, QCString &t, QCString &n, QCString &a, QCString &ftl, QCString &exc)
 

Variables

static yyscan_t g_yyscanner
 
static struct declinfoYY_state g_declinfo_extra
 

Macro Definition Documentation

◆ LEX_NO_INPUT_FILENAME

#define LEX_NO_INPUT_FILENAME

Definition at line 89 of file declinfo.l.

◆ YY_INPUT

#define YY_INPUT ( buf,
result,
max_size )
Value:
result=yyread(buf,max_size,yyscanner);
static int yyread(char *buf, int max_size, yyscan_t yyscanner)
Definition declinfo.l:308

Definition at line 85 of file declinfo.l.

◆ YY_NEVER_INTERACTIVE

#define YY_NEVER_INTERACTIVE   1

Definition at line 49 of file declinfo.l.

◆ YY_NO_INPUT

#define YY_NO_INPUT   1

Definition at line 47 of file declinfo.l.

◆ YY_NO_UNISTD_H

#define YY_NO_UNISTD_H   1

Definition at line 48 of file declinfo.l.

◆ YY_TYPEDEF_YY_SCANNER_T

#define YY_TYPEDEF_YY_SCANNER_T

Definition at line 26 of file declinfo.l.

Typedef Documentation

◆ yyscan_t

typedef yyguts_t* yyscan_t

Definition at line 28 of file declinfo.l.

Function Documentation

◆ addType()

static void addType ( yyscan_t yyscanner)
static

Definition at line 280 of file declinfo.l.

281{
282 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
283 //printf("addType() yyextra->type='%s' yyextra->scope='%s' yyextra->name='%s'\n",
284 // qPrint(yyextra->type),qPrint(yyextra->scope),qPrint(yyextra->name));
285 if (yyextra->name.isEmpty() && yyextra->scope.isEmpty()) return;
286 if (!yyextra->type.isEmpty()) yyextra->type+=" ";
287 if (!yyextra->scope.isEmpty()) yyextra->type+=yyextra->scope+"::";
288 yyextra->type+=yyextra->name;
289 yyextra->scope.clear();
290 yyextra->name.clear();
291}

◆ addTypeName()

static void addTypeName ( yyscan_t yyscanner)
static

Definition at line 293 of file declinfo.l.

294{
295 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
296 //printf("addTypeName() yyextra->type='%s' yyextra->scope='%s' yyextra->name='%s'\n",
297 // qPrint(yyextra->type),qPrint(yyextra->scope),qPrint(yyextra->name));
298 if (yyextra->name.isEmpty() ||
299 yyextra->name.at(yyextra->name.length()-1)==':') // end of Objective-C keyword => append to yyextra->name not yyextra->type
300 {
301 return;
302 }
303 if (!yyextra->type.isEmpty()) yyextra->type+=' ';
304 yyextra->type+=yyextra->name;
305 yyextra->name.clear();
306}

◆ getLexerFILE()

static const char * getLexerFILE ( )
inlinestatic

Definition at line 88 of file declinfo.l.

88{return __FILE__;}

◆ parseFuncDecl()

void parseFuncDecl ( const QCString & decl,
const SrcLangExt lang,
QCString & cl,
QCString & t,
QCString & n,
QCString & a,
QCString & ftl,
QCString & exc )

Definition at line 325 of file declinfo.l.

327{
328 if (decl.isEmpty())
329 {
330 return;
331 }
332 declinfoYYlex_init_extra(&g_declinfo_extra, &g_yyscanner);
333 struct yyguts_t *yyg = (struct yyguts_t*)g_yyscanner;
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
static yyscan_t g_yyscanner
Definition declinfo.l:322
static struct declinfoYY_state g_declinfo_extra
Definition declinfo.l:323
334
335#ifdef FLEX_DEBUG
336 declinfoYYset_debug(Debug::isFlagSet(Debug::Lex_declinfo)?1:0,g_yyscanner);
@ Lex_declinfo
Definition debug.h:56
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:135
337#endif
338
339 DebugLex debugLex(Debug::Lex_declinfo,__FILE__, NULL);
340 yyextra->inputString = decl.data();
341 //printf("Input='%s'\n",yyextra->inputString);
342 yyextra->inputPosition = 0;
343 yyextra->classTempListFound = FALSE;
344 yyextra->funcTempListFound = FALSE;
345 yyextra->insideObjC = lang==SrcLangExt::ObjC;
346 yyextra->insidePHP = lang==SrcLangExt::PHP;
347 yyextra->insidePython = lang==SrcLangExt::Python;
348 yyextra->scope.clear();
349 yyextra->className.clear();
350 yyextra->classTempList.clear();
351 yyextra->funcTempList.clear();
352 yyextra->name.clear();
353 yyextra->type.clear();
354 yyextra->args.clear();
355 yyextra->exceptionString.clear();
356 // first we try to find the yyextra->type, yyextra->scope, yyextra->name and arguments
357 declinfoYYrestart( yyin, g_yyscanner );
358 BEGIN( Start );
359 declinfoYYlex(g_yyscanner);
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition qcstring.h:159
#define FALSE
Definition qcstring.h:34
@ Python
Definition types.h:52
360
361 //printf("yyextra->type='%s' class='%s' yyextra->name='%s' yyextra->args='%s'\n",
362 // qPrint(yyextra->type),qPrint(yyextra->scope),qPrint(yyextra->name),qPrint(yyextra->args));
363
364 int nb = yyextra->name.findRev('[');
365 if (nb!=-1 && yyextra->args.isEmpty()) // correct for [] in yyextra->name ambiguity (due to Java return yyextra->type allowing [])
366 {
367 yyextra->args.prepend(yyextra->name.right(yyextra->name.length()-nb));
368 yyextra->name=yyextra->name.left(nb);
369 }
370
371 cl=yyextra->scope;
372 n=removeRedundantWhiteSpace(yyextra->name);
373 int il=n.find('<'), ir=n.findRev('>');
374 if (il!=-1 && ir!=-1 && n.at(il+1)!='=')
375 // prevent <=>
376 // TODO: handle cases like where n="operator<< <T>"
377 {
379 n=n.left(il);
380 }
381
382 //ctl=yyextra->classTempList.copy();
383 //ftl=yyextra->funcTempList.copy();
384 t=removeRedundantWhiteSpace(yyextra->type);
385 a=removeRedundantWhiteSpace(yyextra->args);
386 exc=removeRedundantWhiteSpace(yyextra->exceptionString);
387
388 if (!t.isEmpty() && !t.startsWith("decltype") && t.at(t.length()-1)==')') // for function pointers
389 {
390 a.prepend(")");
391 t=t.left(t.length()-1);
392 }
393 //printf("yyextra->type='%s' class='%s' yyextra->name='%s' yyextra->args='%s'\n",
394 // qPrint(t),qPrint(cl),qPrint(n),qPrint(a));
int find(char c, int index=0, bool cs=TRUE) const
Definition qcstring.cpp:43
QCString & prepend(const char *s)
Definition qcstring.h:407
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:153
bool startsWith(const char *s) const
Definition qcstring.h:492
char & at(size_t i)
Returns a reference to the character at index i.
Definition qcstring.h:578
QCString right(size_t len) const
Definition qcstring.h:219
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition qcstring.cpp:91
QCString left(size_t len) const
Definition qcstring.h:214
QCString removeRedundantWhiteSpace(const QCString &s)
Definition util.cpp:578
395
396 declinfoYYlex_destroy(g_yyscanner);
397 return;
398}

References QCString::at(), QCString::data(), FALSE, QCString::find(), QCString::findRev(), g_declinfo_extra, g_yyscanner, QCString::isEmpty(), Debug::isFlagSet(), QCString::left(), QCString::length(), Debug::Lex_declinfo, ObjC, PHP, QCString::prepend(), Python, removeRedundantWhiteSpace(), QCString::right(), and QCString::startsWith().

Referenced by findMember().

◆ stateToString()

static const char * stateToString ( int state)
static

◆ yylex()

int yylex ( yyscan_t yyscanner)

Definition at line 104 of file declinfo.l.

106 {B}*"["{B}*"]")* { // operator rule must be before {ID} rule
107 yyextra->name += yytext;
108 BEGIN(Operator);
109 }
110<Start>{ID}({B}*"*")?{B}*"("{B}*"^"{B}*")"{B}*"(" { // Objective-C 2.0 block return type
111 if (!yyextra->insideObjC)
112 {
113 REJECT;
114 }
115 else
116 {
117 addType(yyscanner);
118 yyextra->type += yytext;
119 }
120 }
static void addType(yyscan_t yyscanner)
Definition declinfo.l:280
121<Start>{ID}{B}*"("{B}*{ID}{B}*")" { // Objective-C class categories
122 if (!yyextra->insideObjC)
123 {
124 REJECT;
125 }
126 else
127 {
128 yyextra->name += yytext;
129 }
130 }
131<Start>([~!]{B}*)?{ID}{B}*"["{B}*"]" { // PHP
132 if (!yyextra->insidePHP)
133 {
134 REJECT;
135 }
136 addTypeName(yyscanner);
137 yyextra->name += removeRedundantWhiteSpace(QCString(yytext));
138 }
This is an alternative implementation of QCString.
Definition qcstring.h:101
static void addTypeName(yyscan_t yyscanner)
Definition declinfo.l:293
139<Start>"anonymous_namespace{"[^}]+"}" { // anonymous namespace
140 if (!yyextra->scope.isEmpty())
141 {
142 yyextra->scope+=QCString("::")+yytext;
143 }
144 else
145 {
146 yyextra->scope = yytext;
147 }
148 }
149<Start>([~!]{B}*)?{ID}/({B}*"["{B}*"]")* { // the []'s are for Java,
150 // the / was add to deal with multi-
151 // dimensional C++ arrays like A[][15]
152 // the leading ~ is for a destructor
153 // the leading ! is for a C++/CLI finalizer (see bug 456475 and 635198)
154 addTypeName(yyscanner);
155 yyextra->name += removeRedundantWhiteSpace(QCString(yytext));
156 }
157<Start>{B}*"::"{B}* { // found a yyextra->scope specifier
158 if (!yyextra->scope.isEmpty() && !yyextra->scope.endsWith("::"))
159 {
160 if (!yyextra->name.isEmpty()) yyextra->scope+="::"+yyextra->name; // add yyextra->name to yyextra->scope
161 }
162 else
163 {
164 yyextra->scope = yyextra->name; // yyextra->scope becomes yyextra->name
165 }
166 yyextra->name.clear();
167 }
168<Start>{B}*":" { // Objective-C argument separator
169 yyextra->name+=yytext;
170 }
171<Start>[*&]+ {
172 addType(yyscanner);
173 yyextra->type+=yytext;
174 }
175<Start>{B}+ {
176 addType(yyscanner);
177 }
178<Start>{B}*"("({ID}"::")*{B}*[&*]({B}*("const"|"volatile"){B}+)? {
179 if (yyextra->insidePHP) REJECT;
180 if (yyextra->insidePython) REJECT;
181 addType(yyscanner);
182 QCString text(yytext);
183 yyextra->type+=text.stripWhiteSpace();
184 }
185<Start>{B}*")" {
186 yyextra->type+=")";
187 }
188<Start>{B}*"decltype"/{B}*"(" {
189 yyextra->roundCount=0;
190 yyextra->type="decltype";
191 BEGIN(DeclType);
192 }
193<DeclType>{B}*"(" {
194 ++yyextra->roundCount;
195 yyextra->type+="(";
196 }
197<DeclType>{B}*")" {
198 yyextra->type+=")";
199 if (--yyextra->roundCount == 0) {
200 BEGIN(Start);
201 }
202 }
203<DeclType>. {
204 yyextra->type+=yytext;
205 }
206<Start>{B}*"(" { // TODO: function pointers
207 yyextra->args+="(";
208 BEGIN(ReadArgs);
209 }
210<Start>{B}*"[" {
211 yyextra->args+="[";
212 BEGIN(ReadArgs);
213 }
214<Start>{B}*"<" {
215 yyextra->name+="<";
216 yyextra->sharpCount=0;
217 yyextra->roundCount=0;
218 BEGIN(Template);
219 }
220<Template>"<<" { yyextra->name+="<<"; }
221<Template>">>" { yyextra->name+=">>"; }
222<Template>"(" { yyextra->name+="(";
223 yyextra->roundCount++;
224 }
225<Template>")" { yyextra->name+=")";
226 if (yyextra->roundCount>0)
227 {
228 yyextra->roundCount--;
229 }
230 }
231<Template>"<" {
232 yyextra->name+="<";
233 if (yyextra->roundCount==0)
234 {
235 yyextra->sharpCount++;
236 }
237 }
238<Template>">" {
239 yyextra->name+=">";
240 if (yyextra->roundCount==0)
241 {
242 if (yyextra->sharpCount)
243 --yyextra->sharpCount;
244 else
245 {
246 BEGIN(Start);
247 }
248 }
249 }
250<Template>. {
251 yyextra->name+=*yytext;
252 }
253<Operator>{B}*"("{B}*")"{B}*"<>"{Bopt}/"(" {
254 yyextra->name+="() <>";
255 BEGIN(ReadArgs);
256 }
257<Operator>{B}*"("{B}*")"{Bopt}/"(" {
258 yyextra->name+="()";
259 BEGIN(ReadArgs);
260 }
261<Operator>[^(]*{B}*("<>"{B}*)?/"(" {
262 yyextra->name+=yytext;
263 BEGIN(ReadArgs);
264 }
265<ReadArgs>"throw"{B}*"(" {
266 yyextra->exceptionString="throw(";
267 BEGIN(ReadExceptions);
268 }
269<ReadArgs>. {
270 yyextra->args+=*yytext;
271 }
272<ReadExceptions>. {
273 yyextra->exceptionString+=*yytext;
274 }
275<*>.
276<*>\n
277
278%%

◆ yyread()

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

Definition at line 308 of file declinfo.l.

309{
310 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
311 int c=0;
312 while( c < max_size && yyextra->inputString[yyextra->inputPosition] )
313 {
314 *buf = yyextra->inputString[yyextra->inputPosition++] ;
315 c++; buf++;
316 }
317 return c;
318}

Variable Documentation

◆ g_declinfo_extra

struct declinfoYY_state g_declinfo_extra
static

Definition at line 323 of file declinfo.l.

Referenced by parseFuncDecl().

◆ g_yyscanner

yyscan_t g_yyscanner
static

Definition at line 322 of file declinfo.l.

Referenced by parseFuncDecl().