40%option never-interactive
41%option prefix="defargsYY"
43%option extra-type="struct defargsYY_state *"
47#define YY_TYPEDEF_YY_SCANNER_T
48#define yyguts_t defargsYYguts_t
66#define YY_NO_UNISTD_H 1
107#define YY_INPUT(buf,result,max_size) result=yyread(yyscanner,buf,max_size);
111#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.
118ID [$a-z_A-Z\x80-\xFF][$a-z_A-Z0-9\x80-\xFF]*
119RAWBEGIN (u|U|L|u8)?R\"[^ \t\(\)\\]{0,16}"("
120RAWEND ")"[^ \t\(\)\\]{0,16}\"
151<Start>[<(] { BEGIN(ReadFuncArgType); }
153<ReadFuncArgType>{B}* {
154 yyextra->curArgTypeName+=
" ";
156<ReadFuncArgType,ReadFuncArgPtr>"["[^\]]*"]" {
157 if (YY_START==ReadFuncArgPtr)
159 yyextra->curArgTypeName+=yytext;
161 else if (yyextra->curArgTypeName.stripWhiteSpace().empty())
163 yyextra->curArgAttrib=yytext;
167 yyextra->curArgArray+=yytext;
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;
175 BEGIN( CopyRawString );
DString extractBeginRawStringDelimiter(const char *rawStart)
178 yyextra->curArgDefValue+=*yytext;
179 BEGIN( CopyArgString );
181<ReadFuncArgType>"("([^:)]+{B}*"::")*{B}*[&*\^]+{Bopt}/{ID} {
183 yyextra->curArgTypeName+=yytext;
185 BEGIN( ReadFuncArgPtr );
187<ReadFuncArgPtr>{ID} {
188 yyextra->curArgName=yytext;
190<ReadFuncArgPtr>")"{B}*"(" {
191 yyextra->curArgTypeName+=yytext;
193 yyextra->readArgContext = ReadFuncArgType;
194 yyextra->copyArgValue=&yyextra->curArgTypeName;
195 yyextra->argRoundCount=0;
196 BEGIN( CopyArgRound2 );
198<ReadFuncArgPtr>")"/{B}*"[" {
199 yyextra->curArgTypeName+=yytext;
200 yyextra->curArgTypeName+=yyextra->curArgName;
202 BEGIN( ReadFuncArgType );
205 size_t i=yyextra->curArgTypeName.rfind(
'(');
206 size_t l=yyextra->curArgTypeName.length();
209 yyextra->curArgTypeName=yyextra->curArgTypeName.left(i)+
210 yyextra->curArgTypeName.right(l-i-1);
212 yyextra->curArgTypeName+=yyextra->curArgName;
213 BEGIN( ReadFuncArgType );
static constexpr size_t npos
value used to indicate 'not found' or 'to the end of the string', matching std::string::npos
215<ReadFuncArgType>"<="|">="|"->"|">>"|"<<" {
216 yyextra->curArgTypeName+=yytext;
218<ReadFuncArgType,ReadFuncArgDef>[({<\[] {
219 if (YY_START==ReadFuncArgType)
221 yyextra->curArgTypeName+=*yytext;
222 yyextra->copyArgValue=&yyextra->curArgTypeName;
226 yyextra->curArgDefValue+=*yytext;
227 yyextra->copyArgValue=&yyextra->curArgDefValue;
229 yyextra->readArgContext = YY_START;
232 yyextra->argRoundCount=0;
233 BEGIN( CopyArgRound );
235 else if (*yytext==
'[')
237 yyextra->argSquareCount=0;
238 BEGIN( CopyArgSquare );
240 else if (*yytext==
'{')
242 yyextra->argCurlyCount=0;
243 BEGIN( CopyArgCurly );
247 yyextra->argSharpCount=0;
248 yyextra->argRoundCount=0;
249 BEGIN( CopyArgSharp );
252<CopyArgRound,CopyArgRound2>"(" {
253 yyextra->argRoundCount++;
254 *yyextra->copyArgValue += *yytext;
256<CopyArgRound,CopyArgRound2>")"({B}*{ID})* {
257 *yyextra->copyArgValue += yytext;
258 if (yyextra->argRoundCount>0)
260 yyextra->argRoundCount--;
264 if (YY_START==CopyArgRound2)
266 *yyextra->copyArgValue+=
" "+yyextra->curArgName;
268 BEGIN( yyextra->readArgContext );
271<CopyArgRound>")"/{B}* {
272 *yyextra->copyArgValue += *yytext;
273 if (yyextra->argRoundCount>0) yyextra->argRoundCount--;
274 else BEGIN( yyextra->readArgContext );
277 yyextra->argSquareCount++;
278 *yyextra->copyArgValue += *yytext;
280<CopyArgSquare>"]"({B}*{ID})* {
281 *yyextra->copyArgValue += yytext;
282 if (yyextra->argSquareCount>0)
284 yyextra->argRoundCount--;
288 BEGIN( yyextra->readArgContext );
291<CopyArgSquare>"]"/{B}* {
292 *yyextra->copyArgValue += *yytext;
293 if (yyextra->argSquareCount>0) yyextra->argSquareCount--;
294 else BEGIN( yyextra->readArgContext );
297 if (yyextra->argRoundCount>0)
300 *yyextra->copyArgValue += yytext;
308 if (yyextra->argRoundCount>0)
311 *yyextra->copyArgValue += yytext;
320 if (yyextra->argRoundCount==0) yyextra->argSharpCount++;
321 *yyextra->copyArgValue += *yytext;
324 *yyextra->copyArgValue += *yytext;
325 if (yyextra->argRoundCount>0 && yyextra->argSharpCount==0)
331 if (yyextra->argSharpCount>0)
333 yyextra->argSharpCount--;
337 BEGIN( yyextra->readArgContext );
342 yyextra->argRoundCount++;
343 *yyextra->copyArgValue += *yytext;
346 yyextra->argRoundCount--;
347 *yyextra->copyArgValue += *yytext;
350 yyextra->argCurlyCount++;
351 *yyextra->copyArgValue += *yytext;
354 *yyextra->copyArgValue += *yytext;
355 if (yyextra->argCurlyCount>0) yyextra->argCurlyCount--;
356 else BEGIN( yyextra->readArgContext );
359 yyextra->curArgDefValue+=yytext;
361<CopyRawString>{RAWEND} {
362 yyextra->curArgDefValue+=yytext;
365 BEGIN( ReadFuncArgDef );
DString extractEndRawStringDelimiter(const char *rawEnd)
369 yyextra->curArgDefValue+=*yytext;
370 BEGIN( ReadFuncArgDef );
372<ReadFuncArgType>"=" {
373 BEGIN( ReadFuncArgDef );
375<ReadFuncArgType,ReadFuncArgDef>[,)>]{B}*({CCS}[*!]|{CPPC}[/!])"<" {
376 yyextra->lastDocContext=YY_START;
377 yyextra->lastDocChar=*yytext;
380 BEGIN( ReadDocLine );
382 BEGIN( ReadDocBlock );
384<ReadFuncArgType,ReadFuncArgDef>[,)>] {
385 if (*yytext==
')' && yyextra->curArgTypeName.stripWhiteSpace().empty())
387 yyextra->curArgTypeName+=*yytext;
393 yyextra->curArgDefValue=yyextra->curArgDefValue.stripWhiteSpace();
395 int l =
static_cast<int>(yyextra->curArgTypeName.length());
399 while (i>=0 && (isspace((uint8_t)yyextra->curArgTypeName.at(i)) || yyextra->curArgTypeName.at(i)==
'.')) i--;
400 while (i>=0 && (
isId(yyextra->curArgTypeName.at(i)) || yyextra->curArgTypeName.at(i)==
'$')) i--;
402 a.
attrib = yyextra->curArgAttrib;
407 if (i==l-1 && yyextra->curArgTypeName.at(i)==
')')
409 size_t bis=yyextra->curArgTypeName.find(
'(');
413 while (fi>=0 && (
isId(yyextra->curArgTypeName.at(fi)) || yyextra->curArgTypeName.at(fi)==
':')) fi--;
416 a.
type = yyextra->curArgTypeName.
left(fi+1);
418 a.
array = yyextra->curArgTypeName.
right(l-bi);
422 a.
type = yyextra->curArgTypeName;
425 else if (i>=0 && yyextra->curArgTypeName.at(i)!=
':')
437 if (a.
type.
mid(sv)==
"struct" ||
442 a.
type==
"volatile" ||
463 if (alen>2 && a.
array.
at(0)==
'(' &&
475 a.
defval = yyextra->curArgDefValue;
481 yyextra->curArgAttrib.clear();
482 yyextra->curArgTypeName.clear();
483 yyextra->curArgDefValue.clear();
484 yyextra->curArgArray.clear();
485 yyextra->curArgDocs.clear();
486 yyextra->curTypeConstraint.clear();
494 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)
498<ReadFuncArgType,ReadFuncArgPtr>"extends" {
499 if (yyextra->lang!=SrcLangExt::Java)
505 yyextra->argSharpCount=0;
506 yyextra->curTypeConstraint.clear();
507 yyextra->lastExtendsContext=YY_START;
508 BEGIN(ReadTypeConstraint);
511<ReadFuncArgType,ReadFuncArgPtr>"$"?{ID} {
513 if (YY_START==ReadFuncArgType && yyextra->curArgArray==
"[]")
515 yyextra->curArgTypeName+=
" []";
516 yyextra->curArgArray.clear();
519 yyextra->curArgTypeName+=
name;
const char * name(int level)
521<ReadFuncArgType,ReadFuncArgPtr>. {
522 yyextra->curArgTypeName+=*yytext;
525<ReadFuncArgDef,CopyArgString>"<="|"->"|">="|">>"|"<<" {
526 yyextra->curArgDefValue+=yytext;
528<ReadFuncArgDef,CopyArgString,CopyRawString>. {
529 yyextra->curArgDefValue+=*yytext;
531<CopyArgRound,CopyArgRound2,CopyArgSquare,CopyArgSharp,CopyArgCurly>{ID} {
532 *yyextra->copyArgValue+=yytext;
534<CopyArgRound,CopyArgRound2,CopyArgSquare,CopyArgSharp,CopyArgCurly>. {
535 *yyextra->copyArgValue += *yytext;
537<ReadTypeConstraint>[,)>] {
538 if (yytext[0]!=
'>' || yyextra->argSharpCount==0)
541 BEGIN(yyextra->lastExtendsContext);
545 yyextra->curTypeConstraint+=yytext;
546 yyextra->argSharpCount--;
549<ReadTypeConstraint>"<" {
550 yyextra->curTypeConstraint+=yytext;
551 yyextra->argSharpCount++;
553<ReadTypeConstraint>. {
554 yyextra->curTypeConstraint+=yytext;
556<ReadTypeConstraint>\n {
557 yyextra->curTypeConstraint+=
' ';
560 yyextra->argList->setConstSpecifier(
true);
562<FuncQual>"volatile" {
563 yyextra->argList->setVolatileSpecifier(
true);
565<FuncQual>"override" {
573<FuncQual,TrailingReturn>"="{B}*"0" {
574 yyextra->argList->setPureSpecifier(
true);
578 yyextra->argList->setTrailingReturnType(
DString(
" -> "));
579 BEGIN(TrailingReturn);
581<TrailingReturn>{B}/("final"|"override"){B}* {
586 yyextra->argList->setTrailingReturnType(yyextra->argList->trailingReturnType()+yytext);
589 yyextra->argList->setTrailingReturnType(yyextra->argList->trailingReturnType()+yytext);
591<FuncQual>")"{B}*"["[^]]*"]" {
593 yyextra->extraTypeChars=yytext;
595<ReadDocBlock>[^\*\n]+ {
596 yyextra->curArgDocs+=yytext;
599 yyextra->curArgDocs+=yytext;
602 if (yyextra->lastDocChar!=0)
603 unput(yyextra->lastDocChar);
604 BEGIN(yyextra->lastDocContext);
607 if (yyextra->lastDocChar!=0)
608 unput(yyextra->lastDocChar);
609 BEGIN(yyextra->lastDocContext);
612 yyextra->curArgDocs+=*yytext;
615 yyextra->curArgDocs+=*yytext;
617<*>({CCS}[*!]|{CPPC}[/!])("<"?) {
618 yyextra->lastDocContext=YY_START;
619 yyextra->lastDocChar=0;
621 BEGIN( ReadDocLine );
623 BEGIN( ReadDocBlock );
637 while( c < max_size && yyextra->inputString[yyextra->inputPosition] )
639 *buf = yyextra->inputString[yyextra->inputPosition++] ;
688#define TOTAL_KEYWORDS 28
689#define MIN_WORD_LENGTH 3
690#define MAX_WORD_LENGTH 9
691#define MIN_HASH_VALUE 3
692#define MAX_HASH_VALUE 48
698 static inline size_t hash (
const char *str,
size_t len);
700 static const char *
find (
const char *str,
size_t len);
705 static const unsigned char asso_values[] =
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, 5,
712 5, 30, 0, 49, 25, 49, 10, 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, 0, 49, 0, 5, 49,
717 15, 0, 49, 10, 49, 30, 49, 49, 0, 20,
718 0, 49, 15, 49, 5, 10, 0, 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, 49, 49, 49, 49,
732 49, 49, 49, 49, 49, 49
739 hval += asso_values[
static_cast<unsigned char>(str[4])];
742 hval += asso_values[
static_cast<unsigned char>(str[3])];
752 static const char *
const wordlist[] =
794 size_t key =
hash (str, len);
798 const char *s = wordlist[key];
800 if (*str == *s && !
dstrcmp (str + 1, s + 1))
824 std::unique_ptr<ArgumentList> al = std::make_unique<ArgumentList>();
825 if (argsString.
empty())
return al;
829 defargsYYlex_init_extra(&extra,&yyscanner);
836 defargsYYrestart(
nullptr, yyscanner );
838 defargsYYlex(yyscanner);
839 if (yyextra->argList->empty())
841 yyextra->argList->setNoParameters(
true);
843 if (extraTypeChars) *extraTypeChars=yyextra->extraTypeChars;
845 defargsYYlex_destroy(yyscanner);
849#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)