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:620
static const char * stateToString(int state)
static bool nameIsActuallyPartOfType(QCString &name)
Definition defargs.l:797
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
Definition types.h:207
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 yyextra->delimiter = extractBeginRawStringDelimiter(yytext);
177 BEGIN( CopyRawString );
178 }
QCString extractBeginRawStringDelimiter(const char *rawStart)
Definition util.cpp:7451
179<ReadFuncArgDef>\" {
180 yyextra->curArgDefValue+=*yytext;
181 BEGIN( CopyArgString );
182 }
183<ReadFuncArgType>"("([^:)]+{B}*"::")*{B}*[&*\^]+{Bopt}/{ID} {
184 // function pointer as argument
185 yyextra->curArgTypeName+=yytext;
186 //yyextra->curArgTypeName=yyextra->curArgTypeName.simplifyWhiteSpace();
187 BEGIN( ReadFuncArgPtr );
188 }
189<ReadFuncArgPtr>{ID} {
190 yyextra->curArgName=yytext;
191 }
192<ReadFuncArgPtr>")"{B}*"(" { // function pointer
193 yyextra->curArgTypeName+=yytext;
194 //yyextra->curArgTypeName=yyextra->curArgTypeName.simplifyWhiteSpace();
195 yyextra->readArgContext = ReadFuncArgType;
196 yyextra->copyArgValue=&yyextra->curArgTypeName;
197 yyextra->argRoundCount=0;
198 BEGIN( CopyArgRound2 );
199 }
200<ReadFuncArgPtr>")"/{B}*"[" { // pointer to fixed size array
201 yyextra->curArgTypeName+=yytext;
202 yyextra->curArgTypeName+=yyextra->curArgName;
203 //yyextra->curArgTypeName=yyextra->curArgTypeName.simplifyWhiteSpace();
204 BEGIN( ReadFuncArgType );
205 }
206<ReadFuncArgPtr>")" { // redundant braces detected / remove them
207 int i=yyextra->curArgTypeName.findRev('(');
208 int l=static_cast<int>(yyextra->curArgTypeName.length());
209 if (i!=-1)
210 {
211 yyextra->curArgTypeName=yyextra->curArgTypeName.left(i)+
212 yyextra->curArgTypeName.right(l-i-1);
213 }
214 yyextra->curArgTypeName+=yyextra->curArgName;
215 BEGIN( ReadFuncArgType );
216 }
217<ReadFuncArgType>"<="|">="|"->"|">>"|"<<" { // handle operators in defargs
218 yyextra->curArgTypeName+=yytext;
219 }
220<ReadFuncArgType,ReadFuncArgDef>[({<\[] {
221 if (YY_START==ReadFuncArgType)
222 {
223 yyextra->curArgTypeName+=*yytext;
224 yyextra->copyArgValue=&yyextra->curArgTypeName;
225 }
226 else // YY_START==ReadFuncArgDef
227 {
228 yyextra->curArgDefValue+=*yytext;
229 yyextra->copyArgValue=&yyextra->curArgDefValue;
230 }
231 yyextra->readArgContext = YY_START;
232 if (*yytext=='(')
233 {
234 yyextra->argRoundCount=0;
235 BEGIN( CopyArgRound );
236 }
237 else if (*yytext=='[')
238 {
239 yyextra->argSquareCount=0;
240 BEGIN( CopyArgSquare );
241 }
242 else if (*yytext=='{')
243 {
244 yyextra->argCurlyCount=0;
245 BEGIN( CopyArgCurly );
246 }
247 else // yytext=='<'
248 {
249 yyextra->argSharpCount=0;
250 yyextra->argRoundCount=0;
251 BEGIN( CopyArgSharp );
252 }
253 }
254<CopyArgRound,CopyArgRound2>"(" {
255 yyextra->argRoundCount++;
256 *yyextra->copyArgValue += *yytext;
257 }
258<CopyArgRound,CopyArgRound2>")"({B}*{ID})* {
259 *yyextra->copyArgValue += yytext;
260 if (yyextra->argRoundCount>0)
261 {
262 yyextra->argRoundCount--;
263 }
264 else
265 {
266 if (YY_START==CopyArgRound2)
267 {
268 *yyextra->copyArgValue+=" "+yyextra->curArgName;
269 }
270 BEGIN( yyextra->readArgContext );
271 }
272 }
273<CopyArgRound>")"/{B}* {
274 *yyextra->copyArgValue += *yytext;
275 if (yyextra->argRoundCount>0) yyextra->argRoundCount--;
276 else BEGIN( yyextra->readArgContext );
277 }
278<CopyArgSquare>"[" {
279 yyextra->argSquareCount++;
280 *yyextra->copyArgValue += *yytext;
281 }
282<CopyArgSquare>"]"({B}*{ID})* {
283 *yyextra->copyArgValue += yytext;
284 if (yyextra->argSquareCount>0)
285 {
286 yyextra->argRoundCount--;
287 }
288 else
289 {
290 BEGIN( yyextra->readArgContext );
291 }
292 }
293<CopyArgSquare>"]"/{B}* {
294 *yyextra->copyArgValue += *yytext;
295 if (yyextra->argSquareCount>0) yyextra->argSquareCount--;
296 else BEGIN( yyextra->readArgContext );
297 }
298<CopyArgSharp>"<<" {
299 if (yyextra->argRoundCount>0)
300 {
301 // for e.g. < typename A = (i<<3) >
302 *yyextra->copyArgValue += yytext;
303 }
304 else
305 {
306 REJECT;
307 }
308 }
309<CopyArgSharp>">>" {
310 if (yyextra->argRoundCount>0)
311 {
312 // for e.g. < typename A = (i>>3) >
313 *yyextra->copyArgValue += yytext;
314 }
315 else
316 {
317 REJECT;
318 }
319 }
320<CopyArgSharp>"<" {
321 // don't count < inside (, e.g. for things like: < typename A=(i<6) >
322 if (yyextra->argRoundCount==0) yyextra->argSharpCount++;
323 *yyextra->copyArgValue += *yytext;
324 }
325<CopyArgSharp>">" {
326 *yyextra->copyArgValue += *yytext;
327 if (yyextra->argRoundCount>0 && yyextra->argSharpCount==0)
328 {
329 // don't count > inside )
330 }
331 else
332 {
333 if (yyextra->argSharpCount>0)
334 {
335 yyextra->argSharpCount--;
336 }
337 else
338 {
339 BEGIN( yyextra->readArgContext );
340 }
341 }
342 }
343<CopyArgSharp>"(" {
344 yyextra->argRoundCount++;
345 *yyextra->copyArgValue += *yytext;
346 }
347<CopyArgSharp>")" {
348 yyextra->argRoundCount--;
349 *yyextra->copyArgValue += *yytext;
350 }
351<CopyArgCurly>"{" {
352 yyextra->argCurlyCount++;
353 *yyextra->copyArgValue += *yytext;
354 }
355<CopyArgCurly>"}" {
356 *yyextra->copyArgValue += *yytext;
357 if (yyextra->argCurlyCount>0) yyextra->argCurlyCount--;
358 else BEGIN( yyextra->readArgContext );
359 }
360<CopyArgString>\\. {
361 yyextra->curArgDefValue+=yytext;
362 }
363<CopyRawString>{RAWEND} {
364 yyextra->curArgDefValue+=yytext;
365 if (extractEndRawStringDelimiter(yytext)==yyextra->delimiter)
366 {
367 BEGIN( ReadFuncArgDef );
368 }
369 }
QCString extractEndRawStringDelimiter(const char *rawEnd)
Definition util.cpp:7459
370<CopyArgString>\" {
371 yyextra->curArgDefValue+=*yytext;
372 BEGIN( ReadFuncArgDef );
373 }
374<ReadFuncArgType>"=" {
375 BEGIN( ReadFuncArgDef );
376 }
377<ReadFuncArgType,ReadFuncArgDef>[,)>]{B}*({CCS}[*!]|{CPPC}[/!])"<" {
378 yyextra->lastDocContext=YY_START;
379 yyextra->lastDocChar=*yytext;
380 QCString text(yytext);
381 if (text.find("//")!=-1)
382 BEGIN( ReadDocLine );
383 else
384 BEGIN( ReadDocBlock );
385 }
386<ReadFuncArgType,ReadFuncArgDef>[,)>] {
387 if (*yytext==')' && yyextra->curArgTypeName.stripWhiteSpace().isEmpty())
388 {
389 yyextra->curArgTypeName+=*yytext;
390 BEGIN(FuncQual);
391 }
392 else
393 {
394 yyextra->curArgTypeName=removeRedundantWhiteSpace(yyextra->curArgTypeName);
395 yyextra->curArgDefValue=yyextra->curArgDefValue.stripWhiteSpace();
396 //printf("curArgType='%s' curArgDefVal='%s'\n",qPrint(yyextra->curArgTypeName),qPrint(yyextra->curArgDefValue));
397 int l = static_cast<int>(yyextra->curArgTypeName.length());
398 if (l>0)
399 {
400 int i=l-1;
401 while (i>=0 && (isspace((uint8_t)yyextra->curArgTypeName.at(i)) || yyextra->curArgTypeName.at(i)=='.')) i--;
402 while (i>=0 && (isId(yyextra->curArgTypeName.at(i)) || yyextra->curArgTypeName.at(i)=='$')) i--;
403 Argument a;
404 a.attrib = yyextra->curArgAttrib;
405 a.typeConstraint = yyextra->curTypeConstraint.stripWhiteSpace();
406 //printf("a->type=%s a->name=%s i=%d l=%d\n",
407 // qPrint(a->type),qPrint(a->name),i,l);
408 a.array.clear();
409 if (i==l-1 && yyextra->curArgTypeName.at(i)==')') // function argument
410 {
411 int bi=yyextra->curArgTypeName.find('(');
412 int fi=bi-1;
413 //printf("func arg fi=%d\n",fi);
414 while (fi>=0 && (isId(yyextra->curArgTypeName.at(fi)) || yyextra->curArgTypeName.at(fi)==':')) fi--;
415 if (fi>=0)
416 {
417 a.type = yyextra->curArgTypeName.left(fi+1);
418 a.name = yyextra->curArgTypeName.mid(fi+1,bi-fi-1).stripWhiteSpace();
419 a.array = yyextra->curArgTypeName.right(l-bi);
420 }
421 else
422 {
423 a.type = yyextra->curArgTypeName;
424 }
425 }
426 else if (i>=0 && yyextra->curArgTypeName.at(i)!=':')
427 { // type contains a name
428 a.type = removeRedundantWhiteSpace(yyextra->curArgTypeName.left(i+1)).stripWhiteSpace();
429 a.name = yyextra->curArgTypeName.right(l-i-1).stripWhiteSpace();
430
431 // if the type becomes a type specifier only then we make a mistake
432 // and need to correct it to avoid seeing a nameless parameter
433 // "struct A" as a parameter with type "struct" and name "A".
434 int sv=0;
435 if (a.type.startsWith("const ")) sv=6;
436 else if (a.type.startsWith("volatile ")) sv=9;
437
438 if (a.type.mid(sv)=="struct" ||
439 a.type.mid(sv)=="union" ||
440 a.type.mid(sv)=="class" ||
441 a.type.mid(sv)=="typename" ||
442 a.type=="const" ||
443 a.type=="volatile" ||
445 )
446 {
447 a.type = a.type + " " + a.name;
448 a.name.clear();
449 }
450 //printf(" --> a->type='%s' a->name='%s'\n",qPrint(a->type),qPrint(a->name));
451 }
452 else // assume only the type was specified, try to determine name later
453 {
454 a.type = removeRedundantWhiteSpace(yyextra->curArgTypeName);
455 }
456 if (!a.type.isEmpty() && a.type.at(0)=='$') // typeless PHP name?
457 {
458 a.name = a.type;
459 a.type = "";
460 }
461 a.array += removeRedundantWhiteSpace(yyextra->curArgArray);
462 //printf("array=%s\n",qPrint(a->array));
463 size_t alen = a.array.length();
464 if (alen>2 && a.array.at(0)=='(' &&
465 a.array.at(alen-1)==')') // fix-up for int *(a[10])
466 {
467 i=a.array.find('[')-1;
468 a.array = a.array.mid(1,alen-2);
469 if (i>0 && a.name.isEmpty())
470 {
471 a.name = a.array.left(i).stripWhiteSpace();
472 a.array = a.array.mid(i);
473 }
474 }
475 a.defval = yyextra->curArgDefValue;
476 //printf("a->type=%s a->name=%s a->defval=\"%s\"\n",qPrint(a->type),qPrint(a->name),qPrint(a->defval));
477 a.docs = yyextra->curArgDocs.stripWhiteSpace();
478 //printf("Argument '%s' '%s' adding docs='%s'\n",qPrint(a->type),qPrint(a->name),qPrint(a->docs));
479 yyextra->argList->push_back(a);
480 }
481 yyextra->curArgAttrib.clear();
482 yyextra->curArgTypeName.clear();
483 yyextra->curArgDefValue.clear();
484 yyextra->curArgArray.clear();
485 yyextra->curArgDocs.clear();
486 yyextra->curTypeConstraint.clear();
487 if (*yytext==')')
488 {
489 BEGIN(FuncQual);
490 //printf(">>> end of argument list\n");
491 }
492 else
493 {
494 BEGIN( ReadFuncArgType );
495 }
496 }
497 }
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: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:579
bool isId(int c)
Definition util.h:208
498<ReadFuncArgType,ReadFuncArgPtr>"extends" {
499 if (yyextra->lang!=SrcLangExt::Java)
500 {
501 REJECT;
502 }
503 else
504 {
505 yyextra->curTypeConstraint.clear();
506 yyextra->lastExtendsContext=YY_START;
507 BEGIN(ReadTypeConstraint);
508 }
509 }
510<ReadFuncArgType,ReadFuncArgPtr>"$"?{ID} {
511 QCString name(yytext);
512 if (YY_START==ReadFuncArgType && yyextra->curArgArray=="[]") // Java style array
513 {
514 yyextra->curArgTypeName+=" []";
515 yyextra->curArgArray.clear();
516 }
517 //printf("resolveName '%s'->'%s'\n",yytext,qPrint(name));
518 yyextra->curArgTypeName+=name;
519 }
520<ReadFuncArgType,ReadFuncArgPtr>. {
521 yyextra->curArgTypeName+=*yytext;
522 }
523
524<ReadFuncArgDef,CopyArgString>"<="|"->"|">="|">>"|"<<" {
525 yyextra->curArgDefValue+=yytext;
526 }
527<ReadFuncArgDef,CopyArgString,CopyRawString>. {
528 yyextra->curArgDefValue+=*yytext;
529 }
530<CopyArgRound,CopyArgRound2,CopyArgSquare,CopyArgSharp,CopyArgCurly>{ID} {
531 *yyextra->copyArgValue+=yytext;
532 }
533<CopyArgRound,CopyArgRound2,CopyArgSquare,CopyArgSharp,CopyArgCurly>. {
534 *yyextra->copyArgValue += *yytext;
535 }
536<ReadTypeConstraint>[,)>] {
537 unput(*yytext);
538 BEGIN(yyextra->lastExtendsContext);
539 }
540<ReadTypeConstraint>. {
541 yyextra->curTypeConstraint+=yytext;
542 }
543<ReadTypeConstraint>\n {
544 yyextra->curTypeConstraint+=' ';
545 }
546<FuncQual>"const" {
547 yyextra->argList->setConstSpecifier(TRUE);
548 }
#define TRUE
Definition qcstring.h:37
549<FuncQual>"volatile" {
550 yyextra->argList->setVolatileSpecifier(TRUE);
551 }
552<FuncQual>"override" {
553 }
554<FuncQual>"&" {
555 yyextra->argList->setRefQualifier(RefQualifierType::LValue);
556 }
557<FuncQual>"&&" {
558 yyextra->argList->setRefQualifier(RefQualifierType::RValue);
559 }
560<FuncQual,TrailingReturn>"="{B}*"0" {
561 yyextra->argList->setPureSpecifier(TRUE);
562 BEGIN(FuncQual);
563 }
564<FuncQual>"->" { // C++11 trailing return type
565 yyextra->argList->setTrailingReturnType(QCString(" -> "));
566 BEGIN(TrailingReturn);
567 }
568<TrailingReturn>{B}/("final"|"override"){B}* {
569 unput(*yytext);
570 BEGIN(FuncQual);
571 }
572<TrailingReturn>. {
573 yyextra->argList->setTrailingReturnType(yyextra->argList->trailingReturnType()+yytext);
574 }
575<TrailingReturn>\n {
576 yyextra->argList->setTrailingReturnType(yyextra->argList->trailingReturnType()+yytext);
577 }
578<FuncQual>")"{B}*"["[^]]*"]" { // for functions returning a pointer to an array,
579 // i.e. ")[]" in "int (*f(int))[4]" with argsString="(int))[4]"
580 yyextra->extraTypeChars=yytext;
581 }
582<ReadDocBlock>[^\*\n]+ {
583 yyextra->curArgDocs+=yytext;
584 }
585<ReadDocLine>[^\n]+ {
586 yyextra->curArgDocs+=yytext;
587 }
588<ReadDocBlock>{CCE} {
589 if (yyextra->lastDocChar!=0)
590 unput(yyextra->lastDocChar);
591 BEGIN(yyextra->lastDocContext);
592 }
593<ReadDocLine>\n {
594 if (yyextra->lastDocChar!=0)
595 unput(yyextra->lastDocChar);
596 BEGIN(yyextra->lastDocContext);
597 }
598<ReadDocBlock>\n {
599 yyextra->curArgDocs+=*yytext;
600 }
601<ReadDocBlock>. {
602 yyextra->curArgDocs+=*yytext;
603 }
604<*>({CCS}[*!]|{CPPC}[/!])("<"?) {
605 yyextra->lastDocContext=YY_START;
606 yyextra->lastDocChar=0;
607 if (yytext[1]=='/')
608 BEGIN( ReadDocLine );
609 else
610 BEGIN( ReadDocBlock );
611 }
612<*>\n
613<*>.
614
615%%
616
617/* ----------------------------------------------------------------------------
618 */
619
620static int yyread(yyscan_t yyscanner,char *buf,int max_size)
621{
622 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
623 int c=0;
624 while( c < max_size && yyextra->inputString[yyextra->inputPosition] )
625 {
626 *buf = yyextra->inputString[yyextra->inputPosition++] ;
627 c++; buf++;
628 }
629 return c;
630}
631
632/*
633The following code is generated using 'gperf keywords.txt'
634where keywords.txt has the following content
635
636---------------------------------
637%define class-name KeywordHash
638%define lookup-function-name find
639%readonly-tables
640%language=C++
641%%
642unsigned
643signed
644bool
645char
646char8_t
647char16_t
648char32_t
649wchar_t
650int
651short
652long
653float
654double
655int8_t
656int16_t
657int32_t
658int64_t
659intmax_t
660intptr_t
661uint8_t
662uint16_t
663uint32_t
664uint64_t
665uintmax_t
666uintptr_t
667const
668volatile
669void
670%%
671---------------------------------
672*/
673//--- begin gperf generated code ----------------------------------------------------------
674
675#define TOTAL_KEYWORDS 28
676#define MIN_WORD_LENGTH 3
677#define MAX_WORD_LENGTH 9
678#define MIN_HASH_VALUE 3
679#define MAX_HASH_VALUE 48
680/* maximum key range = 46, duplicates = 0 */
681
683{
684 private:
685 static inline size_t hash (const char *str, size_t len);
686 public:
687 static const char *find (const char *str, size_t len);
688};
689
690inline size_t KeywordHash::hash (const char *str, size_t len)
691{
692 static const unsigned char asso_values[] =
693 {
694 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
695 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
696 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
697 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
698 49, 49, 49, 49, 49, 49, 49, 49, 49, 5,
699 5, 30, 0, 49, 25, 49, 10, 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, 0, 49, 0, 5, 49,
704 15, 0, 49, 10, 49, 30, 49, 49, 0, 20,
705 0, 49, 15, 49, 5, 10, 0, 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, 49,
710 49, 49, 49, 49, 49, 49, 49, 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
720 };
721 size_t hval = len;
722
723 switch (hval)
724 {
725 default:
726 hval += asso_values[static_cast<unsigned char>(str[4])];
727 /*FALLTHROUGH*/
728 case 4:
729 hval += asso_values[static_cast<unsigned char>(str[3])];
730 /*FALLTHROUGH*/
731 case 3:
732 break;
733 }
734 return hval;
735}
736
737const char * KeywordHash::find (const char *str, size_t len)
738{
739 static const char * const wordlist[] =
740 {
741 "", "", "",
742 "int",
743 "bool",
744 "float",
745 "signed",
746 "",
747 "volatile",
748 "char",
749 "short",
750 "double",
751 "wchar_t",
752 "uint16_t",
753 "long",
754 "const",
755 "int8_t",
756 "uint8_t",
757 "char16_t",
758 "void",
759 "", "",
760 "char8_t",
761 "intptr_t",
762 "uintptr_t",
763 "", "", "",
764 "intmax_t",
765 "uintmax_t",
766 "", "",
767 "int64_t",
768 "uint64_t",
769 "", "", "",
770 "int16_t",
771 "uint32_t",
772 "", "", "",
773 "int32_t",
774 "char32_t",
775 "", "", "", "",
776 "unsigned"
777 };
778
779 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
780 {
781 size_t key = hash (str, len);
782
783 if (key <= MAX_HASH_VALUE)
784 {
785 const char *s = wordlist[key];
786
787 if (*str == *s && !qstrcmp (str + 1, s + 1))
788 return s;
789 }
790 }
791 return nullptr;
792}
793
794//--- end gperf generated code ----------------------------------------------------------
795
796/* bug_520975 */
798{
799 return KeywordHash::find(name.data(),name.length())!=nullptr;
800}
801
802/*! Converts an argument string into an ArgumentList.
803 * \param[in] lang language of the current argument list
804 * \param[in] argsString the list of Arguments.
805 * \param[out] extraTypeChars point to string to which trailing characters
806 * for complex types are written to
807 */
808
809std::unique_ptr<ArgumentList> stringToArgumentList(SrcLangExt lang, const QCString &argsString,QCString *extraTypeChars)
810{
811 std::unique_ptr<ArgumentList> al = std::make_unique<ArgumentList>();
812 if (argsString.isEmpty()) return al;
813
814 yyscan_t yyscanner;
815 defargsYY_state extra(argsString.data(),al,lang);
816 defargsYYlex_init_extra(&extra,&yyscanner);
817#ifdef FLEX_DEBUG
818 defargsYYset_debug(Debug::isFlagSet(Debug::Lex_defargs)?1:0,yyscanner);
819#endif
820 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
821 DebugLex debugLex(Debug::Lex_defargs, __FILE__, nullptr);
822
823 defargsYYrestart( nullptr, yyscanner );
824 BEGIN( Start );
825 defargsYYlex(yyscanner);
826 if (yyextra->argList->empty())
827 {
828 yyextra->argList->setNoParameters(TRUE);
829 }
830 if (extraTypeChars) *extraTypeChars=yyextra->extraTypeChars;
831 //printf("stringToArgumentList(%s) result=%s\n",argsString,qPrint(argListToString(*al)));
832 defargsYYlex_destroy(yyscanner);
833 return al;
834}
835
836#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:690
static const char * find(const char *str, size_t len)
Definition defargs.l:737
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:3992
#define MIN_WORD_LENGTH
Definition defargs.l:676
#define MAX_HASH_VALUE
Definition defargs.l:679
std::unique_ptr< ArgumentList > stringToArgumentList(SrcLangExt lang, const QCString &argsString, QCString *extraTypeChars)
Definition defargs.l:809
int qstrcmp(const char *str1, const char *str2)
Definition qcstring.h:69