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