Doxygen
Loading...
Searching...
No Matches
defargs.l
Go to the documentation of this file.
-1/******************************************************************************
2 *
3 *
4 *
5 * Copyright (C) 1997-2015 by Dimitri van Heesch.
6 *
7 * Permission to use, copy, modify, and distribute this software and its
8 * documentation under the terms of the GNU General Public License is hereby
9 * granted. No representations are made about the suitability of this software
10 * for any purpose. It is provided "as is" without express or implied warranty.
11 * See the GNU General Public License for more details.
12 *
13 * Documents produced by Doxygen are derivative works derived from the
14 * input used in their production; they are not affected by this license.
15 *
16 */
15
16/*! \file
17 * This scanner is used to convert a string into a list of function or
18 * template arguments. Each parsed argument results in a Argument struct,
19 * that is put into an ArgumentList in declaration order.
20 * Comment blocks for arguments can also be included in the string.
21 * The argument string does not contain new-lines (except inside any
22 * comment blocks).
23 * An Argument consists of the string fields:
24 * type,name,default value, and documentation
25 * The Argument list as a whole can be pure, constant or volatile.
26 *
27 * Examples of input strings are:
28 * \verbatim
29 * "(int a,int b) const"
30 * "(const char *s="hello world",int=5) = 0"
31 * "<class T,class N>"
32 * "(char c,const char)"
33 * \endverbatim
34 *
35 * Note: It is not always possible to distinguish between the name and
36 * type of an argument. In case of doubt the name is added to the
37 * type, and the matchArgumentList in util.cpp is be used to
38 * further determine the correct separation.
39 */
40%option never-interactive
41%option prefix="defargsYY"
42%option reentrant
43%option extra-type="struct defargsYY_state *"
44%top{
45#include <stdint.h>
46// forward declare yyscan_t to improve type safety
47#define YY_TYPEDEF_YY_SCANNER_T
48struct yyguts_t;
49typedef yyguts_t *yyscan_t;
yyguts_t * yyscan_t
Definition code.l:24
50}
52%{
53
54/*
55 * includes
56 */
57#include <stdio.h>
58//#include <iostream.h>
59#include <assert.h>
60#include <ctype.h>
61
62#include "defargs.h"
63#include "entry.h"
64#include "util.h"
65#include "arguments.h"
66#include "message.h"
67#include "debug.h"
68
69#define YY_NO_INPUT 1
70#define YY_NO_UNISTD_H 1
72/* -----------------------------------------------------------------
73 * state variables
74 */
75struct defargsYY_state
76{
104
105static int yyread(yyscan_t yyscanner,char *buf,int max_size);
106static bool nameIsActuallyPartOfType(QCString &name);
107
108/* -----------------------------------------------------------------
109 */
110#undef YY_INPUT
111#define YY_INPUT(buf,result,max_size) result=yyread(yyscanner,buf,max_size);
112
113// otherwise the filename would be the name of the converted file (*.cpp instead of *.l)
114static inline const char *getLexerFILE() {return __FILE__;}
115#define LEX_NO_INPUT_FILENAME
This is an alternative implementation of QCString.
Definition qcstring.h:101
static int yyread(yyscan_t yyscanner, char *buf, int max_size)
Definition code.l:3971
static const char * stateToString(int state)
static const char * getLexerFILE()
Definition code.l:263
static bool nameIsActuallyPartOfType(QCString &name)
Definition defargs.l:810
const char * inputString
Definition defargs.l:81
QCString curTypeConstraint
Definition defargs.l:92
std::unique_ptr< ArgumentList > & argList
Definition defargs.l:82
QCString delimiter
Definition defargs.l:102
int argSquareCount
Definition defargs.l:95
QCString extraTypeChars
Definition defargs.l:93
SrcLangExt lang
Definition defargs.l:83
QCString curArgAttrib
Definition defargs.l:90
QCString * copyArgValue
Definition defargs.l:85
defargsYY_state(const char *inStr, std::unique_ptr< ArgumentList > &al, SrcLangExt l)
Definition defargs.l:79
QCString curArgDocs
Definition defargs.l:89
QCString curArgDefValue
Definition defargs.l:87
int lastExtendsContext
Definition defargs.l:101
int argCurlyCount
Definition defargs.l:97
int readArgContext
Definition defargs.l:98
QCString curArgName
Definition defargs.l:88
int argSharpCount
Definition defargs.l:96
QCString curArgArray
Definition defargs.l:91
int argRoundCount
Definition defargs.l:94
int inputPosition
Definition defargs.l:84
QCString curArgTypeName
Definition defargs.l:86
int lastDocContext
Definition defargs.l:99
SrcLangExt
Definition types.h:207
A bunch of utility functions.
118%}
119
120B [ \t]
121Bopt {B}*
122ID [$a-z_A-Z\x80-\xFF][$a-z_A-Z0-9\x80-\xFF]*
123RAWBEGIN (u|U|L|u8)?R\"[^ \t\‍(\‍)\\‍]{0,16}"("
124RAWEND ")"[^ \t\‍(\‍)\\‍]{0,16}\"
125
126 // C start comment
127CCS "/\*"
128 // C end comment
129CCE "*\/"
130 // Cpp comment
131CPPC "/\/"
132
133%option noyywrap
134
135%x Start
136%x CopyArgString
137%x CopyRawString
138%x CopyArgRound
139%x CopyArgRound2
140%x CopyArgSquare
141%x CopyArgSharp
142%x CopyArgCurly
143%x ReadFuncArgType
144%x ReadFuncArgDef
145%x ReadFuncArgPtr
146%x FuncQual
147%x ReadDocBlock
148%x ReadDocLine
149%x ReadTypeConstraint
150%x TrailingReturn
151
152
153%%
154
155<Start>[<(] { BEGIN(ReadFuncArgType); }
156
157<ReadFuncArgType>{B}* {
158 yyextra->curArgTypeName+=" ";
159 }
160<ReadFuncArgType>"["[^\‍]]*"]" {
161 if (yyextra->curArgTypeName.stripWhiteSpace().isEmpty())
162 {
163 yyextra->curArgAttrib=yytext; // for M$-IDL
164 }
165 else // array type
166 {
167 yyextra->curArgArray+=yytext;
168 }
169 }
170<ReadFuncArgDef>"'"\\‍[0-7]{1,3}"'" { yyextra->curArgDefValue+=yytext; }
171<ReadFuncArgDef>"'"\\."'" { yyextra->curArgDefValue+=yytext; }
172<ReadFuncArgDef>"'"."'" { yyextra->curArgDefValue+=yytext; }
173<ReadFuncArgDef>{RAWBEGIN} { yyextra->curArgDefValue+=yytext;
174 yyextra->delimiter = extractBeginRawStringDelimiter(yytext);
175 BEGIN( CopyRawString );
176 }
QCString extractBeginRawStringDelimiter(const char *rawStart)
Definition util.cpp:6898
177<ReadFuncArgDef>\" {
178 yyextra->curArgDefValue+=*yytext;
179 BEGIN( CopyArgString );
180 }
181<ReadFuncArgType>"("([^:)]+{B}*"::")*{B}*[&*\^]+{Bopt}/{ID} {
182 // function pointer as argument
183 yyextra->curArgTypeName+=yytext;
184 //yyextra->curArgTypeName=yyextra->curArgTypeName.simplifyWhiteSpace();
185 BEGIN( ReadFuncArgPtr );
186 }
187<ReadFuncArgPtr>{ID} {
188 yyextra->curArgName=yytext;
189 }
190<ReadFuncArgPtr>")"{B}*"(" { // function pointer
191 yyextra->curArgTypeName+=yytext;
192 //yyextra->curArgTypeName=yyextra->curArgTypeName.simplifyWhiteSpace();
193 yyextra->readArgContext = ReadFuncArgType;
194 yyextra->copyArgValue=&yyextra->curArgTypeName;
195 yyextra->argRoundCount=0;
196 BEGIN( CopyArgRound2 );
197 }
198<ReadFuncArgPtr>")"/{B}*"[" { // pointer to fixed size array
199 yyextra->curArgTypeName+=yytext;
200 yyextra->curArgTypeName+=yyextra->curArgName;
201 //yyextra->curArgTypeName=yyextra->curArgTypeName.simplifyWhiteSpace();
202 BEGIN( ReadFuncArgType );
203 }
204<ReadFuncArgPtr>")" { // redundant braces detected / remove them
205 int i=yyextra->curArgTypeName.findRev('(');
206 int l=static_cast<int>(yyextra->curArgTypeName.length());
207 if (i!=-1)
208 {
209 yyextra->curArgTypeName=yyextra->curArgTypeName.left(i)+
210 yyextra->curArgTypeName.right(l-i-1);
211 }
212 yyextra->curArgTypeName+=yyextra->curArgName;
213 BEGIN( ReadFuncArgType );
214 }
215<ReadFuncArgType>"<="|">="|"->"|">>"|"<<" { // handle operators in defargs
216 yyextra->curArgTypeName+=yytext;
217 }
218<ReadFuncArgType,ReadFuncArgDef>[({<\‍[] {
219 if (YY_START==ReadFuncArgType)
220 {
221 yyextra->curArgTypeName+=*yytext;
222 yyextra->copyArgValue=&yyextra->curArgTypeName;
223 }
224 else // YY_START==ReadFuncArgDef
225 {
226 yyextra->curArgDefValue+=*yytext;
227 yyextra->copyArgValue=&yyextra->curArgDefValue;
228 }
229 yyextra->readArgContext = YY_START;
230 if (*yytext=='(')
231 {
232 yyextra->argRoundCount=0;
233 BEGIN( CopyArgRound );
234 }
235 else if (*yytext=='[')
236 {
237 yyextra->argSquareCount=0;
238 BEGIN( CopyArgSquare );
239 }
240 else if (*yytext=='{')
241 {
242 yyextra->argCurlyCount=0;
243 BEGIN( CopyArgCurly );
244 }
245 else // yytext=='<'
246 {
247 yyextra->argSharpCount=0;
248 yyextra->argRoundCount=0;
249 BEGIN( CopyArgSharp );
250 }
251 }
252<CopyArgRound,CopyArgRound2>"(" {
253 yyextra->argRoundCount++;
254 *yyextra->copyArgValue += *yytext;
255 }
256<CopyArgRound,CopyArgRound2>")"({B}*{ID})* {
257 *yyextra->copyArgValue += yytext;
258 if (yyextra->argRoundCount>0)
259 {
260 yyextra->argRoundCount--;
261 }
262 else
263 {
264 if (YY_START==CopyArgRound2)
265 {
266 *yyextra->copyArgValue+=" "+yyextra->curArgName;
267 }
268 BEGIN( yyextra->readArgContext );
269 }
270 }
271<CopyArgRound>")"/{B}* {
272 *yyextra->copyArgValue += *yytext;
273 if (yyextra->argRoundCount>0) yyextra->argRoundCount--;
274 else BEGIN( yyextra->readArgContext );
275 }
276<CopyArgSquare>"[" {
277 yyextra->argSquareCount++;
278 *yyextra->copyArgValue += *yytext;
279 }
280<CopyArgSquare>"]"({B}*{ID})* {
281 *yyextra->copyArgValue += yytext;
282 if (yyextra->argSquareCount>0)
283 {
284 yyextra->argRoundCount--;
285 }
286 else
287 {
288 BEGIN( yyextra->readArgContext );
289 }
290 }
291<CopyArgSquare>"]"/{B}* {
292 *yyextra->copyArgValue += *yytext;
293 if (yyextra->argSquareCount>0) yyextra->argSquareCount--;
294 else BEGIN( yyextra->readArgContext );
295 }
296<CopyArgSharp>"<<" {
297 if (yyextra->argRoundCount>0)
298 {
299 // for e.g. < typename A = (i<<3) >
300 *yyextra->copyArgValue += yytext;
301 }
302 else
303 {
304 REJECT;
305 }
306 }
307<CopyArgSharp>">>" {
308 if (yyextra->argRoundCount>0)
309 {
310 // for e.g. < typename A = (i>>3) >
311 *yyextra->copyArgValue += yytext;
312 }
313 else
314 {
315 REJECT;
316 }
317 }
318<CopyArgSharp>"<" {
319 // don't count < inside (, e.g. for things like: < typename A=(i<6) >
320 if (yyextra->argRoundCount==0) yyextra->argSharpCount++;
321 *yyextra->copyArgValue += *yytext;
322 }
323<CopyArgSharp>">" {
324 *yyextra->copyArgValue += *yytext;
325 if (yyextra->argRoundCount>0 && yyextra->argSharpCount==0)
326 {
327 // don't count > inside )
328 }
329 else
330 {
331 if (yyextra->argSharpCount>0)
332 {
333 yyextra->argSharpCount--;
334 }
335 else
336 {
337 BEGIN( yyextra->readArgContext );
338 }
339 }
340 }
341<CopyArgSharp>"(" {
342 yyextra->argRoundCount++;
343 *yyextra->copyArgValue += *yytext;
344 }
345<CopyArgSharp>")" {
346 yyextra->argRoundCount--;
347 *yyextra->copyArgValue += *yytext;
348 }
349<CopyArgCurly>"{" {
350 yyextra->argCurlyCount++;
351 *yyextra->copyArgValue += *yytext;
352 }
353<CopyArgCurly>"}" {
354 *yyextra->copyArgValue += *yytext;
355 if (yyextra->argCurlyCount>0) yyextra->argCurlyCount--;
356 else BEGIN( yyextra->readArgContext );
357 }
358<CopyArgString>\\. {
359 yyextra->curArgDefValue+=yytext;
360 }
361<CopyRawString>{RAWEND} {
362 yyextra->curArgDefValue+=yytext;
363 if (extractEndRawStringDelimiter(yytext)==yyextra->delimiter)
364 {
365 BEGIN( ReadFuncArgDef );
366 }
367 }
QCString extractEndRawStringDelimiter(const char *rawEnd)
Definition util.cpp:6906
368<CopyArgString>\" {
369 yyextra->curArgDefValue+=*yytext;
370 BEGIN( ReadFuncArgDef );
371 }
372<ReadFuncArgType>"=" {
373 BEGIN( ReadFuncArgDef );
374 }
375<ReadFuncArgType,ReadFuncArgDef>[,)>]{B}*({CCS}[*!]|{CPPC}[/!])"<" {
376 yyextra->lastDocContext=YY_START;
377 yyextra->lastDocChar=*yytext;
378 QCString text(yytext);
379 if (text.find("//")!=-1)
380 BEGIN( ReadDocLine );
381 else
382 BEGIN( ReadDocBlock );
383 }
384<ReadFuncArgType,ReadFuncArgDef>[,)>] {
385 if (*yytext==')' && yyextra->curArgTypeName.stripWhiteSpace().isEmpty())
386 {
387 yyextra->curArgTypeName+=*yytext;
388 BEGIN(FuncQual);
389 }
390 else
391 {
392 yyextra->curArgTypeName=removeRedundantWhiteSpace(yyextra->curArgTypeName);
393 yyextra->curArgDefValue=yyextra->curArgDefValue.stripWhiteSpace();
394 //printf("curArgType='%s' curArgDefVal='%s'\n",qPrint(yyextra->curArgTypeName),qPrint(yyextra->curArgDefValue));
395 int l = static_cast<int>(yyextra->curArgTypeName.length());
396 if (l>0)
397 {
398 int i=l-1;
399 while (i>=0 && (isspace((uint8_t)yyextra->curArgTypeName.at(i)) || yyextra->curArgTypeName.at(i)=='.')) i--;
400 while (i>=0 && (isId(yyextra->curArgTypeName.at(i)) || yyextra->curArgTypeName.at(i)=='$')) i--;
401 Argument a;
402 a.attrib = yyextra->curArgAttrib;
403 a.typeConstraint = yyextra->curTypeConstraint.stripWhiteSpace();
404 //printf("a->type=%s a->name=%s i=%d l=%d\n",
405 // qPrint(a->type),qPrint(a->name),i,l);
406 a.array.clear();
407 if (i==l-1 && yyextra->curArgTypeName.at(i)==')') // function argument
408 {
409 int bi=yyextra->curArgTypeName.find('(');
410 int fi=bi-1;
411 //printf("func arg fi=%d\n",fi);
412 while (fi>=0 && (isId(yyextra->curArgTypeName.at(fi)) || yyextra->curArgTypeName.at(fi)==':')) fi--;
413 if (fi>=0)
414 {
415 a.type = yyextra->curArgTypeName.left(fi+1);
416 a.name = yyextra->curArgTypeName.mid(fi+1,bi-fi-1).stripWhiteSpace();
417 a.array = yyextra->curArgTypeName.right(l-bi);
418 }
419 else
420 {
421 a.type = yyextra->curArgTypeName;
422 }
423 }
424 else if (i>=0 && yyextra->curArgTypeName.at(i)!=':')
425 { // type contains a name
426 a.type = removeRedundantWhiteSpace(yyextra->curArgTypeName.left(i+1)).stripWhiteSpace();
427 a.name = yyextra->curArgTypeName.right(l-i-1).stripWhiteSpace();
428
429 // if the type becomes a type specifier only then we make a mistake
430 // and need to correct it to avoid seeing a nameless parameter
431 // "struct A" as a parameter with type "struct" and name "A".
432 int sv=0;
433 if (a.type.startsWith("const ")) sv=6;
434 else if (a.type.startsWith("volatile ")) sv=9;
435
436 if (a.type.mid(sv)=="struct" ||
437 a.type.mid(sv)=="union" ||
438 a.type.mid(sv)=="class" ||
439 a.type.mid(sv)=="typename" ||
440 a.type=="const" ||
441 a.type=="volatile" ||
443 )
444 {
445 a.type = a.type + " " + a.name;
446 a.name.clear();
447 }
448 //printf(" --> a->type='%s' a->name='%s'\n",qPrint(a->type),qPrint(a->name));
449 }
450 else // assume only the type was specified, try to determine name later
451 {
452 a.type = removeRedundantWhiteSpace(yyextra->curArgTypeName);
453 }
454 if (!a.type.isEmpty() && a.type.at(0)=='$') // typeless PHP name?
455 {
456 a.name = a.type;
457 a.type = "";
458 }
459 a.array += removeRedundantWhiteSpace(yyextra->curArgArray);
460 //printf("array=%s\n",qPrint(a->array));
461 size_t alen = a.array.length();
462 if (alen>2 && a.array.at(0)=='(' &&
463 a.array.at(alen-1)==')') // fix-up for int *(a[10])
464 {
465 i=a.array.find('[')-1;
466 a.array = a.array.mid(1,alen-2);
467 if (i>0 && a.name.isEmpty())
468 {
469 a.name = a.array.left(i).stripWhiteSpace();
470 a.array = a.array.mid(i);
471 }
472 }
473 a.defval = yyextra->curArgDefValue;
474 //printf("a->type=%s a->name=%s a->defval=\"%s\"\n",qPrint(a->type),qPrint(a->name),qPrint(a->defval));
475 a.docs = yyextra->curArgDocs.stripWhiteSpace();
476 //printf("Argument '%s' '%s' adding docs='%s'\n",qPrint(a->type),qPrint(a->name),qPrint(a->docs));
477 yyextra->argList->push_back(a);
478 }
479 yyextra->curArgAttrib.clear();
480 yyextra->curArgTypeName.clear();
481 yyextra->curArgDefValue.clear();
482 yyextra->curArgArray.clear();
483 yyextra->curArgDocs.clear();
484 yyextra->curTypeConstraint.clear();
485 if (*yytext==')')
486 {
487 BEGIN(FuncQual);
488 //printf(">>> end of argument list\n");
489 }
490 else
491 {
492 BEGIN( ReadFuncArgType );
493 }
494 }
495 }
int find(char c, int index=0, bool cs=TRUE) const
Definition qcstring.cpp:43
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:166
bool startsWith(const char *s) const
Definition qcstring.h:507
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition qcstring.h:241
char & at(size_t i)
Returns a reference to the character at index i.
Definition qcstring.h:593
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:163
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
Definition qcstring.h:260
QCString right(size_t len) const
Definition qcstring.h:234
QCString left(size_t len) const
Definition qcstring.h:229
void clear()
Definition qcstring.h:182
This class contains the information about the argument of a function or template.
Definition arguments.h:27
QCString type
Definition arguments.h:42
QCString name
Definition arguments.h:44
QCString defval
Definition arguments.h:46
QCString docs
Definition arguments.h:47
QCString array
Definition arguments.h:45
QCString typeConstraint
Definition arguments.h:48
QCString attrib
Definition arguments.h:41
QCString removeRedundantWhiteSpace(const QCString &s)
Definition util.cpp:568
bool isId(int c)
Definition util.h:207
496<ReadFuncArgType,ReadFuncArgPtr>"extends" {
497 if (yyextra->lang!=SrcLangExt::Java)
498 {
499 REJECT;
500 }
501 else
502 {
503 yyextra->argSharpCount=0;
504 yyextra->curTypeConstraint.clear();
505 yyextra->lastExtendsContext=YY_START;
506 BEGIN(ReadTypeConstraint);
507 }
508 }
509<ReadFuncArgType,ReadFuncArgPtr>"$"?{ID} {
510 QCString name(yytext);
511 if (YY_START==ReadFuncArgType && yyextra->curArgArray=="[]") // Java style array
512 {
513 yyextra->curArgTypeName+=" []";
514 yyextra->curArgArray.clear();
515 }
516 //printf("resolveName '%s'->'%s'\n",yytext,qPrint(name));
517 yyextra->curArgTypeName+=name;
518 }
519<ReadFuncArgType,ReadFuncArgPtr>. {
520 yyextra->curArgTypeName+=*yytext;
521 }
522
523<ReadFuncArgDef,CopyArgString>"<="|"->"|">="|">>"|"<<" {
524 yyextra->curArgDefValue+=yytext;
525 }
526<ReadFuncArgDef,CopyArgString,CopyRawString>. {
527 yyextra->curArgDefValue+=*yytext;
528 }
529<CopyArgRound,CopyArgRound2,CopyArgSquare,CopyArgSharp,CopyArgCurly>{ID} {
530 *yyextra->copyArgValue+=yytext;
531 }
532<CopyArgRound,CopyArgRound2,CopyArgSquare,CopyArgSharp,CopyArgCurly>. {
533 *yyextra->copyArgValue += *yytext;
534 }
535<ReadTypeConstraint>[,)>] {
536 if (yytext[0]!='>' || yyextra->argSharpCount==0)
537 {
538 unput(*yytext);
539 BEGIN(yyextra->lastExtendsContext);
540 }
541 else
542 {
543 yyextra->curTypeConstraint+=yytext;
544 yyextra->argSharpCount--;
545 }
546 }
547<ReadTypeConstraint>"<" {
548 yyextra->curTypeConstraint+=yytext;
549 yyextra->argSharpCount++;
550 }
551<ReadTypeConstraint>. {
552 yyextra->curTypeConstraint+=yytext;
553 }
554<ReadTypeConstraint>\n {
555 yyextra->curTypeConstraint+=' ';
556 }
557<FuncQual>"const" {
558 yyextra->argList->setConstSpecifier(TRUE);
559 }
#define TRUE
Definition qcstring.h:37
560<FuncQual>"volatile" {
561 yyextra->argList->setVolatileSpecifier(TRUE);
562 }
563<FuncQual>"override" {
564 }
565<FuncQual>"&" {
566 yyextra->argList->setRefQualifier(RefQualifierType::LValue);
567 }
568<FuncQual>"&&" {
569 yyextra->argList->setRefQualifier(RefQualifierType::RValue);
570 }
571<FuncQual,TrailingReturn>"="{B}*"0" {
572 yyextra->argList->setPureSpecifier(TRUE);
573 BEGIN(FuncQual);
574 }
575<FuncQual>"->" { // C++11 trailing return type
576 yyextra->argList->setTrailingReturnType(QCString(" -> "));
577 BEGIN(TrailingReturn);
578 }
579<TrailingReturn>{B}/("final"|"override"){B}* {
580 unput(*yytext);
581 BEGIN(FuncQual);
582 }
583<TrailingReturn>. {
584 yyextra->argList->setTrailingReturnType(yyextra->argList->trailingReturnType()+yytext);
585 }
586<TrailingReturn>\n {
587 yyextra->argList->setTrailingReturnType(yyextra->argList->trailingReturnType()+yytext);
588 }
589<FuncQual>")"{B}*"["[^]]*"]" { // for functions returning a pointer to an array,
590 // i.e. ")[]" in "int (*f(int))[4]" with argsString="(int))[4]"
591 yyextra->extraTypeChars=yytext;
592 }
593<ReadDocBlock>[^\*\n]+ {
594 yyextra->curArgDocs+=yytext;
595 }
596<ReadDocLine>[^\n]+ {
597 yyextra->curArgDocs+=yytext;
598 }
599<ReadDocBlock>{CCE} {
600 if (yyextra->lastDocChar!=0)
601 unput(yyextra->lastDocChar);
602 BEGIN(yyextra->lastDocContext);
603 }
604<ReadDocLine>\n {
605 if (yyextra->lastDocChar!=0)
606 unput(yyextra->lastDocChar);
607 BEGIN(yyextra->lastDocContext);
608 }
609<ReadDocBlock>\n {
610 yyextra->curArgDocs+=*yytext;
611 }
612<ReadDocBlock>. {
613 yyextra->curArgDocs+=*yytext;
614 }
615<*>({CCS}[*!]|{CPPC}[/!])("<"?) {
616 yyextra->lastDocContext=YY_START;
617 yyextra->lastDocChar=0;
618 if (yytext[1]=='/')
619 BEGIN( ReadDocLine );
620 else
621 BEGIN( ReadDocBlock );
622 }
623<*>\n
624<*>.
625
626%%
627
628/* ----------------------------------------------------------------------------
629 */
630
631static int yyread(yyscan_t yyscanner,char *buf,int max_size)
632{
633 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
634 int c=0;
635 while( c < max_size && yyextra->inputString[yyextra->inputPosition] )
636 {
637 *buf = yyextra->inputString[yyextra->inputPosition++] ;
638 c++; buf++;
639 }
640 return c;
641}
642
643/*
644The following code is generated using 'gperf keywords.txt'
645where keywords.txt has the following content
646
647---------------------------------
648%define class-name KeywordHash
649%define lookup-function-name find
650%readonly-tables
651%language=C++
652%%
653unsigned
654signed
655bool
656char
657char8_t
658char16_t
659char32_t
660wchar_t
661int
662short
663long
664float
665double
666int8_t
667int16_t
668int32_t
669int64_t
670intmax_t
671intptr_t
672uint8_t
673uint16_t
674uint32_t
675uint64_t
676uintmax_t
677uintptr_t
678const
679volatile
680void
681%%
682---------------------------------
683*/
684//--- begin gperf generated code ----------------------------------------------------------
685
686#define TOTAL_KEYWORDS 28
687#define MIN_WORD_LENGTH 3
688#define MAX_WORD_LENGTH 9
689#define MIN_HASH_VALUE 3
690#define MAX_HASH_VALUE 48
691/* maximum key range = 46, duplicates = 0 */
693class KeywordHash
694{
695 private:
696 static inline size_t hash (const char *str, size_t len);
697 public:
698 static const char *find (const char *str, size_t len);
699};
700
701inline size_t KeywordHash::hash (const char *str, size_t len)
702{
703 static const unsigned char asso_values[] =
704 {
705 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
706 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
707 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
708 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
709 49, 49, 49, 49, 49, 49, 49, 49, 49, 5,
710 5, 30, 0, 49, 25, 49, 10, 49, 49, 49,
711 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
712 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
713 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
714 49, 49, 49, 49, 49, 0, 49, 0, 5, 49,
715 15, 0, 49, 10, 49, 30, 49, 49, 0, 20,
716 0, 49, 15, 49, 5, 10, 0, 49, 49, 49,
717 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
718 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
719 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
720 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
721 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
722 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
723 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
724 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
725 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
726 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
727 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
728 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
729 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
730 49, 49, 49, 49, 49, 49
731 };
732 size_t hval = len;
733
734 switch (hval)
735 {
736 default:
737 hval += asso_values[static_cast<unsigned char>(str[4])];
738 /*FALLTHROUGH*/
739 case 4:
740 hval += asso_values[static_cast<unsigned char>(str[3])];
741 /*FALLTHROUGH*/
742 case 3:
743 break;
744 }
745 return hval;
746}
747
748const char * KeywordHash::find (const char *str, size_t len)
749{
750 static const char * const wordlist[] =
751 {
752 "", "", "",
753 "int",
754 "bool",
755 "float",
756 "signed",
757 "",
758 "volatile",
759 "char",
760 "short",
761 "double",
762 "wchar_t",
763 "uint16_t",
764 "long",
765 "const",
766 "int8_t",
767 "uint8_t",
768 "char16_t",
769 "void",
770 "", "",
771 "char8_t",
772 "intptr_t",
773 "uintptr_t",
774 "", "", "",
775 "intmax_t",
776 "uintmax_t",
777 "", "",
778 "int64_t",
779 "uint64_t",
780 "", "", "",
781 "int16_t",
782 "uint32_t",
783 "", "", "",
784 "int32_t",
785 "char32_t",
786 "", "", "", "",
787 "unsigned"
788 };
789
790 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
791 {
792 size_t key = hash (str, len);
793
794 if (key <= MAX_HASH_VALUE)
795 {
796 const char *s = wordlist[key];
797
798 if (*str == *s && !qstrcmp (str + 1, s + 1))
799 return s;
800 }
801 }
802 return nullptr;
803}
804
805//--- end gperf generated code ----------------------------------------------------------
806
807/* bug_520975 */
808static bool nameIsActuallyPartOfType(QCString &name)
809{
810 return KeywordHash::find(name.data(),name.length())!=nullptr;
811}
812
813/*! Converts an argument string into an ArgumentList.
814 * \param[in] lang language of the current argument list
815 * \param[in] argsString the list of Arguments.
816 * \param[out] extraTypeChars point to string to which trailing characters
817 * for complex types are written to
818 */
819
820std::unique_ptr<ArgumentList> stringToArgumentList(SrcLangExt lang, const QCString &argsString,QCString *extraTypeChars)
821{
822 std::unique_ptr<ArgumentList> al = std::make_unique<ArgumentList>();
823 if (argsString.isEmpty()) return al;
824
825 yyscan_t yyscanner;
826 defargsYY_state extra(argsString.data(),al,lang);
827 defargsYYlex_init_extra(&extra,&yyscanner);
828#ifdef FLEX_DEBUG
829 defargsYYset_debug(Debug::isFlagSet(Debug::Lex_defargs)?1:0,yyscanner);
830#endif
831 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
832 DebugLex debugLex(Debug::Lex_defargs, __FILE__, nullptr);
833
834 defargsYYrestart( nullptr, yyscanner );
835 BEGIN( Start );
836 defargsYYlex(yyscanner);
837 if (yyextra->argList->empty())
838 {
839 yyextra->argList->setNoParameters(TRUE);
840 }
841 if (extraTypeChars) *extraTypeChars=yyextra->extraTypeChars;
842 //printf("stringToArgumentList(%s) result=%s\n",argsString,qPrint(argListToString(*al)));
843 defargsYYlex_destroy(yyscanner);
844 return al;
845}
846
847#include "defargs.l.h"
@ Lex_defargs
Definition debug.h:58
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:132
static size_t hash(const char *str, size_t len)
Definition defargs.l:703
static const char * find(const char *str, size_t len)
Definition defargs.l:750
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:172
#define MIN_WORD_LENGTH
Definition defargs.l:689
#define MAX_HASH_VALUE
Definition defargs.l:692
std::unique_ptr< ArgumentList > stringToArgumentList(SrcLangExt lang, const QCString &argsString, QCString *extraTypeChars)
Definition defargs.l:822
int qstrcmp(const char *str1, const char *str2)
Definition qcstring.h:69