defargs.l 18.2 KB
Newer Older
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1 2
/******************************************************************************
 *
3
 * 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
4
 *
Dimitri van Heesch's avatar
Dimitri van Heesch committed
5
 * Copyright (C) 1997-2013 by Dimitri van Heesch.
Dimitri van Heesch's avatar
Dimitri van Heesch committed
6 7 8 9 10 11 12
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation under the terms of the GNU General Public License is hereby 
 * granted. No representations are made about the suitability of this software 
 * for any purpose. It is provided "as is" without express or implied warranty.
 * See the GNU General Public License for more details.
 *
Dimitri van Heesch's avatar
Dimitri van Heesch committed
13 14
 * Documents produced by Doxygen are derivative works derived from the
 * input used in their production; they are not affected by this license.
Dimitri van Heesch's avatar
Dimitri van Heesch committed
15 16 17
 *
 */

Dimitri van Heesch's avatar
Dimitri van Heesch committed
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
/*! \file
 *  This scanner is used to convert a string into a list of function or 
 *  template arguments. Each parsed argument results in a Argument struct,
 *  that is put into an ArgumentList in declaration order.
 *  Comment blocks for arguments can also be included in the string.
 *  The argument string does not contain new-lines (except inside any
 *  comment blocks).
 *  An Argument consists of the string fields: 
 *                 type,name,default value, and documentation
 *  The Argument list as a whole can be pure, constant or volatile.
 *
 *  Examples of input strings are:
 *  \code
 *    "(int a,int b) const"
 *    "(const char *s="hello world",int=5) = 0"
 *    "<class T,class N>"
 *    "(char c,const char)"
 *  \endcode
 *
 *  Note: It is not always possible to distinguish between the name and 
 *        type of an argument. In case of doubt the name is added to the
 *        type, and the matchArgumentList in util.cpp is be used to
 *        further determine the correct separation.
 */

Dimitri van Heesch's avatar
Dimitri van Heesch committed
43 44 45 46 47 48
%{

/*
 *	includes
 */
#include <stdio.h>
49
//#include <iostream.h>
Dimitri van Heesch's avatar
Dimitri van Heesch committed
50 51 52 53 54 55 56
#include <assert.h>
#include <ctype.h>
#include <qregexp.h>

#include "defargs.h"
#include "entry.h"
#include "util.h"
57
#include "arguments.h"
58
#include "message.h"
Dimitri van Heesch's avatar
Dimitri van Heesch committed
59 60
  
#define YY_NEVER_INTERACTIVE 1
61
#define YY_NO_INPUT 1
Dimitri van Heesch's avatar
Dimitri van Heesch committed
62 63
  
/* -----------------------------------------------------------------
Dimitri van Heesch's avatar
Dimitri van Heesch committed
64
 *	state variables
Dimitri van Heesch's avatar
Dimitri van Heesch committed
65
 */
Dimitri van Heesch's avatar
Dimitri van Heesch committed
66 67 68 69 70 71 72 73 74 75
static const char      *g_inputString;
static int	        g_inputPosition;
static ArgumentList    *g_argList;
static QCString        *g_copyArgValue;
static QCString         g_curArgTypeName;
static QCString         g_curArgDefValue;
static QCString		g_curArgName;
static QCString		g_curArgDocs;
static QCString		g_curArgAttrib;
static QCString		g_curArgArray;
76
static QCString		g_extraTypeChars;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
77 78 79 80 81 82
static int              g_argRoundCount;
static int              g_argSharpCount;
static int              g_argCurlyCount;
static int              g_readArgContext;
static int              g_lastDocContext;
static int              g_lastDocChar;
83
static QCString         g_delimiter;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
84 85 86 87 88 89 90 91 92

/* -----------------------------------------------------------------
 */
#undef	YY_INPUT
#define	YY_INPUT(buf,result,max_size) result=yyread(buf,max_size);

static int yyread(char *buf,int max_size)
{
    int c=0;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
93
    while( c < max_size && g_inputString[g_inputPosition] )
Dimitri van Heesch's avatar
Dimitri van Heesch committed
94
    {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
95
	*buf = g_inputString[g_inputPosition++] ;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
96 97 98 99 100 101 102 103
	c++; buf++;
    }
    return c;
}

%}

B       [ \t]
104
ID	[a-z_A-Z\x80-\xFF][a-z_A-Z0-9\x80-\xFF]*
105 106
RAWBEGIN  (u|U|L|u8)?R\"[^ \t\(\)\\]{0,16}"("
RAWEND    ")"[^ \t\(\)\\]{0,16}\"
Dimitri van Heesch's avatar
Dimitri van Heesch committed
107

108 109
%option noyywrap

Dimitri van Heesch's avatar
Dimitri van Heesch committed
110 111
%x      Start
%x      CopyArgString
112
%x      CopyRawString
Dimitri van Heesch's avatar
Dimitri van Heesch committed
113 114 115 116 117 118 119 120
%x	CopyArgRound
%x	CopyArgRound2
%x	CopyArgSharp
%x	CopyArgCurly
%x	ReadFuncArgType
%x	ReadFuncArgDef
%x	ReadFuncArgPtr
%x	FuncQual
Dimitri van Heesch's avatar
Dimitri van Heesch committed
121 122
%x	ReadDocBlock
%x	ReadDocLine
123
%x      TrailingReturn
Dimitri van Heesch's avatar
Dimitri van Heesch committed
124 125 126 127 128 129 130


%%

<Start>[<(]				{ BEGIN(ReadFuncArgType); }

<ReadFuncArgType>{B}*			{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
131
  					  g_curArgTypeName+=" ";
Dimitri van Heesch's avatar
Dimitri van Heesch committed
132
  					}
133
<ReadFuncArgType>"["[^\]]*"]"		{ 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
134 135 136 137 138 139 140 141
					  if (g_curArgTypeName.stripWhiteSpace().isEmpty())
					  {
					    g_curArgAttrib=yytext; // for M$-IDL
					  }
					  else // array type
					  {
					    g_curArgArray+=yytext;
					  }
142
					}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
143 144 145
<ReadFuncArgDef>"'"\\[0-7]{1,3}"'"	{ g_curArgDefValue+=yytext; }
<ReadFuncArgDef>"'"\\."'"		{ g_curArgDefValue+=yytext; }
<ReadFuncArgDef>"'"."'"			{ g_curArgDefValue+=yytext; }
146 147 148 149 150 151 152
<ReadFuncArgDef>{RAWBEGIN}              { g_curArgDefValue+=yytext; 
                                          QCString text=yytext;
                                          int i=text.find('"');
                                          g_delimiter = yytext+i+1;
                                          g_delimiter=g_delimiter.left(g_delimiter.length()-1);
                                          BEGIN( CopyRawString );
                                        }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
153
<ReadFuncArgDef>\"			{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
154
  					  g_curArgDefValue+=*yytext;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
155 156
  					  BEGIN( CopyArgString );
  					}
157
<ReadFuncArgType>"("([^:)]+{B}*"::")*{B}*[&*\^]+{B}*/{ID} { 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
158
  					  // function pointer as argument
Dimitri van Heesch's avatar
Dimitri van Heesch committed
159 160
					  g_curArgTypeName+=yytext;
					  //g_curArgTypeName=g_curArgTypeName.simplifyWhiteSpace();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
161 162 163
					  BEGIN( ReadFuncArgPtr );
  					}
<ReadFuncArgPtr>{ID}			{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
164
					  g_curArgName=yytext;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
165
  					}
166
<ReadFuncArgPtr>")"{B}*"("		{ // function pointer
Dimitri van Heesch's avatar
Dimitri van Heesch committed
167 168 169 170 171
					  g_curArgTypeName+=yytext;
					  //g_curArgTypeName=g_curArgTypeName.simplifyWhiteSpace();
					  g_readArgContext = ReadFuncArgType;
					  g_copyArgValue=&g_curArgTypeName;
					  g_argRoundCount=0;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
172 173
					  BEGIN( CopyArgRound2 );
					}
174 175
<ReadFuncArgPtr>")"/{B}*"["		{ // pointer to fixed size array
					  g_curArgTypeName+=yytext;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
176
					  g_curArgTypeName+=g_curArgName;
177 178 179
					  //g_curArgTypeName=g_curArgTypeName.simplifyWhiteSpace();
					  BEGIN( ReadFuncArgType );
					}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
180
<ReadFuncArgPtr>")"			{ // redundant braces detected / remove them
Dimitri van Heesch's avatar
Dimitri van Heesch committed
181
					  int i=g_curArgTypeName.findRev('('),l=g_curArgTypeName.length();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
182
					  if (i!=-1)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
183 184 185
					    g_curArgTypeName=g_curArgTypeName.left(i)+
					                   g_curArgTypeName.right(l-i-1);
					  g_curArgTypeName+=g_curArgName;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
186 187
					  BEGIN( ReadFuncArgType );
					}
188 189 190
<ReadFuncArgType>"<="|">="|"->"|">>"|"<<" { // handle operators in defargs
  					  g_curArgTypeName+=yytext;
  					}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
191 192 193
<ReadFuncArgType,ReadFuncArgDef>[({<]	{	 
					  if (YY_START==ReadFuncArgType)
					  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
194 195
					    g_curArgTypeName+=*yytext;
					    g_copyArgValue=&g_curArgTypeName;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
196 197 198
					  }
					  else // YY_START==ReadFuncArgDef
					  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
199 200
					    g_curArgDefValue+=*yytext;
					    g_copyArgValue=&g_curArgDefValue;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
201
					  }
202
					  g_readArgContext = YY_START; 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
203 204
					  if (*yytext=='(')
					  {
205
					    g_argRoundCount=0; 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
206 207 208 209
					    BEGIN( CopyArgRound ); 
					  }
					  else if (*yytext=='{')
					  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
210
					    g_argCurlyCount=0; 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
211 212 213 214
					    BEGIN( CopyArgCurly ); 
					  }
					  else // yytext=='<'
					  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
215
					    g_argSharpCount=0; 
216
					    g_argRoundCount=0; 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
217 218 219 220
					    BEGIN( CopyArgSharp ); 
					  }
					}
<CopyArgRound,CopyArgRound2>"("		{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
221 222
  					  g_argRoundCount++;
					  *g_copyArgValue += *yytext;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
223
  					}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
224 225
<CopyArgRound,CopyArgRound2>")"({B}*{ID})* {
					  *g_copyArgValue += yytext;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
226
					  if (g_argRoundCount>0) 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
227
					  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
228
					    g_argRoundCount--;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
229 230 231 232 233
					  }
					  else 
					  {
					    if (YY_START==CopyArgRound2)
					    {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
234
					      *g_copyArgValue+=" "+g_curArgName;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
235
					    }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
236
					    BEGIN( g_readArgContext );
Dimitri van Heesch's avatar
Dimitri van Heesch committed
237 238
					  }
  					}
239 240 241 242 243
<CopyArgRound>")"/{B}*                  {
					  *g_copyArgValue += *yytext;
					  if (g_argRoundCount>0) g_argRoundCount--;
					  else BEGIN( g_readArgContext );
                                        }
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
<CopyArgSharp>"<<"                      {
                                          if (g_argRoundCount>0)
                                          {
					    *g_copyArgValue += yytext;
                                          }
                                          else
                                          {
                                            REJECT;
                                          }
                                        }
<CopyArgSharp>">>"                      {
                                          if (g_argRoundCount>0)
                                          {
					    *g_copyArgValue += yytext;
                                          }
                                          else
                                          {
                                            REJECT;
                                          }
                                        }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
264
<CopyArgSharp>"<"			{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
265 266
  					  g_argSharpCount++;
					  *g_copyArgValue += *yytext;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
267 268
  					}
<CopyArgSharp>">"			{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
269 270 271
					  *g_copyArgValue += *yytext;
					  if (g_argSharpCount>0) g_argSharpCount--;
					  else BEGIN( g_readArgContext );
Dimitri van Heesch's avatar
Dimitri van Heesch committed
272
  					}
273 274 275 276 277 278 279 280
<CopyArgSharp>"("                       {
                                          g_argRoundCount++;
					  *g_copyArgValue += *yytext;
                                        }
<CopyArgSharp>")"                       {
                                          g_argRoundCount--;
					  *g_copyArgValue += *yytext;
                                        }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
281
<CopyArgCurly>"{"			{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
282 283
  					  g_argCurlyCount++;
					  *g_copyArgValue += *yytext;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
284
  					}
285
<CopyArgCurly>"}"			{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
286 287 288
					  *g_copyArgValue += *yytext;
					  if (g_argCurlyCount>0) g_argCurlyCount--;
					  else BEGIN( g_readArgContext );
Dimitri van Heesch's avatar
Dimitri van Heesch committed
289 290
  					}
<CopyArgString>\\.			{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
291
					  g_curArgDefValue+=yytext;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
292
  					}
293 294 295 296 297 298 299 300 301
<CopyRawString>{RAWEND}                 {
					  g_curArgDefValue+=yytext;
                                          QCString delimiter = yytext+1;
                                          delimiter=delimiter.left(delimiter.length()-1);
                                          if (delimiter==g_delimiter)
                                          {
					    BEGIN( ReadFuncArgDef );
                                          }
                                        }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
302
<CopyArgString>\"			{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
303
					  g_curArgDefValue+=*yytext;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
304 305 306 307 308
					  BEGIN( ReadFuncArgDef );
  					}
<ReadFuncArgType>"="			{
					  BEGIN( ReadFuncArgDef );
  					}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
309 310 311 312 313 314 315 316 317
<ReadFuncArgType,ReadFuncArgDef>[,)>]{B}*("/*"[*!]|"//"[/!])"<" {
					  g_lastDocContext=YY_START;
					  g_lastDocChar=*yytext;  
					  QCString text=yytext;
					  if (text.find("//")!=-1)
					    BEGIN( ReadDocLine );
					  else
					    BEGIN( ReadDocBlock );
  					}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
318
<ReadFuncArgType,ReadFuncArgDef>[,)>]	{
319 320 321
  					  if (*yytext==')' && g_curArgTypeName.stripWhiteSpace().isEmpty())
					  {
					    g_curArgTypeName+=*yytext;
322
					    BEGIN(FuncQual);
323 324
					  }
					  else
Dimitri van Heesch's avatar
Dimitri van Heesch committed
325
					  {
326 327 328 329 330
					    g_curArgTypeName=removeRedundantWhiteSpace(g_curArgTypeName);
					    g_curArgDefValue=g_curArgDefValue.stripWhiteSpace();
					    //printf("curArgType=`%s' curArgDefVal=`%s'\n",g_curArgTypeName.data(),g_curArgDefValue.data());
					    int l=g_curArgTypeName.length();
					    if (l>0)
331
					    {
332
					      int i=l-1;
333
					      while (i>=0 && (isspace((uchar)g_curArgTypeName.at(i)) || g_curArgTypeName.at(i)=='.')) i--;
334
					      while (i>=0 && (isId(g_curArgTypeName.at(i)) || g_curArgTypeName.at(i)=='$')) i--;
335 336 337
					      Argument *a = new Argument; 
					      a->attrib = g_curArgAttrib.copy();
					      //printf("a->type=%s a->name=%s i=%d l=%d\n",
338
					      //        a->type.data(),a->name.data(),i,l);
339 340
					      a->array.resize(0);
					      if (i==l-1 && g_curArgTypeName.at(i)==')') // function argument
341
					      {
342 343 344 345 346 347 348
						int bi=g_curArgTypeName.find('(');
						int fi=bi-1;
						//printf("func arg fi=%d\n",fi);
						while (fi>=0 && isId(g_curArgTypeName.at(fi))) fi--;
						if (fi>=0)
						{
						  a->type  = g_curArgTypeName.left(fi+1);
349
						  a->name  = g_curArgTypeName.mid(fi+1,bi-fi-1).stripWhiteSpace();
350 351 352 353 354 355 356 357 358
						  a->array = g_curArgTypeName.right(l-bi);
						}
						else
						{
						  a->type = g_curArgTypeName;
						}
					      }
					      else if (i>=0 && g_curArgTypeName.at(i)!=':')
					      { // type contains a name
359
						a->type = removeRedundantWhiteSpace(g_curArgTypeName.left(i+1)).stripWhiteSpace();
360
						a->name = g_curArgTypeName.right(l-i-1).stripWhiteSpace();
361 362 363 364 365

						// if the type becomes a type specifier only then we make a mistake
						// and need to correct it to avoid seeing a nameless parameter
						// "struct A" as a parameter with type "struct" and name "A".
						int sv=0;
366 367 368 369 370 371 372 373 374 375
						if      (a->type.left(6)=="const ")    sv=6;
						else if (a->type.left(9)=="volatile ") sv=9;

						if (a->type.mid(sv)=="struct"    ||
						    a->type.mid(sv)=="union"     ||
						    a->type.mid(sv)=="class"     ||
						    a->type.mid(sv)=="typename"  ||
						    a->type=="const"             ||
						    a->type=="volatile"
						   )
376 377 378 379
						{ 
						  a->type = a->type + " " + a->name;
						  a->name.resize(0);
						}
380
						//printf(" --> a->type='%s'\n",a->type.data());
381
					      }
382
					      else // assume only the type was specified, try to determine name later 
383
					      {
384
						a->type = removeRedundantWhiteSpace(g_curArgTypeName);  
385
					      }
386 387 388 389 390
                                              if (!a->type.isEmpty() && a->type.at(0)=='$') // typeless PHP name?
                                              {
                                                a->name = a->type;
                                                a->type = "";
                                              }
391
					      a->array  += removeRedundantWhiteSpace(g_curArgArray);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
392 393 394 395 396 397 398 399 400
					      //printf("array=%s\n",a->array.data());
					      int alen = a->array.length();
					      if (alen>2 && a->array.at(0)=='(' && 
						            a->array.at(alen-1)==')') // fix-up for int *(a[10])
					      {
						int i=a->array.find('[')-1;
						a->array = a->array.mid(1,alen-2);
						if (i>0 && a->name.isEmpty())
						{
401
						  a->name  = a->array.left(i).stripWhiteSpace();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
402 403 404
						  a->array = a->array.mid(i);
						}
					      }
405
					      a->defval = g_curArgDefValue.copy();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
406
					      //printf("a->type=%s a->name=%s a->defval=\"%s\"\n",a->type.data(),a->name.data(),a->defval.data());
407 408 409
					      a->docs   = g_curArgDocs.stripWhiteSpace();
					      //printf("Argument `%s' `%s' adding docs=`%s'\n",a->type.data(),a->name.data(),a->docs.data());
					      g_argList->append(a);
410
					    }
411 412 413 414 415 416 417 418 419
					    g_curArgAttrib.resize(0);
					    g_curArgTypeName.resize(0);
					    g_curArgDefValue.resize(0);
					    g_curArgArray.resize(0);
					    g_curArgDocs.resize(0);
					    if (*yytext==')')
					    {
					      BEGIN(FuncQual);
					      //printf(">>> end of argument list\n");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
420
					    }
421
					    else
Dimitri van Heesch's avatar
Dimitri van Heesch committed
422
					    {
423
					      BEGIN( ReadFuncArgType );
Dimitri van Heesch's avatar
Dimitri van Heesch committed
424 425 426
					    }
					  }
  					}
427
<ReadFuncArgType,ReadFuncArgPtr>"$"?{ID} { 
428
  					  QCString name=yytext; //resolveDefines(yytext);
429 430 431 432 433
					  if (YY_START==ReadFuncArgType && g_curArgArray=="[]") // Java style array
					  {
					    g_curArgTypeName+=" []";
					    g_curArgArray.resize(0);
					  }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
434
					  //printf("resolveName `%s'->`%s'\n",yytext,name.data());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
435
  					  g_curArgTypeName+=name;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
436 437
					}
<ReadFuncArgType,ReadFuncArgPtr>.	{ 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
438
  					  g_curArgTypeName+=*yytext;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
439
					}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
440

Dimitri van Heesch's avatar
Dimitri van Heesch committed
441
<ReadFuncArgDef,CopyArgString>"<="|"->"|">="|">>"|"<<"	{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
442 443
  					  g_curArgDefValue+=yytext;
  					}
444
<ReadFuncArgDef,CopyArgString,CopyRawString>.		{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
445
					  g_curArgDefValue+=*yytext;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
446 447
  					}
<CopyArgRound,CopyArgRound2,CopyArgSharp,CopyArgCurly>{ID}  {
448
  					  QCString name=yytext; //resolveDefines(yytext);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
449
					  *g_copyArgValue+=name;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
450 451
					}
<CopyArgRound,CopyArgRound2,CopyArgSharp,CopyArgCurly>.  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
452
					  *g_copyArgValue += *yytext;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
453 454
					}
<FuncQual>"const"		       	{ 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
455
					  g_argList->constSpecifier=TRUE;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
456 457
					}
<FuncQual>"volatile"		    	{ 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
458
					  g_argList->volatileSpecifier=TRUE;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
459
					}
460
<FuncQual,TrailingReturn>"="{B}*"0"  	{ 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
461
					  g_argList->pureSpecifier=TRUE;
462
                                          BEGIN(FuncQual);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
463
					}
464 465 466 467 468 469 470 471 472 473 474 475 476 477
<FuncQual>"->"                          { // C++11 trailing return type
                                          g_argList->trailingReturnType=" -> ";
                                          BEGIN(TrailingReturn);
                                        }
<TrailingReturn>{B}/("final"|"override"){B}*  {
                                          unput(*yytext);
                                          BEGIN(FuncQual);
                                        }
<TrailingReturn>.                       {
                                          g_argList->trailingReturnType+=yytext;
                                        }
<TrailingReturn>\n                      {
                                          g_argList->trailingReturnType+=yytext;
                                        }
478 479 480 481
<FuncQual>")"{B}*"["[^]]*"]"		{ // for functions returning a pointer to an array, 
                                          // i.e. ")[]" in "int (*f(int))[4]" with argsString="(int))[4]"
  					  g_extraTypeChars=yytext;
  					}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
482 483 484 485 486 487 488 489 490 491
<ReadDocBlock>[^\*\n]+			{
  					  g_curArgDocs+=yytext;
  					}
<ReadDocLine>[^\n]+			{
  					  g_curArgDocs+=yytext;
  					}
<ReadDocBlock>"*/"			{ 
  					  if (g_lastDocChar!=0)
					    unput(g_lastDocChar);
  					  BEGIN(g_lastDocContext); 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
492
					}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511
<ReadDocLine>\n				{
  					  if (g_lastDocChar!=0)
					    unput(g_lastDocChar);
					  BEGIN(g_lastDocContext);
  					}
<ReadDocBlock>\n			{
  					  g_curArgDocs+=*yytext;
  					}
<ReadDocBlock>.				{
  					  g_curArgDocs+=*yytext;
  					}
<*>("/*"[*!]|"//"[/!])("<"?)		{
  					  g_lastDocContext=YY_START;
					  g_lastDocChar=0;  
					  if (yytext[1]=='/')
					    BEGIN( ReadDocLine );
					  else
  					    BEGIN( ReadDocBlock );
  					}
512
<*>\n
Dimitri van Heesch's avatar
Dimitri van Heesch committed
513 514 515 516 517 518 519
<*>.

%%

/* ----------------------------------------------------------------------------
 */

Dimitri van Heesch's avatar
Dimitri van Heesch committed
520
/*! Converts an argument string into an ArgumentList.
521 522 523 524
 *  \param[in] argsString the list of Arguments.
 *  \param[out] al a reference to resulting argument list pointer.
 *  \param[out] extraTypeChars point to string to which trailing characters 
 *              for complex types are written to
Dimitri van Heesch's avatar
Dimitri van Heesch committed
525 526
 */
 
527
void stringToArgumentList(const char *argsString,ArgumentList* al,QCString *extraTypeChars)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
528 529
{
  if (al==0) return; 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
530
  if (argsString==0) return;
531
  printlex(yy_flex_debug, TRUE, __FILE__, NULL);
532 533 534 535 536

  g_copyArgValue=0;
  g_curArgDocs.resize(0);
  g_curArgAttrib.resize(0);
  g_curArgArray.resize(0);
537
  g_extraTypeChars.resize(0);
538 539 540 541 542
  g_argRoundCount = 0;
  g_argSharpCount = 0;
  g_argCurlyCount = 0;
  g_lastDocChar = 0;

Dimitri van Heesch's avatar
Dimitri van Heesch committed
543 544 545 546 547 548
  g_inputString   = argsString;
  g_inputPosition = 0;
  g_curArgTypeName.resize(0);
  g_curArgDefValue.resize(0);
  g_curArgName.resize(0);
  g_argList = al;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
549 550 551
  defargsYYrestart( defargsYYin );
  BEGIN( Start );
  defargsYYlex();
552
  if (extraTypeChars) *extraTypeChars=g_extraTypeChars;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
553
  //printf("stringToArgumentList(%s) result=%s\n",argsString,argListToString(al).data());
554
  printlex(yy_flex_debug, FALSE, __FILE__, NULL);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
555 556
}

557
#if !defined(YY_FLEX_SUBMINOR_VERSION) 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
558 559 560
extern "C" { // some bogus code to keep the compiler happy
  void defargsYYdummy() { yy_flex_realloc(0,0); } 
}
561 562
#endif