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
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.
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().empty())
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 );
DString 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 size_t i=yyextra->curArgTypeName.rfind(
'(');
212 size_t l=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 );
static constexpr size_t npos
value used to indicate 'not found' or 'to the end of the string', matching std::string::npos
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 );
DString 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;
386 BEGIN( ReadDocLine );
388 BEGIN( ReadDocBlock );
390<ReadFuncArgType,ReadFuncArgDef>[,)>] {
391 if (*yytext==
')' && yyextra->curArgTypeName.stripWhiteSpace().empty())
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 size_t bis=yyextra->curArgTypeName.find(
'(');
419 while (fi>=0 && (
isId(yyextra->curArgTypeName.at(fi)) || yyextra->curArgTypeName.at(fi)==
':')) fi--;
422 a.
type = yyextra->curArgTypeName.
left(fi+1);
424 a.
array = yyextra->curArgTypeName.
right(l-bi);
428 a.
type = yyextra->curArgTypeName;
431 else if (i>=0 && yyextra->curArgTypeName.at(i)!=
':')
443 if (a.
type.
mid(sv)==
"struct" ||
448 a.
type==
"volatile" ||
469 if (alen>2 && a.
array.
at(0)==
'(' &&
481 a.
defval = yyextra->curArgDefValue;
487 yyextra->curArgAttrib.clear();
488 yyextra->curArgTypeName.clear();
489 yyextra->curArgDefValue.clear();
490 yyextra->curArgArray.clear();
491 yyextra->curArgDocs.clear();
492 yyextra->curTypeConstraint.clear();
500 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(int c)
Returns true if c is a valid character for an identifier.
DString removeRedundantWhiteSpace(const DString &s)
504<ReadFuncArgType,ReadFuncArgPtr>"extends" {
505 if (yyextra->lang!=SrcLangExt::Java)
511 yyextra->argSharpCount=0;
512 yyextra->curTypeConstraint.clear();
513 yyextra->lastExtendsContext=YY_START;
514 BEGIN(ReadTypeConstraint);
517<ReadFuncArgType,ReadFuncArgPtr>"$"?{ID} {
519 if (YY_START==ReadFuncArgType && yyextra->curArgArray==
"[]")
521 yyextra->curArgTypeName+=
" []";
522 yyextra->curArgArray.clear();
525 yyextra->curArgTypeName+=name;
527<ReadFuncArgType,ReadFuncArgPtr>. {
528 yyextra->curArgTypeName+=*yytext;
531<ReadFuncArgDef,CopyArgString>"<="|"->"|">="|">>"|"<<" {
532 yyextra->curArgDefValue+=yytext;
534<ReadFuncArgDef,CopyArgString,CopyRawString>. {
535 yyextra->curArgDefValue+=*yytext;
537<CopyArgRound,CopyArgRound2,CopyArgSquare,CopyArgSharp,CopyArgCurly>{ID} {
538 *yyextra->copyArgValue+=yytext;
540<CopyArgRound,CopyArgRound2,CopyArgSquare,CopyArgSharp,CopyArgCurly>. {
541 *yyextra->copyArgValue += *yytext;
543<ReadTypeConstraint>[,)>] {
544 if (yytext[0]!=
'>' || yyextra->argSharpCount==0)
547 BEGIN(yyextra->lastExtendsContext);
551 yyextra->curTypeConstraint+=yytext;
552 yyextra->argSharpCount--;
555<ReadTypeConstraint>"<" {
556 yyextra->curTypeConstraint+=yytext;
557 yyextra->argSharpCount++;
559<ReadTypeConstraint>. {
560 yyextra->curTypeConstraint+=yytext;
562<ReadTypeConstraint>\n {
563 yyextra->curTypeConstraint+=
' ';
566 yyextra->argList->setConstSpecifier(
true);
568<FuncQual>"volatile" {
569 yyextra->argList->setVolatileSpecifier(
true);
571<FuncQual>"override" {
579<FuncQual,TrailingReturn>"="{B}*"0" {
580 yyextra->argList->setPureSpecifier(
true);
584 yyextra->argList->setTrailingReturnType(
DString(
" -> "));
585 BEGIN(TrailingReturn);
587<TrailingReturn>{B}/("final"|"override"){B}* {
592 yyextra->argList->setTrailingReturnType(yyextra->argList->trailingReturnType()+yytext);
595 yyextra->argList->setTrailingReturnType(yyextra->argList->trailingReturnType()+yytext);
597<FuncQual>")"{B}*"["[^]]*"]" {
599 yyextra->extraTypeChars=yytext;
601<ReadDocBlock>[^\*\n]+ {
602 yyextra->curArgDocs+=yytext;
605 yyextra->curArgDocs+=yytext;
608 if (yyextra->lastDocChar!=0)
609 unput(yyextra->lastDocChar);
610 BEGIN(yyextra->lastDocContext);
613 if (yyextra->lastDocChar!=0)
614 unput(yyextra->lastDocChar);
615 BEGIN(yyextra->lastDocContext);
618 yyextra->curArgDocs+=*yytext;
621 yyextra->curArgDocs+=*yytext;
623<*>({CCS}[*!]|{CPPC}[/!])("<"?) {
624 yyextra->lastDocContext=YY_START;
625 yyextra->lastDocChar=0;
627 BEGIN( ReadDocLine );
629 BEGIN( ReadDocBlock );
641 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
643 while( c < max_size && yyextra->inputString[yyextra->inputPosition] )
645 *buf = yyextra->inputString[yyextra->inputPosition++] ;
694#define TOTAL_KEYWORDS 28
695#define MIN_WORD_LENGTH 3
696#define MAX_WORD_LENGTH 9
697#define MIN_HASH_VALUE 3
698#define MAX_HASH_VALUE 48
704 static inline size_t hash (
const char *str,
size_t len);
706 static const char *
find (
const char *str,
size_t len);
711 static const unsigned char asso_values[] =
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, 5,
718 5, 30, 0, 49, 25, 49, 10, 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, 0, 49, 0, 5, 49,
723 15, 0, 49, 10, 49, 30, 49, 49, 0, 20,
724 0, 49, 15, 49, 5, 10, 0, 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, 49, 49, 49, 49,
737 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
738 49, 49, 49, 49, 49, 49
745 hval += asso_values[
static_cast<unsigned char>(str[4])];
748 hval += asso_values[
static_cast<unsigned char>(str[3])];
758 static const char *
const wordlist[] =
800 size_t key =
hash (str, len);
804 const char *s = wordlist[key];
806 if (*str == *s && !
dstrcmp (str + 1, s + 1))
830 std::unique_ptr<ArgumentList> al = std::make_unique<ArgumentList>();
831 if (argsString.
empty())
return al;
835 defargsYYlex_init_extra(&extra,&yyscanner);
839 struct yyguts_t *yyg = (
struct yyguts_t*)yyscanner;
842 defargsYYrestart(
nullptr, yyscanner );
844 defargsYYlex(yyscanner);
845 if (yyextra->argList->empty())
847 yyextra->argList->setNoParameters(
true);
849 if (extraTypeChars) *extraTypeChars=yyextra->extraTypeChars;
851 defargsYYlex_destroy(yyscanner);
855#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)
std::unique_ptr< ArgumentList > stringToArgumentList(SrcLangExt lang, const DString &argsString, DString *extraTypeChars)
int dstrcmp(const char *str1, const char *str2)
static int yyread(yyscan_t yyscanner, char *buf, int max_size)