40%option never-interactive
41%option prefix="defargsYY"
43%option extra-type="struct defargsYY_state *"
47#define YY_TYPEDEF_YY_SCANNER_T
65#define YY_NO_UNISTD_H 1
106#define YY_INPUT(buf,result,max_size) result=yyread(yyscanner,buf,max_size);
110#define LEX_NO_INPUT_FILENAME
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
static bool nameIsActuallyPartOfType(DString &name)
static int yyread(yyscan_t yyscanner, char *buf, int max_size)
static const char * stateToString(int state)
static const char * getLexerFILE()
std::unique_ptr< ArgumentList > & argList
defargsYY_state(const char *inStr, std::unique_ptr< ArgumentList > &al, SrcLangExt l)
DString curTypeConstraint
A bunch of utility functions.
117ID [$a-z_A-Z\x80-\xFF][$a-z_A-Z0-9\x80-\xFF]*
118RAWBEGIN (u|U|L|u8)?R\"[^ \t\(\)\\]{0,16}"("
119RAWEND ")"[^ \t\(\)\\]{0,16}\"
150<Start>[<(] { BEGIN(ReadFuncArgType); }
152<ReadFuncArgType>{B}* {
153 yyextra->curArgTypeName+=
" ";
155<ReadFuncArgType,ReadFuncArgPtr>"["[^\]]*"]" {
156 if (YY_START==ReadFuncArgPtr)
158 yyextra->curArgTypeName+=yytext;
160 else if (yyextra->curArgTypeName.stripWhiteSpace().empty())
162 yyextra->curArgAttrib=yytext;
166 yyextra->curArgArray+=yytext;
169<ReadFuncArgDef>"'"\\[0-7]{1,3}"'" { yyextra->curArgDefValue+=yytext; }
170<ReadFuncArgDef>"'"\\."'" { yyextra->curArgDefValue+=yytext; }
171<ReadFuncArgDef>"'"."'" { yyextra->curArgDefValue+=yytext; }
172<ReadFuncArgDef>{RAWBEGIN} { yyextra->curArgDefValue+=yytext;
174 BEGIN( CopyRawString );
DString extractBeginRawStringDelimiter(const char *rawStart)
177 yyextra->curArgDefValue+=*yytext;
178 BEGIN( CopyArgString );
180<ReadFuncArgType>"("([^:)]+{B}*"::")*{B}*[&*\^]+{Bopt}/{ID} {
182 yyextra->curArgTypeName+=yytext;
184 BEGIN( ReadFuncArgPtr );
186<ReadFuncArgPtr>{ID} {
187 yyextra->curArgName=yytext;
189<ReadFuncArgPtr>")"{B}*"(" {
190 yyextra->curArgTypeName+=yytext;
192 yyextra->readArgContext = ReadFuncArgType;
193 yyextra->copyArgValue=&yyextra->curArgTypeName;
194 yyextra->argRoundCount=0;
195 BEGIN( CopyArgRound2 );
197<ReadFuncArgPtr>")"/{B}*"[" {
198 yyextra->curArgTypeName+=yytext;
199 yyextra->curArgTypeName+=yyextra->curArgName;
201 BEGIN( ReadFuncArgType );
204 size_t i=yyextra->curArgTypeName.rfind(
'(');
205 size_t l=yyextra->curArgTypeName.length();
208 yyextra->curArgTypeName=yyextra->curArgTypeName.left(i)+
209 yyextra->curArgTypeName.right(l-i-1);
211 yyextra->curArgTypeName+=yyextra->curArgName;
212 BEGIN( ReadFuncArgType );
static constexpr size_t npos
value used to indicate 'not found' or 'to the end of the string', matching std::string::npos
214<ReadFuncArgType>"<="|">="|"->"|">>"|"<<" {
215 yyextra->curArgTypeName+=yytext;
217<ReadFuncArgType,ReadFuncArgDef>[({<\[] {
218 if (YY_START==ReadFuncArgType)
220 yyextra->curArgTypeName+=*yytext;
221 yyextra->copyArgValue=&yyextra->curArgTypeName;
225 yyextra->curArgDefValue+=*yytext;
226 yyextra->copyArgValue=&yyextra->curArgDefValue;
228 yyextra->readArgContext = YY_START;
231 yyextra->argRoundCount=0;
232 BEGIN( CopyArgRound );
234 else if (*yytext==
'[')
236 yyextra->argSquareCount=0;
237 BEGIN( CopyArgSquare );
239 else if (*yytext==
'{')
241 yyextra->argCurlyCount=0;
242 BEGIN( CopyArgCurly );
246 yyextra->argSharpCount=0;
247 yyextra->argRoundCount=0;
248 BEGIN( CopyArgSharp );
251<CopyArgRound,CopyArgRound2>"(" {
252 yyextra->argRoundCount++;
253 *yyextra->copyArgValue += *yytext;
255<CopyArgRound,CopyArgRound2>")"({B}*{ID})* {
256 *yyextra->copyArgValue += yytext;
257 if (yyextra->argRoundCount>0)
259 yyextra->argRoundCount--;
263 if (YY_START==CopyArgRound2)
265 *yyextra->copyArgValue+=
" "+yyextra->curArgName;
267 BEGIN( yyextra->readArgContext );
270<CopyArgRound>")"/{B}* {
271 *yyextra->copyArgValue += *yytext;
272 if (yyextra->argRoundCount>0) yyextra->argRoundCount--;
273 else BEGIN( yyextra->readArgContext );
276 yyextra->argSquareCount++;
277 *yyextra->copyArgValue += *yytext;
279<CopyArgSquare>"]"({B}*{ID})* {
280 *yyextra->copyArgValue += yytext;
281 if (yyextra->argSquareCount>0)
283 yyextra->argRoundCount--;
287 BEGIN( yyextra->readArgContext );
290<CopyArgSquare>"]"/{B}* {
291 *yyextra->copyArgValue += *yytext;
292 if (yyextra->argSquareCount>0) yyextra->argSquareCount--;
293 else BEGIN( yyextra->readArgContext );
296 if (yyextra->argRoundCount>0)
299 *yyextra->copyArgValue += yytext;
307 if (yyextra->argRoundCount>0)
310 *yyextra->copyArgValue += yytext;
319 if (yyextra->argRoundCount==0) yyextra->argSharpCount++;
320 *yyextra->copyArgValue += *yytext;
323 *yyextra->copyArgValue += *yytext;
324 if (yyextra->argRoundCount>0 && yyextra->argSharpCount==0)
330 if (yyextra->argSharpCount>0)
332 yyextra->argSharpCount--;
336 BEGIN( yyextra->readArgContext );
341 yyextra->argRoundCount++;
342 *yyextra->copyArgValue += *yytext;
345 yyextra->argRoundCount--;
346 *yyextra->copyArgValue += *yytext;
349 yyextra->argCurlyCount++;
350 *yyextra->copyArgValue += *yytext;
353 *yyextra->copyArgValue += *yytext;
354 if (yyextra->argCurlyCount>0) yyextra->argCurlyCount--;
355 else BEGIN( yyextra->readArgContext );
358 yyextra->curArgDefValue+=yytext;
360<CopyRawString>{RAWEND} {
361 yyextra->curArgDefValue+=yytext;
364 BEGIN( ReadFuncArgDef );
DString extractEndRawStringDelimiter(const char *rawEnd)
368 yyextra->curArgDefValue+=*yytext;
369 BEGIN( ReadFuncArgDef );
371<ReadFuncArgType>"=" {
372 BEGIN( ReadFuncArgDef );
374<ReadFuncArgType,ReadFuncArgDef>[,)>]{B}*({CCS}[*!]|{CPPC}[/!])"<" {
375 yyextra->lastDocContext=YY_START;
376 yyextra->lastDocChar=*yytext;
379 BEGIN( ReadDocLine );
381 BEGIN( ReadDocBlock );
383<ReadFuncArgType,ReadFuncArgDef>[,)>] {
384 if (*yytext==
')' && yyextra->curArgTypeName.stripWhiteSpace().empty())
386 yyextra->curArgTypeName+=*yytext;
392 yyextra->curArgDefValue=yyextra->curArgDefValue.stripWhiteSpace();
394 int l =
static_cast<int>(yyextra->curArgTypeName.length());
398 while (i>=0 && (isspace((uint8_t)yyextra->curArgTypeName.at(i)) || yyextra->curArgTypeName.at(i)==
'.')) i--;
399 while (i>=0 && (
isId(yyextra->curArgTypeName.at(i)) || yyextra->curArgTypeName.at(i)==
'$')) i--;
401 a.
attrib = yyextra->curArgAttrib;
406 if (i==l-1 && yyextra->curArgTypeName.at(i)==
')')
408 size_t bis=yyextra->curArgTypeName.find(
'(');
412 while (fi>=0 && (
isId(yyextra->curArgTypeName.at(fi)) || yyextra->curArgTypeName.at(fi)==
':')) fi--;
415 a.
type = yyextra->curArgTypeName.
left(fi+1);
417 a.
array = yyextra->curArgTypeName.
right(l-bi);
421 a.
type = yyextra->curArgTypeName;
424 else if (i>=0 && yyextra->curArgTypeName.at(i)!=
':')
436 if (a.
type.
mid(sv)==
"struct" ||
441 a.
type==
"volatile" ||
462 if (alen>2 && a.
array.
at(0)==
'(' &&
474 a.
defval = yyextra->curArgDefValue;
480 yyextra->curArgAttrib.clear();
481 yyextra->curArgTypeName.clear();
482 yyextra->curArgDefValue.clear();
483 yyextra->curArgArray.clear();
484 yyextra->curArgDocs.clear();
485 yyextra->curTypeConstraint.clear();
493 BEGIN( ReadFuncArgType );
This class contains the information about the argument of a function or template.
DString mid(size_t index, size_t len=npos) const
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
char & at(size_t i)
Returns a reference to the character at index i.
DString right(size_t len) const
size_t find(char c, size_t pos=0) const
DString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
DString left(size_t len) const
bool startsWith(const char *s) const
size_t length() const
Returns the length of the string, not counting the 0-terminator.
bool isId(char c)
Returns true if c is a valid character for an identifier.
DString removeRedundantWhiteSpace(const DString &s)
497<ReadFuncArgType,ReadFuncArgPtr>"extends" {
498 if (yyextra->lang!=SrcLangExt::Java)
504 yyextra->argSharpCount=0;
505 yyextra->curTypeConstraint.clear();
506 yyextra->lastExtendsContext=YY_START;
507 BEGIN(ReadTypeConstraint);
510<ReadFuncArgType,ReadFuncArgPtr>"$"?{ID} {
512 if (YY_START==ReadFuncArgType && yyextra->curArgArray==
"[]")
514 yyextra->curArgTypeName+=
" []";
515 yyextra->curArgArray.clear();
518 yyextra->curArgTypeName+=name;
520<ReadFuncArgType,ReadFuncArgPtr>. {
521 yyextra->curArgTypeName+=*yytext;
524<ReadFuncArgDef,CopyArgString>"<="|"->"|">="|">>"|"<<" {
525 yyextra->curArgDefValue+=yytext;
527<ReadFuncArgDef,CopyArgString,CopyRawString>. {
528 yyextra->curArgDefValue+=*yytext;
530<CopyArgRound,CopyArgRound2,CopyArgSquare,CopyArgSharp,CopyArgCurly>{ID} {
531 *yyextra->copyArgValue+=yytext;
533<CopyArgRound,CopyArgRound2,CopyArgSquare,CopyArgSharp,CopyArgCurly>. {
534 *yyextra->copyArgValue += *yytext;
536<ReadTypeConstraint>[,)>] {
537 if (yytext[0]!=
'>' || yyextra->argSharpCount==0)
540 BEGIN(yyextra->lastExtendsContext);
544 yyextra->curTypeConstraint+=yytext;
545 yyextra->argSharpCount--;
548<ReadTypeConstraint>"<" {
549 yyextra->curTypeConstraint+=yytext;
550 yyextra->argSharpCount++;
552<ReadTypeConstraint>. {
553 yyextra->curTypeConstraint+=yytext;
555<ReadTypeConstraint>\n {
556 yyextra->curTypeConstraint+=
' ';
559 yyextra->argList->setConstSpecifier(
true);
561<FuncQual>"volatile" {
562 yyextra->argList->setVolatileSpecifier(
true);
564<FuncQual>"override" {
572<FuncQual,TrailingReturn>"="{B}*"0" {
573 yyextra->argList->setPureSpecifier(
true);
577 yyextra->argList->setTrailingReturnType(
DString(
" -> "));
578 BEGIN(TrailingReturn);
580<TrailingReturn>{B}/("final"|"override"){B}* {
585 yyextra->argList->setTrailingReturnType(yyextra->argList->trailingReturnType()+yytext);
588 yyextra->argList->setTrailingReturnType(yyextra->argList->trailingReturnType()+yytext);
590<FuncQual>")"{B}*"["[^]]*"]" {
592 yyextra->extraTypeChars=yytext;
594<ReadDocBlock>[^\*\n]+ {
595 yyextra->curArgDocs+=yytext;
598 yyextra->curArgDocs+=yytext;
601 if (yyextra->lastDocChar!=0)
602 unput(yyextra->lastDocChar);
603 BEGIN(yyextra->lastDocContext);
606 if (yyextra->lastDocChar!=0)
607 unput(yyextra->lastDocChar);
608 BEGIN(yyextra->lastDocContext);
611 yyextra->curArgDocs+=*yytext;
614 yyextra->curArgDocs+=*yytext;
616<*>({CCS}[*!]|{CPPC}[/!])("<"?) {
617 yyextra->lastDocContext=YY_START;
618 yyextra->lastDocChar=0;
620 BEGIN( ReadDocLine );
622 BEGIN( ReadDocBlock );
634 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
636 while( c < max_size && yyextra->inputString[yyextra->inputPosition] )
638 *buf = yyextra->inputString[yyextra->inputPosition++] ;
687#define TOTAL_KEYWORDS 28
688#define MIN_WORD_LENGTH 3
689#define MAX_WORD_LENGTH 9
690#define MIN_HASH_VALUE 3
691#define MAX_HASH_VALUE 48
697 static inline size_t hash (
const char *str,
size_t len);
699 static const char *
find (
const char *str,
size_t len);
704 static const unsigned char asso_values[] =
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, 5,
711 5, 30, 0, 49, 25, 49, 10, 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, 0, 49, 0, 5, 49,
716 15, 0, 49, 10, 49, 30, 49, 49, 0, 20,
717 0, 49, 15, 49, 5, 10, 0, 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, 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
738 hval += asso_values[
static_cast<unsigned char>(str[4])];
741 hval += asso_values[
static_cast<unsigned char>(str[3])];
751 static const char *
const wordlist[] =
793 size_t key =
hash (str, len);
797 const char *s = wordlist[key];
799 if (*str == *s && !
dstrcmp (str + 1, s + 1))
823 std::unique_ptr<ArgumentList> al = std::make_unique<ArgumentList>();
824 if (argsString.
empty())
return al;
828 defargsYYlex_init_extra(&extra,&yyscanner);
832 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
835 defargsYYrestart(
nullptr, yyscanner );
837 defargsYYlex(yyscanner);
838 if (yyextra->argList->empty())
840 yyextra->argList->setNoParameters(
true);
842 if (extraTypeChars) *extraTypeChars=yyextra->extraTypeChars;
844 defargsYYlex_destroy(yyscanner);
848#include "defargs.l.h"
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
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)
static int yyread(char *buf, int max_size, yyscan_t yyscanner)
std::unique_ptr< ArgumentList > stringToArgumentList(SrcLangExt lang, const DString &argsString, DString *extraTypeChars)
int dstrcmp(const char *str1, const char *str2)