📄 scanner.l
字号:
// annonymous compound inside -> insert dummy variable name //printf("Adding annonymous variable for scope %s\n",p->name.data()); msName.sprintf("@%d",anonCount++); break; } } p=p->parent; } } if (!msName.isEmpty()) { Entry *varEntry=new Entry; varEntry->protection = current->protection ; varEntry->mtype = current->mtype; varEntry->virt = current->virt; varEntry->stat = current->stat; varEntry->section = Entry::VARIABLE_SEC; varEntry->name = msName.stripWhiteSpace(); varEntry->type = current->type.simplifyWhiteSpace()+" "; varEntry->args = msArgs; //current->args.simplifyWhiteSpace(); //if (!current->name.isEmpty() && current->name[0]!='@' && // current->parent->section & Entry::COMPOUND_MASK) // varEntry->type+=current->parent->name+"::"; if (isTypedef) { varEntry->type.prepend("typedef "); // //printf("current->name = %s %s\n",current->name.data(),msName.data()); // if (!current->name.isEmpty() && current->name.at(0)!='@') // { // //printf("2>>>>>>>>>> adding %s->%s\n",msName.data(),current->name.data()); // QCString scope; // if (current_root->section & Entry::SCOPE_MASK) scope=current_root->name; // Doxygen::typedefDict.insert(msName,new TypedefInfo(current->name,scope)); // } } varEntry->type+=current->name+msType; varEntry->fileName = yyFileName; varEntry->startLine = yyLineNr; varEntry->doc = current->doc.copy(); varEntry->brief = current->brief.copy(); varEntry->mGrpId = current->mGrpId; // deep copy group list QListIterator<Grouping> gli(*current->groups); Grouping *g; for (;(g=gli.current());++gli) { varEntry->groups->append(new Grouping(*g)); } //printf("Add: type=`%s',name=`%s',args=`%s'\n", // varEntry->type.data(),varEntry->name.data(),varEntry->args.data()); current_root->addSubEntry(varEntry); } if (*yytext==';') { msType.resize(0); msName.resize(0); msArgs.resize(0); isTypedef=FALSE; current->reset(); initEntry(); BEGIN( FindMembers ); } } <MemberSpec>"=" { lastInitializerContext=YY_START; initializerSharpCount=0; BEGIN(ReadInitializer); /* BEGIN(MemberSpecSkip); */ } /*<MemberSpecSkip>"{" { curlyCount=0; lastCurlyContext = MemberSpecSkip; previous = current; BEGIN(SkipCurly); } */<MemberSpecSkip>"," { BEGIN(MemberSpec); }<MemberSpecSkip>";" { unput(';'); BEGIN(MemberSpec); }<ReadBody>{BN}+ { current->program += yytext ; lineCount() ; }<ReadBody>. { current->program += yytext ; }<FindMembers>("("({BN}*{ID}{BN}*"::")*({BN}*"*"{BN}*)+)+ { current->bodyLine = yyLineNr; lineCount(); addType(current); funcPtrType=yytext; roundCount=0; //current->type += yytext; BEGIN( FuncPtr ); }<FuncPtr>{SCOPENAME} { current->name = yytext; if (current->name=="const" || current->name=="volatile") { funcPtrType += current->name; } else { BEGIN( EndFuncPtr ); } }<FuncPtr>. { //printf("Error: FuncPtr `%c' unexpected at line %d of %s\n",*yytext,yyLineNr,yyFileName); }<EndFuncPtr>")"{BN}*/";" { // a variable with extra braces lineCount(); current->type+=funcPtrType.data()+1; BEGIN(FindMembers); }<EndFuncPtr>")"{BN}*/"(" { // a function pointer lineCount(); current->type+=funcPtrType+")"; BEGIN(FindMembers); }<EndFuncPtr>")"{BN}*/"[" { // an array of variables lineCount(); current->type+=funcPtrType.data(); current->args += ")"; BEGIN(FindMembers); }<EndFuncPtr>"(" { // a function returning a function current->args += *yytext ; roundCount=0; BEGIN( FuncFunc ); }<EndFuncPtr>"["[^\n\]]*"]" { funcPtrType+=yytext; }<EndFuncPtr>")" { BEGIN(FindMembers); }<FuncFunc>"(" { current->args += *yytext ; ++roundCount; }<FuncFunc>")" { current->args += *yytext ; if ( roundCount ) --roundCount; else { BEGIN(FuncFuncEnd); } }<FuncFuncEnd>")"{BN}*"(" { lineCount(); current->type+=funcPtrType+")("; BEGIN(FuncFuncType); }<FuncFuncEnd>")"{BN}*/[;{] { lineCount(); current->type+=funcPtrType.data()+1; BEGIN(Function); }<FuncFuncEnd>. { current->args += *yytext; }<FuncFuncType>"(" { current->type += *yytext; roundCount++; }<FuncFuncType>")" { current->type += *yytext; if (roundCount) --roundCount; else BEGIN(Function); }<FuncFuncType>{BN}*","{BN}* { lineCount() ; current->type += ", " ; }<FuncFuncType>{BN}+ { lineCount() ; current->type += ' ' ; }<FuncFuncType>. { current->type += *yytext; }<FindMembers>"("/{BN}*{ID}{BN}*"*" { // for catching typedef void (__stdcall *f)() like definitions if (current->type.left(7)=="typedef" && current->bodyLine==-1) // the bodyLine check is to prevent this guard to be true more than once { current->bodyLine = yyLineNr; BEGIN( GetCallType ); } else if (!current->name.isEmpty()) // normal function { current->args = yytext; current->bodyLine = yyLineNr; currentArgumentContext = FuncQual; fullArgString=current->args.copy(); copyArgString=¤t->args; BEGIN( ReadFuncArgType ) ; //printf(">>> Read function arguments!\n"); } }<GetCallType>{BN}*{ID}{BN}*"*" { lineCount(); addType(current); funcPtrType="("; funcPtrType+=yytext; roundCount=0; BEGIN( FuncPtr ); }<FindMembers>"(" { if (!current->name.isEmpty()) { current->args = yytext; current->bodyLine = yyLineNr; currentArgumentContext = FuncQual; fullArgString=current->args.copy(); copyArgString=¤t->args; BEGIN( ReadFuncArgType ) ; //printf(">>> Read function arguments!\n"); } } /*<FindMembers>"("{BN}*("void"{BN}*)?")" { lineCount(); current->args = "()"; BEGIN( FuncQual ); } */ /*- Function argument reading rules ---------------------------------------*/<ReadFuncArgType>[^ \/\r\t\n\)\(\"\']+ { *copyArgString+=yytext; fullArgString+=yytext; }<CopyArgString>[^\n\\\"\']+ { *copyArgString+=yytext; fullArgString+=yytext; }<CopyArgRound>[^\/\n\)\(\"\']+ { *copyArgString+=yytext; fullArgString+=yytext; }<ReadFuncArgType,ReadTempArgs>{BN}* { *copyArgString+=" "; fullArgString+=" "; lineCount(); }<ReadFuncArgType,CopyArgRound,CopyArgSharp,ReadTempArgs>\" { *copyArgString+=*yytext; fullArgString+=*yytext; lastCopyArgStringContext = YY_START; BEGIN( CopyArgString ); }<ReadFuncArgType,ReadTempArgs>"(" { *copyArgString+=*yytext; fullArgString+=*yytext; argRoundCount=0; lastCopyArgContext = YY_START; BEGIN( CopyArgRound ); }<ReadFuncArgType>")" { *copyArgString+=*yytext; fullArgString+=*yytext; stringToArgumentList(fullArgString,current->argList); BEGIN( currentArgumentContext ); } /* a special comment */<ReadFuncArgType>("/*"[*!]|"//"[/!])("<"?) { fullArgString+=yytext; lastCopyArgChar=0; if (yytext[1]=='/') BEGIN( CopyArgCommentLine ); else BEGIN( CopyArgComment ); } /* `)' followed by a special comment */<ReadFuncArgType>")"{BN}*("/*"[*!]|"//"[/!])"<" { lineCount(); lastCopyArgChar=*yytext; QCString text=&yytext[1]; text=text.stripWhiteSpace(); fullArgString+=text; if (text.find("//")!=-1) BEGIN( CopyArgCommentLine ); else BEGIN( CopyArgComment ); }<CopyArgComment>[^\n\*]+ { fullArgString+=yytext; }<CopyArgComment>"*/" { fullArgString+=yytext; if (lastCopyArgChar!=0) unput(lastCopyArgChar); BEGIN( ReadFuncArgType ); }<CopyArgCommentLine>\n { fullArgString+=yytext; yyLineNr++; if (lastCopyArgChar!=0) unput(lastCopyArgChar); BEGIN( ReadFuncArgType ); }<CopyArgCommentLine>[^\n]+ { fullArgString+=yytext; }<CopyArgComment>\n { fullArgString+=*yytext; yyLineNr++; }<CopyArgComment>. { fullArgString+=*yytext; }<ReadTempArgs>"<" { *copyArgString+=*yytext; fullArgString+=*yytext; argSharpCount=1; BEGIN( CopyArgSharp ); }<ReadTempArgs>">" { *copyArgString+=*yytext; fullArgString+=*yytext; //printf("end template list %s\n",copyArgString->data()); stringToArgumentList(fullArgString,currentArgumentList); BEGIN( currentArgumentContext ); }<CopyArgRound>"(" { argRoundCount++; *copyArgString+=*yytext; fullArgString+=*yytext; }<CopyArgRound>")" { *copyArgString+=*yytext; fullArgString+=*yytext; if (argRoundCount>0) argRoundCount--; else BEGIN( lastCopyArgContext ); }<CopyArgSharp>"<" { argSharpCount++; //printf("argSharpCount++=%d copy\n",argSharpCount); *copyArgString+=*yytext; fullArgString+=*yytext; }<CopyArgSharp>">" { *copyArgString+=*yytext; fullArgString+=*yytext; argSharpCount--; if (argSharpCount>0) { //printf("argSharpCount--=%d copy\n",argSharpCount); } else { BEGIN( ReadTempArgs ); //printf("end of argSharpCount\n"); } }<CopyArgString>\\. { *copyArgString+=yytext; fullArgString+=yytext; }<CopyArgString>\" { *copyArgString+=*yytext; fullArgString+=*yytext; BEGIN( lastCopyArgStringContext ); }<ReadFuncArgType,ReadTempArgs,CopyArgRound,CopyArgSharp>{CHARLIT} { *copyArgString+=yytext; fullArgString+=yytext; }<ReadFuncArgType,ReadTempArgs,CopyArgString,CopyArgRound,CopyArgSharp>\n { yyLineNr++; *copyArgString+=*yytext; fullArgString+=*yytext; }<ReadFuncArgType,ReadTempArgs,CopyArgString,CopyArgRound,CopyArgSharp>. { *copyArgString+=*yytext; fullArgString+=*yytext; } /*------------------------------------------------------------------------*/<FuncRound>"(" { current->args += *yytext ; ++roundCount ; }<FuncRound>")" { current->args += *yytext ; if ( roundCount ) --roundCount ; else BEGIN( FuncQual ) ; } /*<FuncQual>"#" { lastCPPContext = YY_START; BEGIN(SkipCPP); } */<FuncQual>[{:;] { unput(*yytext); BEGIN( Function ); }<FuncQual>{BN}*"const"{BN}* { lineCount() ; current->args += " const "; current->argList->constSpecifier=TRUE; }<FuncQual>{BN}*"volatile"{BN}* { lineCount() ; current->args += " volatile "; current->argList->volatileSpecifier=TRUE; }<FuncQual>{BN}*"="{BN}*"0"{BN}* { lineCount() ; current->args += " = 0"; current->virt = Pure; current->argList->pureSpecifier=TRUE; }<FuncRound,FuncFunc>{BN}*","{BN}* { lineCount() ; current->args += ", " ; }<FuncQual,FuncRound,FuncFunc>{BN}+ { lineCount() ; current->args += ' ' ; }<FuncQual,FuncRound,FuncFunc>. { current->args += *yytext; }<FuncQual>{BN}*"try"{BN}+ { /* try-function-block */ insideTryBlock=TRUE; }<FuncQual>{BN}*"throw"{BN}*"(" { current->exception = " throw (" ; roundCount=0; lineCount() ; BEGIN( ExcpRound ) ; }<FuncQual>{BN}*"raises"{BN}*"(" { current->exception = " raises (" ; lineCount() ; roundCount=0; BEGIN( ExcpRound ) ; }<ExcpRound>"(" { current->exception += *yytext ; ++roundCount ; }<ExcpRound>")" { current->exception += *yytext ; if ( roundCount ) --roundCount ; else BEGIN( FuncQual ) ; }<ExcpRound>. { current->exception += yytext; }<Function>"(" { current->type += current->name ; current->name = current->arg
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -