42%option never-interactive
43%option prefix="defargsYY"
45%option extra-type="struct defargsYY_state *"
49#define YY_TYPEDEF_YY_SCANNER_T
72#define YY_NO_UNISTD_H 1
113#define YY_INPUT(buf,result,max_size) result=yyread(yyscanner,buf,max_size);
117#define LEX_NO_INPUT_FILENAME
This is an alternative implementation of QCString.
static int yyread(yyscan_t yyscanner, char *buf, int max_size)
static const char * stateToString(int state)
static bool nameIsActuallyPartOfType(QCString &name)
static const char * getLexerFILE()
QCString curTypeConstraint
std::unique_ptr< ArgumentList > & argList
defargsYY_state(const char *inStr, std::unique_ptr< ArgumentList > &al, SrcLangExt l)
A bunch of utility functions.
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}\"
157<Start>[<(] { BEGIN(ReadFuncArgType); }
159<ReadFuncArgType>{B}* {
160 yyextra->curArgTypeName+=
" ";
162<ReadFuncArgType,ReadFuncArgPtr>"["[^\]]*"]" {
163 if (YY_START==ReadFuncArgPtr)
165 yyextra->curArgTypeName+=yytext;
167 else if (yyextra->curArgTypeName.stripWhiteSpace().isEmpty())
169 yyextra->curArgAttrib=yytext;
173 yyextra->curArgArray+=yytext;
176<ReadFuncArgDef>"'"\\[0-7]{1,3}"'" { yyextra->curArgDefValue+=yytext; }
177<ReadFuncArgDef>"'"\\."'" { yyextra->curArgDefValue+=yytext; }
178<ReadFuncArgDef>"'"."'" { yyextra->curArgDefValue+=yytext; }
179<ReadFuncArgDef>{RAWBEGIN} { yyextra->curArgDefValue+=yytext;
181 BEGIN( CopyRawString );
QCString extractBeginRawStringDelimiter(const char *rawStart)
184 yyextra->curArgDefValue+=*yytext;
185 BEGIN( CopyArgString );
187<ReadFuncArgType>"("([^:)]+{B}*"::")*{B}*[&*\^]+{Bopt}/{ID} {
189 yyextra->curArgTypeName+=yytext;
191 BEGIN( ReadFuncArgPtr );
193<ReadFuncArgPtr>{ID} {
194 yyextra->curArgName=yytext;
196<ReadFuncArgPtr>")"{B}*"(" {
197 yyextra->curArgTypeName+=yytext;
199 yyextra->readArgContext = ReadFuncArgType;
200 yyextra->copyArgValue=&yyextra->curArgTypeName;
201 yyextra->argRoundCount=0;
202 BEGIN( CopyArgRound2 );
204<ReadFuncArgPtr>")"/{B}*"[" {
205 yyextra->curArgTypeName+=yytext;
206 yyextra->curArgTypeName+=yyextra->curArgName;
208 BEGIN( ReadFuncArgType );
211 int i=yyextra->curArgTypeName.findRev(
'(');
212 int l=
static_cast<int>(yyextra->curArgTypeName.length());
215 yyextra->curArgTypeName=yyextra->curArgTypeName.left(i)+
216 yyextra->curArgTypeName.right(l-i-1);
218 yyextra->curArgTypeName+=yyextra->curArgName;
219 BEGIN( ReadFuncArgType );
221<ReadFuncArgType>"<="|">="|"->"|">>"|"<<" {
222 yyextra->curArgTypeName+=yytext;
224<ReadFuncArgType,ReadFuncArgDef>[({<\[] {
225 if (YY_START==ReadFuncArgType)
227 yyextra->curArgTypeName+=*yytext;
228 yyextra->copyArgValue=&yyextra->curArgTypeName;
232 yyextra->curArgDefValue+=*yytext;
233 yyextra->copyArgValue=&yyextra->curArgDefValue;
235 yyextra->readArgContext = YY_START;
238 yyextra->argRoundCount=0;
239 BEGIN( CopyArgRound );
241 else if (*yytext==
'[')
243 yyextra->argSquareCount=0;
244 BEGIN( CopyArgSquare );
246 else if (*yytext==
'{')
248 yyextra->argCurlyCount=0;
249 BEGIN( CopyArgCurly );
253 yyextra->argSharpCount=0;
254 yyextra->argRoundCount=0;
255 BEGIN( CopyArgSharp );
258<CopyArgRound,CopyArgRound2>"(" {
259 yyextra->argRoundCount++;
260 *yyextra->copyArgValue += *yytext;
262<CopyArgRound,CopyArgRound2>")"({B}*{ID})* {
263 *yyextra->copyArgValue += yytext;
264 if (yyextra->argRoundCount>0)
266 yyextra->argRoundCount--;
270 if (YY_START==CopyArgRound2)
272 *yyextra->copyArgValue+=
" "+yyextra->curArgName;
274 BEGIN( yyextra->readArgContext );
277<CopyArgRound>")"/{B}* {
278 *yyextra->copyArgValue += *yytext;
279 if (yyextra->argRoundCount>0) yyextra->argRoundCount--;
280 else BEGIN( yyextra->readArgContext );
283 yyextra->argSquareCount++;
284 *yyextra->copyArgValue += *yytext;
286<CopyArgSquare>"]"({B}*{ID})* {
287 *yyextra->copyArgValue += yytext;
288 if (yyextra->argSquareCount>0)
290 yyextra->argRoundCount--;
294 BEGIN( yyextra->readArgContext );
297<CopyArgSquare>"]"/{B}* {
298 *yyextra->copyArgValue += *yytext;
299 if (yyextra->argSquareCount>0) yyextra->argSquareCount--;
300 else BEGIN( yyextra->readArgContext );
303 if (yyextra->argRoundCount>0)
306 *yyextra->copyArgValue += yytext;
314 if (yyextra->argRoundCount>0)
317 *yyextra->copyArgValue += yytext;
326 if (yyextra->argRoundCount==0) yyextra->argSharpCount++;
327 *yyextra->copyArgValue += *yytext;
330 *yyextra->copyArgValue += *yytext;
331 if (yyextra->argRoundCount>0 && yyextra->argSharpCount==0)
337 if (yyextra->argSharpCount>0)
339 yyextra->argSharpCount--;
343 BEGIN( yyextra->readArgContext );
348 yyextra->argRoundCount++;
349 *yyextra->copyArgValue += *yytext;
352 yyextra->argRoundCount--;
353 *yyextra->copyArgValue += *yytext;
356 yyextra->argCurlyCount++;
357 *yyextra->copyArgValue += *yytext;
360 *yyextra->copyArgValue += *yytext;
361 if (yyextra->argCurlyCount>0) yyextra->argCurlyCount--;
362 else BEGIN( yyextra->readArgContext );
365 yyextra->curArgDefValue+=yytext;
367<CopyRawString>{RAWEND} {
368 yyextra->curArgDefValue+=yytext;
371 BEGIN( ReadFuncArgDef );
QCString extractEndRawStringDelimiter(const char *rawEnd)
375 yyextra->curArgDefValue+=*yytext;
376 BEGIN( ReadFuncArgDef );
378<ReadFuncArgType>"=" {
379 BEGIN( ReadFuncArgDef );
381<ReadFuncArgType,ReadFuncArgDef>[,)>]{B}*({CCS}[*!]|{CPPC}[/!])"<" {
382 yyextra->lastDocContext=YY_START;
383 yyextra->lastDocChar=*yytext;
385 if (text.find(
"//")!=-1)
386 BEGIN( ReadDocLine );
388 BEGIN( ReadDocBlock );
390<ReadFuncArgType,ReadFuncArgDef>[,)>] {
391 if (*yytext==
')' && yyextra->curArgTypeName.stripWhiteSpace().isEmpty())
393 yyextra->curArgTypeName+=*yytext;
399 yyextra->curArgDefValue=yyextra->curArgDefValue.stripWhiteSpace();
401 int l =
static_cast<int>(yyextra->curArgTypeName.length());
405 while (i>=0 && (isspace((uint8_t)yyextra->curArgTypeName.at(i)) || yyextra->curArgTypeName.at(i)==
'.')) i--;
406 while (i>=0 && (
isId(yyextra->curArgTypeName.at(i)) || yyextra->curArgTypeName.at(i)==
'$')) i--;
408 a.
attrib = yyextra->curArgAttrib;
413 if (i==l-1 && yyextra->curArgTypeName.at(i)==
')')
415 int bi=yyextra->curArgTypeName.find(
'(');
418 while (fi>=0 && (
isId(yyextra->curArgTypeName.at(fi)) || yyextra->curArgTypeName.at(fi)==
':')) fi--;
421 a.
type = yyextra->curArgTypeName.
left(fi+1);
423 a.
array = yyextra->curArgTypeName.
right(l-bi);
427 a.
type = yyextra->curArgTypeName;
430 else if (i>=0 && yyextra->curArgTypeName.at(i)!=
':')
442 if (a.
type.
mid(sv)==
"struct" ||
447 a.
type==
"volatile" ||
468 if (alen>2 && a.
array.
at(0)==
'(' &&
479 a.
defval = yyextra->curArgDefValue;
483 yyextra->argList->push_back(a);
485 yyextra->curArgAttrib.clear();
486 yyextra->curArgTypeName.clear();
487 yyextra->curArgDefValue.clear();
488 yyextra->curArgArray.clear();
489 yyextra->curArgDocs.clear();
490 yyextra->curTypeConstraint.clear();
498 BEGIN( ReadFuncArgType );
int find(char c, int index=0, bool cs=TRUE) const
size_t length() const
Returns the length of the string, not counting the 0-terminator.
bool startsWith(const char *s) const
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
char & at(size_t i)
Returns a reference to the character at index i.
bool isEmpty() const
Returns TRUE iff the string is empty.
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
QCString right(size_t len) const
QCString left(size_t len) const
This class contains the information about the argument of a function or template.
QCString removeRedundantWhiteSpace(const QCString &s)
502<ReadFuncArgType,ReadFuncArgPtr>"extends" {
503 if (yyextra->lang!=SrcLangExt::Java)
509 yyextra->argSharpCount=0;
510 yyextra->curTypeConstraint.clear();
511 yyextra->lastExtendsContext=YY_START;
512 BEGIN(ReadTypeConstraint);
515<ReadFuncArgType,ReadFuncArgPtr>"$"?{ID} {
517 if (YY_START==ReadFuncArgType && yyextra->curArgArray==
"[]")
519 yyextra->curArgTypeName+=
" []";
520 yyextra->curArgArray.clear();
523 yyextra->curArgTypeName+=name;
525<ReadFuncArgType,ReadFuncArgPtr>. {
526 yyextra->curArgTypeName+=*yytext;
529<ReadFuncArgDef,CopyArgString>"<="|"->"|">="|">>"|"<<" {
530 yyextra->curArgDefValue+=yytext;
532<ReadFuncArgDef,CopyArgString,CopyRawString>. {
533 yyextra->curArgDefValue+=*yytext;
535<CopyArgRound,CopyArgRound2,CopyArgSquare,CopyArgSharp,CopyArgCurly>{ID} {
536 *yyextra->copyArgValue+=yytext;
538<CopyArgRound,CopyArgRound2,CopyArgSquare,CopyArgSharp,CopyArgCurly>. {
539 *yyextra->copyArgValue += *yytext;
541<ReadTypeConstraint>[,)>] {
542 if (yytext[0]!=
'>' || yyextra->argSharpCount==0)
545 BEGIN(yyextra->lastExtendsContext);
549 yyextra->curTypeConstraint+=yytext;
550 yyextra->argSharpCount--;
553<ReadTypeConstraint>"<" {
554 yyextra->curTypeConstraint+=yytext;
555 yyextra->argSharpCount++;
557<ReadTypeConstraint>. {
558 yyextra->curTypeConstraint+=yytext;
560<ReadTypeConstraint>\n {
561 yyextra->curTypeConstraint+=
' ';
564 yyextra->argList->setConstSpecifier(
TRUE);
566<FuncQual>"volatile" {
567 yyextra->argList->setVolatileSpecifier(
TRUE);
569<FuncQual>"override" {
577<FuncQual,TrailingReturn>"="{B}*"0" {
578 yyextra->argList->setPureSpecifier(
TRUE);
582 yyextra->argList->setTrailingReturnType(
QCString(
" -> "));
583 BEGIN(TrailingReturn);
585<TrailingReturn>{B}/("final"|"override"){B}* {
590 yyextra->argList->setTrailingReturnType(yyextra->argList->trailingReturnType()+yytext);
593 yyextra->argList->setTrailingReturnType(yyextra->argList->trailingReturnType()+yytext);
595<FuncQual>")"{B}*"["[^]]*"]" {
597 yyextra->extraTypeChars=yytext;
599<ReadDocBlock>[^\*\n]+ {
600 yyextra->curArgDocs+=yytext;
603 yyextra->curArgDocs+=yytext;
606 if (yyextra->lastDocChar!=0)
607 unput(yyextra->lastDocChar);
608 BEGIN(yyextra->lastDocContext);
611 if (yyextra->lastDocChar!=0)
612 unput(yyextra->lastDocChar);
613 BEGIN(yyextra->lastDocContext);
616 yyextra->curArgDocs+=*yytext;
619 yyextra->curArgDocs+=*yytext;
621<*>({CCS}[*!]|{CPPC}[/!])("<"?) {
622 yyextra->lastDocContext=YY_START;
623 yyextra->lastDocChar=0;
625 BEGIN( ReadDocLine );
627 BEGIN( ReadDocBlock );
639 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
641 while( c < max_size && yyextra->inputString[yyextra->inputPosition] )
643 *buf = yyextra->inputString[yyextra->inputPosition++] ;
692#define TOTAL_KEYWORDS 28
693#define MIN_WORD_LENGTH 3
694#define MAX_WORD_LENGTH 9
695#define MIN_HASH_VALUE 3
696#define MAX_HASH_VALUE 48
702 static inline size_t hash (
const char *str,
size_t len);
704 static const char *
find (
const char *str,
size_t len);
709 static const unsigned char asso_values[] =
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, 5,
716 5, 30, 0, 49, 25, 49, 10, 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, 0, 49, 0, 5, 49,
721 15, 0, 49, 10, 49, 30, 49, 49, 0, 20,
722 0, 49, 15, 49, 5, 10, 0, 49, 49, 49,
723 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
724 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
725 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
726 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
727 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
728 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
729 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
730 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
731 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
732 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
733 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
734 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
735 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
736 49, 49, 49, 49, 49, 49
743 hval += asso_values[
static_cast<unsigned char>(str[4])];
746 hval += asso_values[
static_cast<unsigned char>(str[3])];
756 static const char *
const wordlist[] =
798 size_t key =
hash (str, len);
802 const char *s = wordlist[key];
804 if (*str == *s && !
qstrcmp (str + 1, s + 1))
828 std::unique_ptr<ArgumentList> al = std::make_unique<ArgumentList>();
829 if (argsString.
isEmpty())
return al;
833 defargsYYlex_init_extra(&extra,&yyscanner);
837 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
840 defargsYYrestart(
nullptr, yyscanner );
842 defargsYYlex(yyscanner);
843 if (yyextra->argList->empty())
845 yyextra->argList->setNoParameters(
TRUE);
847 if (extraTypeChars) *extraTypeChars=yyextra->extraTypeChars;
849 defargsYYlex_destroy(yyscanner);
853#include "defargs.l.h"
static bool isFlagSet(const DebugMask mask)
static size_t hash(const char *str, size_t len)
static const char * find(const char *str, size_t len)
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
static int yyread(yyscan_t yyscanner, char *buf, int max_size)
std::unique_ptr< ArgumentList > stringToArgumentList(SrcLangExt lang, const QCString &argsString, QCString *extraTypeChars)
int qstrcmp(const char *str1, const char *str2)