Doxygen
Loading...
Searching...
No Matches
declinfo.l File Reference
#include <stdint.h>
#include "declinfo.h"
#include "debug.h"
#include "message.h"
#include "types.h"
#include "util.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 yyguts_t   declinfoYYguts_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 DString &decl, const SrcLangExt lang, DString &cl, DString &t, DString &n, DString &a, DString &ftl, DString &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 83 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:313

Definition at line 79 of file declinfo.l.

◆ YY_NEVER_INTERACTIVE

#define YY_NEVER_INTERACTIVE   1

Definition at line 43 of file declinfo.l.

◆ YY_NO_INPUT

#define YY_NO_INPUT   1

Definition at line 41 of file declinfo.l.

◆ YY_NO_UNISTD_H

#define YY_NO_UNISTD_H   1

Definition at line 42 of file declinfo.l.

◆ YY_TYPEDEF_YY_SCANNER_T

#define YY_TYPEDEF_YY_SCANNER_T

Definition at line 24 of file declinfo.l.

◆ yyguts_t

#define yyguts_t   declinfoYYguts_t

Definition at line 25 of file declinfo.l.

Typedef Documentation

◆ yyscan_t

typedef yyguts_t* yyscan_t

Definition at line 27 of file declinfo.l.

Function Documentation

◆ addType()

void addType ( yyscan_t yyscanner)
static

Definition at line 282 of file declinfo.l.

283{
284 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
285 //printf("addType() yyextra->type='%s' yyextra->scope='%s' yyextra->name='%s'\n",
286 // qPrint(yyextra->type),qPrint(yyextra->scope),qPrint(yyextra->name));
287 if (yyextra->name.empty() && yyextra->scope.empty())
288 {
289 return;
290 }
291 if (!yyextra->type.empty()) yyextra->type+=" ";
292 if (!yyextra->scope.empty()) yyextra->type+=yyextra->scope+"::";
293 yyextra->type+=yyextra->name;
294 yyextra->scope.clear();
295 yyextra->name.clear();
#define yyguts_t
Definition code.l:23
296}

References yyguts_t.

◆ addTypeName()

void addTypeName ( yyscan_t yyscanner)
static

Definition at line 298 of file declinfo.l.

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

References yyguts_t.

◆ getLexerFILE()

const char * getLexerFILE ( )
inlinestatic

Definition at line 82 of file declinfo.l.

82{return __FILE__;}

◆ parseFuncDecl()

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

Definition at line 330 of file declinfo.l.

332{
333 if (decl.empty())
334 {
335 return;
336 }
337 declinfoYYlex_init_extra(&g_declinfo_extra, &g_yyscanner);
338 struct yyguts_t *yyg = (struct yyguts_t*)g_yyscanner;
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:148
static yyscan_t g_yyscanner
Definition declinfo.l:327
static struct declinfoYY_state g_declinfo_extra
Definition declinfo.l:328
339
340#ifdef FLEX_DEBUG
341 declinfoYYset_debug(Debug::isFlagSet(Debug::Lex_declinfo)?1:0,g_yyscanner);
@ Lex_declinfo
Definition debug.h:59
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:132
342#endif
343
344 DebugLex debugLex(Debug::Lex_declinfo,__FILE__, NULL);
345 yyextra->inputString = decl.data();
346 //printf("Input='%s'\n",yyextra->inputString);
347 yyextra->inputPosition = 0;
348 yyextra->classTempListFound = false;
349 yyextra->funcTempListFound = false;
350 yyextra->insideObjC = lang==SrcLangExt::ObjC;
351 yyextra->insidePHP = lang==SrcLangExt::PHP;
352 yyextra->insidePython = lang==SrcLangExt::Python;
353 yyextra->scope.clear();
354 yyextra->className.clear();
355 yyextra->classTempList.clear();
356 yyextra->funcTempList.clear();
357 yyextra->name.clear();
358 yyextra->type.clear();
359 yyextra->args.clear();
360 yyextra->exceptionString.clear();
361 // first we try to find the yyextra->type, yyextra->scope, yyextra->name and arguments
362 declinfoYYrestart( yyin, g_yyscanner );
363 BEGIN( Start );
364 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 dstring.h:157
365
366 //printf("yyextra->type='%s' class='%s' yyextra->name='%s' yyextra->args='%s'\n",
367 // qPrint(yyextra->type),qPrint(yyextra->scope),qPrint(yyextra->name),qPrint(yyextra->args));
368
369 if (size_t nb = yyextra->name.rfind('[') ; nb!=DString::npos && yyextra->args.empty()) // correct for [] in yyextra->name ambiguity (due to Java return yyextra->type allowing [])
370 {
371 yyextra->args.prepend(yyextra->name.mid(nb));
372 yyextra->name=yyextra->name.left(nb);
373 }
static constexpr size_t npos
value used to indicate 'not found' or 'to the end of the string', matching std::string::npos
Definition dstring.h:178
374
375 cl=yyextra->scope;
376 n=removeRedundantWhiteSpace(yyextra->name);
377 size_t il=n.find('<'), ir=n.rfind('>');
378 if (il!=DString::npos && ir!=DString::npos && n.at(il+1)!='=')
379 // prevent <=>
380 // TODO: handle cases like where n="operator<< <T>"
381 {
383 n=n.left(il);
384 }
size_t rfind(char c, size_t pos=npos) const
Definition dstring.h:244
DString mid(size_t index, size_t len=npos) const
Definition dstring.h:318
char & at(size_t i)
Returns a reference to the character at index i.
Definition dstring.h:686
size_t find(char c, size_t pos=0) const
Definition dstring.h:239
DString left(size_t len) const
Definition dstring.h:306
DString removeRedundantWhiteSpace(const DString &s)
Definition util.cpp:427
385
386 //ctl=yyextra->classTempList.copy();
387 //ftl=yyextra->funcTempList.copy();
388 t=removeRedundantWhiteSpace(yyextra->type);
389 a=removeRedundantWhiteSpace(yyextra->args);
390 exc=removeRedundantWhiteSpace(yyextra->exceptionString);
391
392 size_t len = t.length();
393 if (!t.empty() && t.at(len-1)==')') // for function pointers
394 {
395 // check if `)` is from decltype(`
396 size_t pos = t.find("decltype(");
397 if (pos != DString::npos)
398 {
399 size_t cnt = 1;
400 for (size_t i = pos + 9; i < len; i++)
401 {
402 if (t.at(i) == '(') cnt++;
403 else if (t.at(i) == ')')
404 {
405 cnt--;
406 if (cnt == 0)
407 {
408 if (i != len-1)
409 {
410 a.prepend(")");
411 t=t.left(len-1);
412 }
413 }
414 }
415 }
416 }
417 else
418 {
419 a.prepend(")");
420 t=t.left(len-1);
421 }
422 }
423 //printf("yyextra->type='%s' class='%s' yyextra->name='%s' yyextra->args='%s'\n",
424 // qPrint(t),qPrint(cl),qPrint(n),qPrint(a));
DString & prepend(const char *s)
Definition dstring.h:515
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition dstring.h:151
425
426 declinfoYYlex_destroy(g_yyscanner);
427 return;
428}

References DString::at(), DString::data(), DString::empty(), DString::find(), g_declinfo_extra, g_yyscanner, Debug::isFlagSet(), DString::left(), DString::length(), Debug::Lex_declinfo, DString::mid(), DString::npos, DString::prepend(), removeRedundantWhiteSpace(), DString::rfind(), and yyguts_t.

Referenced by findMember().

◆ stateToString()

const char * stateToString ( int state)
static

◆ yylex()

int yylex ( yyscan_t yyscanner)

Definition at line 98 of file declinfo.l.

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

◆ yyread()

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

Definition at line 313 of file declinfo.l.

314{
315 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
316 int c=0;
317 while( c < max_size && yyextra->inputString[yyextra->inputPosition] )
318 {
319 *buf = yyextra->inputString[yyextra->inputPosition++] ;
320 c++; buf++;
321 }
322 return c;
323}

References yyguts_t.

Variable Documentation

◆ g_declinfo_extra

struct declinfoYY_state g_declinfo_extra
static

Definition at line 328 of file declinfo.l.

Referenced by parseFuncDecl().

◆ g_yyscanner

yyscan_t g_yyscanner
static

Definition at line 327 of file declinfo.l.

Referenced by parseFuncDecl().