Doxygen
defargs.l
浏览该文件的文档.
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
50 struct yyguts_t;
51 typedef yyguts_t *yyscan_t;
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 
70 #define YY_NO_INPUT 1
71 #define YY_NO_UNISTD_H 1
72 
73 #define USE_STATE2STRING 0
74 
75 /* -----------------------------------------------------------------
76  * state variables
77  */
78 struct defargsYY_state
79 {
80  defargsYY_state(const char *inStr,std::unique_ptr<ArgumentList> &al,SrcLangExt l)
81  : inputString(inStr), argList(al), lang(l) {}
82  const char *inputString;
83  std::unique_ptr<ArgumentList> &argList;
84  SrcLangExt lang;
85  int inputPosition = 0;
86  QCString *copyArgValue = 0;
87  QCString curArgTypeName;
88  QCString curArgDefValue;
89  QCString curArgName;
90  QCString curArgDocs;
91  QCString curArgAttrib;
92  QCString curArgArray;
93  QCString curTypeConstraint;
94  QCString extraTypeChars;
95  int argRoundCount = 0;
96  int argSquareCount = 0;
97  int argSharpCount = 0;
98  int argCurlyCount = 0;
99  int readArgContext = 0;
100  int lastDocContext = 0;
101  int lastDocChar = 0;
102  int lastExtendsContext = 0;
103  QCString delimiter;
104 };
105 
106 #if USE_STATE2STRING
107 static const char *stateToString(int state);
108 #endif
109 
110 static yy_size_t yyread(yyscan_t yyscanner,char *buf,yy_size_t max_size);
111 static bool nameIsActuallyPartOfType(QCString &name);
112 
113 /* -----------------------------------------------------------------
114  */
115 #undef YY_INPUT
116 #define YY_INPUT(buf,result,max_size) result=yyread(yyscanner,buf,max_size);
117 
118 %}
119 
120 B [ \t]
121 Bopt {B}*
122 ID [$a-z_A-Z\x80-\xFF][$a-z_A-Z0-9\x80-\xFF]*
123 RAWBEGIN (u|U|L|u8)?R\"[^ \t\(\)\\]{0,16}"("
124 RAWEND ")"[^ \t\(\)\\]{0,16}\"
125 
126  // C start comment
127 CCS "/\*"
128  // C end comment
129 CCE "*\/"
130  // Cpp comment
131 CPPC "/\/"
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  QCString text(yytext);
175  int i=text.find('"');
176  yyextra->delimiter = yytext+i+1;
177  yyextra->delimiter=yyextra->delimiter.left(yyextra->delimiter.length()-1);
178  BEGIN( CopyRawString );
179  }
180 <ReadFuncArgDef>\" {
181  yyextra->curArgDefValue+=*yytext;
182  BEGIN( CopyArgString );
183  }
184 <ReadFuncArgType>"("([^:)]+{B}*"::")*{B}*[&*\^]+{Bopt}/{ID} {
185  // function pointer as argument
186  yyextra->curArgTypeName+=yytext;
187  //yyextra->curArgTypeName=yyextra->curArgTypeName.simplifyWhiteSpace();
188  BEGIN( ReadFuncArgPtr );
189  }
190 <ReadFuncArgPtr>{ID} {
191  yyextra->curArgName=yytext;
192  }
193 <ReadFuncArgPtr>")"{B}*"(" { // function pointer
194  yyextra->curArgTypeName+=yytext;
195  //yyextra->curArgTypeName=yyextra->curArgTypeName.simplifyWhiteSpace();
196  yyextra->readArgContext = ReadFuncArgType;
197  yyextra->copyArgValue=&yyextra->curArgTypeName;
198  yyextra->argRoundCount=0;
199  BEGIN( CopyArgRound2 );
200  }
201 <ReadFuncArgPtr>")"/{B}*"[" { // pointer to fixed size array
202  yyextra->curArgTypeName+=yytext;
203  yyextra->curArgTypeName+=yyextra->curArgName;
204  //yyextra->curArgTypeName=yyextra->curArgTypeName.simplifyWhiteSpace();
205  BEGIN( ReadFuncArgType );
206  }
207 <ReadFuncArgPtr>")" { // redundant braces detected / remove them
208  int i=yyextra->curArgTypeName.findRev('('),l=yyextra->curArgTypeName.length();
209  if (i!=-1)
210  yyextra->curArgTypeName=yyextra->curArgTypeName.left(i)+
211  yyextra->curArgTypeName.right(l-i-1);
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  QCString delimiter(yytext+1);
364  delimiter=delimiter.left(delimiter.length()-1);
365  if (delimiter==yyextra->delimiter)
366  {
367  BEGIN( ReadFuncArgDef );
368  }
369  }
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=yyextra->curArgTypeName.length();
398  if (l>0)
399  {
400  int i=l-1;
401  while (i>=0 && (isspace((uchar)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.resize(0);
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.left(6)=="const ") sv=6;
436  else if (a.type.left(9)=="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  nameIsActuallyPartOfType(a.name)
443  )
444  {
445  a.type = a.type + " " + a.name;
446  a.name.resize(0);
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  int 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.resize(0);
480  yyextra->curArgTypeName.resize(0);
481  yyextra->curArgDefValue.resize(0);
482  yyextra->curArgArray.resize(0);
483  yyextra->curArgDocs.resize(0);
484  yyextra->curTypeConstraint.resize(0);
485  if (*yytext==')')
486  {
487  BEGIN(FuncQual);
488  //printf(">>> end of argument list\n");
489  }
490  else
491  {
492  BEGIN( ReadFuncArgType );
493  }
494  }
495  }
496 <ReadFuncArgType,ReadFuncArgPtr>"extends" {
497  if (yyextra->lang!=SrcLangExt_Java)
498  {
499  REJECT;
500  }
501  else
502  {
503  yyextra->curTypeConstraint.resize(0);
504  yyextra->lastExtendsContext=YY_START;
505  BEGIN(ReadTypeConstraint);
506  }
507  }
508 <ReadFuncArgType,ReadFuncArgPtr>"$"?{ID} {
509  QCString name(yytext);
510  if (YY_START==ReadFuncArgType && yyextra->curArgArray=="[]") // Java style array
511  {
512  yyextra->curArgTypeName+=" []";
513  yyextra->curArgArray.resize(0);
514  }
515  //printf("resolveName '%s'->'%s'\n",yytext,qPrint(name));
516  yyextra->curArgTypeName+=name;
517  }
518 <ReadFuncArgType,ReadFuncArgPtr>. {
519  yyextra->curArgTypeName+=*yytext;
520  }
521 
522 <ReadFuncArgDef,CopyArgString>"<="|"->"|">="|">>"|"<<" {
523  yyextra->curArgDefValue+=yytext;
524  }
525 <ReadFuncArgDef,CopyArgString,CopyRawString>. {
526  yyextra->curArgDefValue+=*yytext;
527  }
528 <CopyArgRound,CopyArgRound2,CopyArgSquare,CopyArgSharp,CopyArgCurly>{ID} {
529  *yyextra->copyArgValue+=yytext;
530  }
531 <CopyArgRound,CopyArgRound2,CopyArgSquare,CopyArgSharp,CopyArgCurly>. {
532  *yyextra->copyArgValue += *yytext;
533  }
534 <ReadTypeConstraint>[,)>] {
535  unput(*yytext);
536  BEGIN(yyextra->lastExtendsContext);
537  }
538 <ReadTypeConstraint>. {
539  yyextra->curTypeConstraint+=yytext;
540  }
541 <ReadTypeConstraint>\n {
542  yyextra->curTypeConstraint+=' ';
543  }
544 <FuncQual>"const" {
545  yyextra->argList->setConstSpecifier(TRUE);
546  }
547 <FuncQual>"volatile" {
548  yyextra->argList->setVolatileSpecifier(TRUE);
549  }
550 <FuncQual>"override" {
551  }
552 <FuncQual>"&" {
553  yyextra->argList->setRefQualifier(RefQualifierLValue);
554  }
555 <FuncQual>"&&" {
556  yyextra->argList->setRefQualifier(RefQualifierRValue);
557  }
558 <FuncQual,TrailingReturn>"="{B}*"0" {
559  yyextra->argList->setPureSpecifier(TRUE);
560  BEGIN(FuncQual);
561  }
562 <FuncQual>"->" { // C++11 trailing return type
563  yyextra->argList->setTrailingReturnType(QCString(" -> "));
564  BEGIN(TrailingReturn);
565  }
566 <TrailingReturn>{B}/("final"|"override"){B}* {
567  unput(*yytext);
568  BEGIN(FuncQual);
569  }
570 <TrailingReturn>. {
571  yyextra->argList->setTrailingReturnType(yyextra->argList->trailingReturnType()+yytext);
572  }
573 <TrailingReturn>\n {
574  yyextra->argList->setTrailingReturnType(yyextra->argList->trailingReturnType()+yytext);
575  }
576 <FuncQual>")"{B}*"["[^]]*"]" { // for functions returning a pointer to an array,
577  // i.e. ")[]" in "int (*f(int))[4]" with argsString="(int))[4]"
578  yyextra->extraTypeChars=yytext;
579  }
580 <ReadDocBlock>[^\*\n]+ {
581  yyextra->curArgDocs+=yytext;
582  }
583 <ReadDocLine>[^\n]+ {
584  yyextra->curArgDocs+=yytext;
585  }
586 <ReadDocBlock>{CCE} {
587  if (yyextra->lastDocChar!=0)
588  unput(yyextra->lastDocChar);
589  BEGIN(yyextra->lastDocContext);
590  }
591 <ReadDocLine>\n {
592  if (yyextra->lastDocChar!=0)
593  unput(yyextra->lastDocChar);
594  BEGIN(yyextra->lastDocContext);
595  }
596 <ReadDocBlock>\n {
597  yyextra->curArgDocs+=*yytext;
598  }
599 <ReadDocBlock>. {
600  yyextra->curArgDocs+=*yytext;
601  }
602 <*>({CCS}[*!]|{CPPC}[/!])("<"?) {
603  yyextra->lastDocContext=YY_START;
604  yyextra->lastDocChar=0;
605  if (yytext[1]=='/')
606  BEGIN( ReadDocLine );
607  else
608  BEGIN( ReadDocBlock );
609  }
610 <*>\n
611 <*>.
612 
613 %%
614 
615 /* ----------------------------------------------------------------------------
616  */
617 
618 static yy_size_t yyread(yyscan_t yyscanner,char *buf,yy_size_t max_size)
619 {
620  struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
621  yy_size_t c=0;
622  while( c < max_size && yyextra->inputString[yyextra->inputPosition] )
623  {
624  *buf = yyextra->inputString[yyextra->inputPosition++] ;
625  c++; buf++;
626  }
627  return c;
628 }
629 
630 /*
631 The following code is generated using 'gperf keywords.txt'
632 where keywords.txt has the following content
633 
634 ---------------------------------
635 %define class-name KeywordHash
636 %define lookup-function-name find
637 %readonly-tables
638 %language=C++
639 %%
640 unsigned
641 signed
642 bool
643 char
644 char8_t
645 char16_t
646 char32_t
647 wchar_t
648 int
649 short
650 long
651 float
652 double
653 int8_t
654 int16_t
655 int32_t
656 int64_t
657 intmax_t
658 intptr_t
659 uint8_t
660 uint16_t
661 uint32_t
662 uint64_t
663 uintmax_t
664 uintptr_t
665 const
666 volatile
667 void
668 %%
669 ---------------------------------
670 */
671 //--- begin gperf generated code ----------------------------------------------------------
672 
673 #define TOTAL_KEYWORDS 28
674 #define MIN_WORD_LENGTH 3
675 #define MAX_WORD_LENGTH 9
676 #define MIN_HASH_VALUE 3
677 #define MAX_HASH_VALUE 48
678 /* maximum key range = 46, duplicates = 0 */
679 
680 class KeywordHash
681 {
682  private:
683  static inline unsigned int hash (const char *str, unsigned int len);
684  public:
685  static const char *find (const char *str, unsigned int len);
686 };
687 
688 inline unsigned int
689 KeywordHash::hash (const char *str, unsigned int len)
690 {
691  static const unsigned char asso_values[] =
692  {
693  49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
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, 5,
698  5, 30, 0, 49, 25, 49, 10, 49, 49, 49,
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, 0, 49, 0, 5, 49,
703  15, 0, 49, 10, 49, 30, 49, 49, 0, 20,
704  0, 49, 15, 49, 5, 10, 0, 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, 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
719  };
720  unsigned int hval = len;
721 
722  switch (hval)
723  {
724  default:
725  hval += asso_values[static_cast<unsigned char>(str[4])];
726  /*FALLTHROUGH*/
727  case 4:
728  hval += asso_values[static_cast<unsigned char>(str[3])];
729  /*FALLTHROUGH*/
730  case 3:
731  break;
732  }
733  return hval;
734 }
735 
736 const char *
737 KeywordHash::find (const char *str, unsigned int 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  unsigned int 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 0;
792 }
793 
794 //--- end gperf generated code ----------------------------------------------------------
795 
796 /* bug_520975 */
797 static bool nameIsActuallyPartOfType(QCString &name)
798 {
799  return KeywordHash::find(name.data(),name.length())!=0;
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 
809 std::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(1,yyscanner);
819 #endif
820  struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
821  printlex(yy_flex_debug, TRUE, __FILE__, NULL);
822 
823  defargsYYrestart( 0, 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  printlex(yy_flex_debug, FALSE, __FILE__, NULL);
833  defargsYYlex_destroy(yyscanner);
834  return al;
835 }
836 
837 #if USE_STATE2STRING
838 #include "defargs.l.h"
839 #endif