📄 code.l
字号:
if (YY_START==FuncCall && !g_insideBody) { g_theVarContext.pushScope(); } }<MemberCall2,FuncCall>")" { g_theCallContext.popScope(); g_code->codify(yytext); if (--g_bracketCount<=0) { if (!g_insideBody) { g_theVarContext.popScope(); } g_name.resize(0);g_args.resize(0); g_parmType.resize(0);g_parmName.resize(0); BEGIN( Body ); } }<MemberCall2,FuncCall>")"[ \t\n]*[;:] { codifyLines(yytext); g_bracketCount=0; if (yytext[yyleng-1]==';') g_searchingForBody=FALSE; if (!g_inClass && !g_type.isEmpty()) { g_theVarContext.addVariable(g_type,g_name); } g_parmType.resize(0);g_parmName.resize(0); g_theCallContext.popScope(); g_theCallContext.setClass(0); if (yytext[yyleng-1]==';' || g_insideBody) { if (!g_insideBody) { g_theVarContext.popScope(); } g_name.resize(0);g_type.resize(0); BEGIN( Body ); } else { g_bracketCount=0; BEGIN( SkipInits ); } }<MemberCall2,FuncCall>")"({BN}"const"|"volatile")*{BN}*"{" { if (g_insideBody) { g_theVarContext.pushScope(); } g_theVarContext.addVariable(g_parmType,g_parmName); g_theCallContext.popScope(); g_parmType.resize(0);g_parmName.resize(0); if (g_name.find("::")!=-1) { g_scopeStack.push(SCOPEBLOCK); setClassScope(g_realScope); } else { g_scopeStack.push(INNERBLOCK); } g_code->codify(")"); yytext[yyleng-1]='\0'; QCString cv(yytext+1); if (!cv.stripWhiteSpace().isEmpty()) { startFontClass("keyword"); codifyLines(yytext+1); endFontClass(); } else // just whitespace { codifyLines(yytext+1); } g_code->codify("{"); if (g_searchingForBody) { g_searchingForBody=FALSE; g_insideBody=TRUE; } if (g_insideBody) g_bodyCurlyCount++; g_curlyCount++; g_type.resize(0); g_name.resize(0); BEGIN( Body ); }<SkipInits>";" { g_code->codify(yytext); g_type.resize(0); g_name.resize(0); BEGIN( Body ); }<SkipInits>"{" { g_code->codify(yytext); g_curlyCount++; if (g_searchingForBody) { g_searchingForBody=FALSE; g_insideBody=TRUE; } if (g_insideBody) g_bodyCurlyCount++; if (g_name.find("::")!=-1) { g_scopeStack.push(SCOPEBLOCK); setClassScope(g_realScope); } else { g_scopeStack.push(INNERBLOCK); } g_type.resize(0); g_name.resize(0); BEGIN( Body ); }<SkipInits>{ID} { generateClassOrGlobalLink(*g_code,yytext); }<FuncCall>([a-z_A-Z][a-z_A-Z0-9]*)/"(" { generateFunctionLink(*g_code,yytext); }<FuncCall>([a-z_A-Z][a-z_A-Z0-9]*)/("."|"->") { //g_code->codify(yytext); g_name=yytext; generateClassOrGlobalLink(*g_code,yytext); BEGIN( MemberCall2 ); }<FuncCall,MemberCall2>("("{B}*("*"{B}*)*[a-z_A-Z][a-z_A-Z0-9]*{B}*")"{B}*)/("."|"->") { g_code->codify(yytext); int s=0;while (!isId(yytext[s])) s++; int e=yyleng-1;while (!isId(yytext[e])) e--; g_name=((QCString)yytext).mid(s,e-s+1); BEGIN( MemberCall2 ); }<MemberCall2>([a-z_A-Z][a-z_A-Z0-9]*)/([ \t\n]*"(") { if (!g_args.isEmpty()) generateMemberLink(*g_code,g_args,yytext); else generateClassOrGlobalLink(*g_code,yytext); g_args.resize(0); BEGIN( FuncCall ); }<MemberCall2>([a-z_A-Z][a-z_A-Z0-9]*)/([ \t\n]*("."|"->")) { //g_code->codify(yytext); g_name=yytext; generateClassOrGlobalLink(*g_code,yytext); BEGIN( MemberCall2 ); }<MemberCall2>"->"|"." { g_code->codify(yytext); g_memCallContext = YY_START; BEGIN( MemberCall ); }<SkipComment>"//" { g_code->codify(yytext); }<SkipComment>[^*/\n]+ { g_code->codify(yytext); }<SkipComment>[ \t]*"*/" { g_code->codify(yytext); endFontClass(); BEGIN( g_lastCContext ) ; }<SkipCxxComment>[^\r\n]+ { g_code->codify(yytext); }<SkipCxxComment>\r <SkipCxxComment>\n { unput('\n'); endFontClass(); BEGIN( g_lastCContext ) ; }<SkipCxxComment>. { g_code->codify(yytext); }<RemoveSpecialCComment>"*/"{B}*\n({B}*\n)*({B}*(("//@"[{}])|("/*@"[{}]"*/")){B}*\n)?{B}*"/*"[*!]/[^/*] { g_yyLineNr+=QCString(yytext).contains('\n'); }<RemoveSpecialCComment>"*/"{B}*\n({B}*\n)*({B}*(("//@"[{}])|("/*@"[{}]"*/")){B}*\n)? { g_yyLineNr+=QCString(yytext).contains('\n'); endCodeLine(); if (g_yyLineNr<g_inputLines) { startCodeLine(); } if (g_lastSpecialCContext==SkipCxxComment) { // force end of C++ comment here endFontClass(); BEGIN( g_lastCContext ) ; } else { BEGIN(g_lastSpecialCContext); } }<RemoveSpecialCComment>"*/" { BEGIN(g_lastSpecialCContext); }<RemoveSpecialCComment>[^*\n]+<RemoveSpecialCComment>"//"|"/*"<RemoveSpecialCComment>\n { g_yyLineNr++; }<RemoveSpecialCComment>.<*>\n({B}*"//"[!/][^\n]*\n)+ { // remove special one-line comment if (Config_getBool("STRIP_CODE_COMMENTS")) { g_yyLineNr+=((QCString)yytext).contains('\n'); endCodeLine(); if (g_yyLineNr<g_inputLines) { startCodeLine(); } } else { startFontClass("comment"); codifyLines(yytext); endFontClass(); } }<*>\n{B}*"//@"[{}].*\n { // remove one-line group marker if (Config_getBool("STRIP_CODE_COMMENTS")) { g_yyLineNr+=2; endCodeLine(); if (g_yyLineNr<g_inputLines) { startCodeLine(); } } else { startFontClass("comment"); codifyLines(yytext); endFontClass(); } }<*>\n{B}*"/*@"[{}] { // remove one-line group marker if (Config_getBool("STRIP_CODE_COMMENTS")) { g_lastSpecialCContext = YY_START; g_yyLineNr++; BEGIN(RemoveSpecialCComment); } else { // check is to prevent getting stuck in skipping C++ comments if (YY_START != SkipCxxComment) { g_lastCContext = YY_START ; } startFontClass("comment"); codifyLines(yytext); BEGIN(SkipComment); } }<*>^{B}*"//@"[{}].*\n { // remove one-line group marker if (Config_getBool("STRIP_CODE_COMMENTS")) { g_yyLineNr++; endCodeLine(); if (g_yyLineNr<g_inputLines) { startCodeLine(); } } else { startFontClass("comment"); codifyLines(yytext); endFontClass(); } }<*>^{B}*"/*@"[{}] { // remove multi-line group marker if (Config_getBool("STRIP_CODE_COMMENTS")) { g_lastSpecialCContext = YY_START; BEGIN(RemoveSpecialCComment); } else { // check is to prevent getting stuck in skipping C++ comments if (YY_START != SkipCxxComment) { g_lastCContext = YY_START ; } startFontClass("comment"); g_code->codify(yytext); BEGIN(SkipComment); } }<*>^{B}*"//"[!/][^\n]*\n { // remove special one-line comment if (Config_getBool("STRIP_CODE_COMMENTS")) { g_yyLineNr++; endCodeLine(); if (g_yyLineNr<g_inputLines) { startCodeLine(); } } else { startFontClass("comment"); codifyLines(yytext); endFontClass(); } }<*>"//"[!/][^\n]*\n { // strip special one-line comment if (Config_getBool("STRIP_CODE_COMMENTS")) { char c[2]; c[0]='\n'; c[1]=0; codifyLines(c); } else { startFontClass("comment"); codifyLines(yytext); endFontClass(); } }<*>\n{B}*"/*"[!*]/[^/*] { if (Config_getBool("STRIP_CODE_COMMENTS")) { g_lastSpecialCContext = YY_START; g_yyLineNr++; BEGIN(RemoveSpecialCComment); } else { // check is to prevent getting stuck in skipping C++ comments if (YY_START != SkipCxxComment) { g_lastCContext = YY_START ; } startFontClass("comment"); codifyLines(yytext); BEGIN(SkipComment); } }<*>^{B}*"/*"[!*]/[^/*] { // special C comment block at a new line if (Config_getBool("STRIP_CODE_COMMENTS")) { g_lastSpecialCContext = YY_START; BEGIN(RemoveSpecialCComment); } else { // check is to prevent getting stuck in skipping C++ comments if (YY_START != SkipCxxComment) { g_lastCContext = YY_START ; } startFontClass("comment"); g_code->codify(yytext); BEGIN(SkipComment); } }<*>"/*"[!*]/[^/*] { // special C comment block half way a line if (Config_getBool("STRIP_CODE_COMMENTS")) { g_lastSpecialCContext = YY_START; BEGIN(RemoveSpecialCComment); } else { // check is to prevent getting stuck in skipping C++ comments if (YY_START != SkipCxxComment) { g_lastCContext = YY_START ; } startFontClass("comment"); g_code->codify(yytext); BEGIN(SkipComment); } }<*>"/*"("!"?)"*/" { if (!Config_getBool("STRIP_CODE_COMMENTS")) { startFontClass("comment"); g_code->codify(yytext); endFontClass(); } }<*>"/*" { startFontClass("comment"); g_code->codify(yytext); // check is to prevent getting stuck in skipping C++ comments if (YY_START != SkipCxxComment) { g_lastCContext = YY_START ; } BEGIN( SkipComment ) ; }<*>"//" { startFontClass("comment"); g_code->codify(yytext); g_lastCContext = YY_START ; BEGIN( SkipCxxComment ) ; }<*>"(" { g_code->codify(yytext); g_theCallContext.pushScope(); }<*>")" { g_code->codify(yytext); g_theCallContext.popScope(); }<*>\n { codifyLines(yytext); }<*>. { g_code->codify(yytext); } /*<*>([ \t\n]*"\n"){2,} { // combine multiple blank lines //QCString sepLine=yytext; //g_code->codify("\n\n"); //g_yyLineNr+=sepLine.contains('\n'); //char sepLine[3]="\n\n"; codifyLines(yytext); } */%%/*@ ---------------------------------------------------------------------------- */void initParseCodeContext(){ g_theVarContext.clear(); g_codeClassSDict.setAutoDelete(TRUE); g_codeClassSDict.clear(); g_curClassBases.clear(); g_anchorCount = 0;}void parseCode(OutputDocInterface &od,const char *className,const QCString &s, bool exBlock, const char *exName,FileDef *fd, int startLine,int endLine,bool inlineFragment){ if (s.isEmpty()) return; g_code = od.clone(); g_inputString = s; g_inputPosition = 0; g_currentFontClass = 0; if (endLine!=-1) g_inputLines = endLine+1; else g_inputLines = countLines(); if (startLine!=-1) g_yyLineNr = startLine; else g_yyLineNr = 1; g_curlyCount = 0; g_bodyCurlyCount = 0; g_bracketCount = 0; g_sharpCount = 0; g_insideTemplate = FALSE; g_theCallContext.clear(); g_scopeStack.clear(); g_classScope = className; g_exampleBlock = exBlock; g_exampleName = exName; g_sourceFileDef = fd; g_currentDefinition = 0; g_currentMemberDef = 0; g_searchingForBody = FALSE; g_insideBody = FALSE; g_bracketCount = 0; if (!g_exampleName.isEmpty()) { g_exampleFile = convertNameToFile(g_exampleName+"-example"); } g_includeCodeFragment = inlineFragment; startCodeLine(); g_type.resize(0); g_name.resize(0); g_args.resize(0); g_parmName.resize(0); g_parmType.resize(0); codeYYrestart( codeYYin ); BEGIN( Body ); codeYYlex(); endFontClass(); if (g_inputLines==1) { g_code->endCodeLine(); } od.append(g_code); delete g_code; return;}extern "C" { // some bogus code to keep the compiler happy// int codeYYwrap() { return 1 ; } void codeYYdummy() { yy_flex_realloc(0,0); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -