📄 cpp.ll
字号:
}<ClassName>[a-z_A-Z0-9\[\]*&]+("::"[a-z_A-Z0-9\[\]*&]+)* { current->type += ' '; current->type += current->name; current->name = yytext; }<ClassName>"<".*">" { // FIXME: dirty hack to allow partially // specialized templates current->name += yytext; }<ClassName>[ \t]*":"[ \t]* { current->args = ":"; BEGIN(Bases); }<Bases,ClassName,IdlSwitch>[ \t]*"{"[ \t]* {#ifdef DEBUG debug("found `%s %s'", current->type.c_str(), current->name.c_str());#endif current->file = yyFileName; current->startLine = yyLineNr; ++curlyBracketCount; innerCurlyCount = 0; BEGIN(Curly); }<Bases,ClassName>[ \t]*";" { current->file = yyFileName; current->startLine = yyLineNr; innerCurlyCount = 0; if(current->section == TYPEDEF_SEC || current->section == UNION_SEC) {#ifdef DEBUG debug("found `%s %s'", current->type.c_str(), current->name.c_str());#endif if(current->section == UNION_SEC) // hack for C-style structs current->section = VARIABLE_SEC; current_root->addSubEntry(current); current->file = yyFileName; last = current; current = new Entry; current->protection = protection; BEGIN(FindMembersSuffix); } else {#ifdef DEBUG debug("found forward class declaration `%s'", current->name.c_str());#endif current->clear(); } BEGIN(FindMembers); }<Bases>[a-z_A-Z*.<>0-9:]+ { current->extends.append( new McString(yytext)); current->args += ' '; current->args += yytext; }<Bases>"," { current->args += ','; }<Comment>\n { current->program += yytext; yyLineNr++; }<Comment>"//"<Comment>. { current->program += yytext; }<Comment>.*"*/" { current->program += yytext; BEGIN(Curly); }<FindMembers>[ \t\n]*("///"|"//{{{")[ \t]* { lineCount(); current->docify = true; if(current->doc.length() > 0 || current->memo.length() > 0) {#ifdef DEBUG debug("found commented entry");#endif current->file = yyFileName; current_root->addSubEntry(current); last = current; current = new Entry; } else current->clear(); BEGIN(Cxx_Memo); }<Cxx_Memo>.* { current->doc += yytext; }<Cxx_Memo>\n { yyLineNr++; BEGIN(FindMembers); }<FindMembers>[ \t\n]*"/*""*"+"/"<FindMembers>[ \t\n]*"/***""*"* { lastCContext = YY_START; lineCount(); BEGIN(SkipComment); }<FindMembers>[ \t\n]*"////"* { lastCContext = YY_START; lineCount(); }<FindMembers>[ \t\n]*("/**"|"/*{{{")[ \t]* { lineCount(); current->docify = true; if(current->doc.length() > 0 || current->memo.length() > 0) {#ifdef DEBUG debug("found commented entry");#endif current_root->addSubEntry(current); current->file = yyFileName; last = current; current = new Entry; } else current->clear(); BEGIN(Doc); }<VerbDoc,Doc>\n[ \t]*"*"+"/" { lineCount(); BEGIN(FindMembers); }<Namespace>[a-z_A-Z0-9]* { McString tmp; // maybe we have to deal with a // hierarchy of namespaces here if(current_root->section == NAMESPACE_SEC) tmp = current_root->fullName + "::"; else addNamespace(current_root); tmp += yytext; Entry *find = findEntry(current_root->sub, tmp.c_str(), NAMESPACE_SEC); if(find) { current_root = find; if(find->doc.length() == 0 && current->doc.length() > 0) find->doc = current->doc; if(find->memo.length() == 0 && current->memo.length() > 0) find->memo = current->memo; last = find; // do not doc this namespace twice delete current; current = new Entry; } else if(current->doc.length() > 0 || current->memo.length() > 0 || !onlyDocs) // ignore the namespace if it's not // doc++-commented or not in // 'document all' mode {#ifdef DEBUG debug("found namespace `%s'", yytext);#endif current->docify = true; current->name = yytext; current->file = yyFileName; current_root->addSubEntry(current); current_root = current; last = current; current = new Entry; } }<Namespace>"{" { ++curlyBracketCount; BEGIN(FindMembers); }<UsingNamespace>[a-z_A-Z0-9]+("::"[a-z_A-Z0-9]+)* { Entry *find = findEntry(current_root->sub, yytext, NAMESPACE_SEC); if(find) { // add the namespace to the lookup // table, which will tell us where // to look when a identifier isn't // known namespace_entry *n = new namespace_entry; n->name = new char[strlen(yytext) + 1]; strcpy(n->name, yytext); n->innerCurlyCount = innerCurlyCount; namespace_table.append(n);#ifdef DEBUG debug("Namespace `%s' appended to lookup table", yytext);#endif } else msg("Warning: unknown namespace `%s', ignoring `using' keyword\n", yytext); }<UsingNamespace>; { BEGIN(FindMembers); }<Doc>"\\begin{verbatim}" { current->doc += yytext; if(!HTMLsyntax) BEGIN(VerbDoc); }<Doc>"<"[pP][rR][eE]">" { if(HTMLsyntax) { current->doc += "<PRE>"; BEGIN(VerbDoc); } else current->doc += yytext; }<VerbDoc>\n { current->doc += '\n'; yyLineNr++; }<VerbDoc>"\\end{verbatim}" { current->doc += yytext; if(!HTMLsyntax) BEGIN(Doc); }<VerbDoc>"</"[pP][rR][eE]">" { if(HTMLsyntax) { current->doc += "</PRE>"; BEGIN(Doc); } else current->doc += yytext; }<Doc>\n[ \t]*"*"*[ \t]* { current->doc += '\n'; yyLineNr++; }<VerbDoc,Doc>. { current->doc += *yytext; }<VerbDoc,Doc>"//" { current->doc += yytext; }<VerbDoc,Doc>"/*" { current->doc += yytext; }<VerbDoc,Doc>"*/" { BEGIN(FindMembers); }<FindMembers>("//@{".*\n)|("/*@{"[^*]*\*+"/") { lineCount(); current->file = yyFileName; current->startLine = yyLineNr; innerCurlyCount = 0; BEGIN(SubDoc); }<SubDoc>"/*" { current->program += yytext; BEGIN(SubDocComment); }<SubDoc>"//" { current->program += yytext; BEGIN(SubDocCppComment); }<SubDoc>. { current->program += *yytext; }<SubDoc>\n { current->program += *yytext; ++yyLineNr; }<SubDoc>("//@{".*\n)|("/*@{"[^*]*\*+"/") { lineCount(); current->program += yytext; ++curlyBracketCount; ++innerCurlyCount; }<SubDoc>("//@}".*\n)|("/*@}"[^*]*\*+"/") { lineCount(); if(curlyBracketCount > 0) --curlyBracketCount; if(innerCurlyCount > 0) { current->program += yytext; --innerCurlyCount; } else {#ifdef DEBUG debug("found explicit subentry");#endif current->docify = true; current_root->addSubEntry(current); last = current; current = new Entry; current->protection = protection; BEGIN(FindMembers); } }<SubDocComment,SubDocCppComment>"/*" { current->program += yytext; }<SubDocComment,SubDocCppComment>"//" { current->program += yytext; }<SubDocComment>. { current->program += yytext; }<SubDocComment>\n { current->program += yytext; ++yyLineNr; }<SubDocComment>"*/" { current->program += yytext; BEGIN(SubDoc); }<SubDocCppComment>. { current->program += yytext; }<SubDocCppComment>\n { current->program += yytext; ++yyLineNr; BEGIN(SubDoc); }<SkipComment>"//"<SkipComment>[ \t]*"*/" { BEGIN(lastCContext); }<*>"//" { lastCContext = YY_START; BEGIN(SkipCxxComment); }<SkipCxxComment>.*\n { yyLineNr++; BEGIN(lastCContext); }<*>.<*>\n { yyLineNr++; }<*>"/*" { lastCContext = YY_START; BEGIN(SkipComment); }%%void callcppYYlex(){ cppYYlex(); if(current->name.length() || current->program.length() || current->memo.length() || current->doc.length()) { current->docify = true; if(current->section == EMPTY_SEC) current->section = VARIABLE_SEC; current_root->addSubEntry(current); last = current; current->file = yyFileName; current = new Entry; current->protection = protection; }}void parseCppClasses(Entry *rt){ Entry *cr; if(rt == 0) return; for(cr = rt->sub; cr; cr = cr->next) {#ifdef DEBUG if(verb) { printf("Scanning `%s %s%s'", cr->type.c_str(), cr->name.c_str(), cr->args.c_str()); if(cr->program.length()) printf("..."); printf("\n"); }#endif if(cr->program.length() > 0) { cr->program += '\n'; inputString = cr->program.c_str(); inputPosition = 0; cppYYrestart(cppYYin); BEGIN(FindMembers); current_root = cr; strcpy(yyFileName, cr->file.c_str()); yyLineNr = cr->startLine; current->clear(); if(cr->section & CLASS_SEC) current->protection = protection = PRIV; else current->protection = protection = PUBL; callcppYYlex(); cr->program.clear(); } parseCppClasses(cr); } parseDoc(rt);}void buildFullName(Entry *entry){ Entry *tmp; for(tmp = entry; tmp; tmp = tmp->next) { tmp->makeFullName(); buildFullName(tmp->sub); }}void removeNotDocified(Entry *entry){ Entry *index = entry, *tmp; for(; index; index = tmp) { if(index->sub) removeNotDocified(index->sub); tmp = index->next; if((!index->docify || !MAKE_DOC(index)) && index != root) index->parent->removeSub(index); }}void parseCpp(Entry *rt){ assert(rt); current_root = rt; global_root = rt; protection = PUBL; current = new Entry; last = current; inputString = rt->program.c_str(); inputPosition = 0; cppYYrestart(cppYYin); BEGIN(FindMembers); callcppYYlex(); rt->program.clear(); parseCppClasses(rt); removeNotDocified(rt); buildFullName(rt); delete current;}extern "C" { int cppYYwrap() { return 1; }};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -