📄 java.ll
字号:
BEGIN(ClassName); }<FindMembers>[ \t]*"interface"[ \t]+ {// same for a nested interface here current->section = INTERFACE_SEC; current->type += "interface"; msg("found interface `%s'", current->name.c_str()); BEGIN(ClassName); }<FindMembers>[ \t]*"static"[ \t]* {// we notice all of the allowed keywords here but don't do anything accept// adding it to type current->type += "static "; }<FindMembers>[ \t]*"synchronized"[ \t]* { current->type += "synchronized "; }<FindMembers>[ \t]*"volatile"[ \t]* { current->type += "volatile "; }<FindMembers>[ \t]*"transient"[ \t]* { current->type += "transient "; }<FindMembers>[ \t]*"native"[ \t]* { current->type += "native "; }<FindMembers>[ \t]*"final"[ \t]* { current->type += "final "; }<FindMembers>[ \t]*"///$$filename"[ \t]+ { // search for file name marker inserted // in `readfiles.ll' BEGIN(File); }<File>.* { // found a file name: now use it as the // current file name strcpy(yyFileName, yytext); }<File>\n { BEGIN(FindMembers); }<FindMembers>[a-z_A-Z.0-9]+ {// if we find a non-keyword word, make note of it and go to rule <Member> if(current->type.length()) current->type += ' '; current->type += current->name; current->name = yytext; BEGIN(Member); }<Member>[a-z_A-Z.0-9]+ {// The rule <Member> I had to make a small adjustment:// splitting <Member>[;=] into <Member>";" and <Member>"="// (see below for explaination) if(current->type.length()) current->type += ' '; current->type += current->name; current->name = yytext; }<Member>";" {// this is "business as usual" current->section = VARIABLE_SEC; current_root->addSubEntry(current); msg("found field `%s'", current->name.c_str()); current = new Entry; BEGIN(FindMembers); }<Member>"=" {// we made this an extra rule because otherwise the initialized had been// treated as Member (which it obviously isn't). So if we have an "=", we go to// a new rule <SkipToSemi> where we skip everything including the ending ";"// then we go to FindMembers current->section = VARIABLE_SEC; current_root->addSubEntry(current); msg("found field `%s'", current->name.c_str()); current = new Entry; skip_to_semi_count = 0; // we count bracket-levels "{}" BEGIN(SkipToSemi); }<SkipToSemi>"{" {// We take care for bracket-levels because there might be definition of an// anonymous class here that makes use of Semicolons we are not interested in. skip_to_semi_count++; }<SkipToSemi>"(" { skip_to_semi_count++; }<SkipToSemi>"[" { skip_to_semi_count++; }<SkipToSemi>"}" { skip_to_semi_count--; }<SkipToSemi>")" { skip_to_semi_count--; }<SkipToSemi>"]" { skip_to_semi_count--; }<SkipToSemi>";" {// So if there is a semicolon at "our" bracket level, we expect members again. if(skip_to_semi_count == 0) BEGIN(FindMembers); }<Member>"(" { current->section = FUNCTION_SEC; current->args = yytext; msg("found method `%s'", current->name.c_str()); BEGIN(Args); }<Args>")" { current->args += *yytext; BEGIN(Function); }<Args>. { current->args += *yytext; }<Function>[ \t]*"throws"[ \t]+ { BEGIN(Throws);// I changed <Function> in order to skip method(function)-body *totally*. I// hope this is ok.// In order to do so, after getting the "{", we skip to the corresponding "}"// using an extra new rule <SkipToBracket> current->args += " throws "; }<Function>";" { current_root->addSubEntry(current); current = new Entry; BEGIN(FindMembers); }<Function>"{" { current_root->addSubEntry(current); current = new Entry; skip_to_bracket_count = 1; // we take care of bracket level BEGIN(SkipToBracket); }<SkipToBracket>"{" { // this skips the function body. skip_to_bracket_count++; }<SkipToBracket>"}" { if(--skip_to_bracket_count == 0) BEGIN(FindMembers); }<Throws>[a-z_A-Z.0-9]+[ \t]*, { current->args += yytext; }<Throws>[a-z_A-Z.0-9]+ { current->args += yytext; BEGIN(Function); }<Comment>\n { current->program += yytext; yyLineNr++; }<Comment>. { current->program += yytext; }<Comment>.*"*/" { current->program += yytext; BEGIN(lastContext); }<SkipComment>[ \t]*"*/" { BEGIN(lastContext); }<SkipComment>"/*""*"*"*/"<SkipComment>[ \t\n]*"/**""*"*[ \t]*<SkipString>[\"\'] { if(*yytext == ssEndChar) BEGIN(lastContext); if(ssSave) current->program += *yytext; }<SkipString>\\. { if(ssSave) current->program += yytext; }<SkipString>. { if(ssSave) current->program += *yytext; }<FindClasses,ClassName,Package,Import,Extends,Implements,FindMembers,Member,Args,Function,Throws,See,Author,Version,Param,Return,Exception,Precondition,Postcondition,Invariant>[ \t\n]*"/**""*"*[ \t]* { lastContext = YY_START; lineCount(); current->doc.clear(); BEGIN(JavaDoc); }<JavaDoc>\n { current->doc += *yytext; yyLineNr++; }<JavaDoc>[\n \t]*"*"+"/" {// Before the fix, it was context-sensitive which state to go next - depending// on current->section. I changed this, since it doesn't make sense. BEGIN(lastContext); }<JavaDoc>\n[ \t]*"*"*[ \t]* { current->doc += '\n'; yyLineNr++; }<JavaDoc>. { current->doc += *yytext; }<FindClasses,ClassName,Package,Import,Extends,Implements,FindMembers,Member,Args,Function,Throws,See,Author,Version,Param,Return,Exception,Precondition,Postcondition,Invariant>"/*" { if(YY_START != SkipComment) // Default rules are hellspawn lastContext = YY_START; BEGIN(SkipComment); }<FindClasses,ClassName,Package,Import,Extends,Implements,FindMembers,Member,Args,Function,Throws,See,Author,Version,Param,Return,Exception,Precondition,Postcondition,Invariant>[ \t]*"*/" { BEGIN(lastContext); }<FindClasses,ClassName,Package,Import,Extends,Implements,FindMembers,Member,Args,Function,Throws,See,Author,Version,Param,Return,Exception,Precondition,Postcondition,Invariant>"/*""*"*"*/"<FindClasses,ClassName,Package,Import,Extends,Implements,FindMembers,Member,Args,Function,Throws,See,Author,Version,Param,Return,Exception,Precondition,Postcondition,Invariant>[\"\'] { ssEndChar = *yytext; ssSave = 0; lastContext = YY_START; BEGIN(SkipString); }<FindClasses,ClassName,Package,Import,Extends,Implements,FindMembers,Member,Args,Function,Throws,See,Author,Version,Param,Return,Exception,Precondition,Postcondition,Invariant>\/\/.*\n<*>.<*>\n { yyLineNr++; }%%void parseJavaClasses(Entry *rt){ if(rt == 0) return; for(Entry *cr = rt->sub; cr; cr = cr->next) { if(cr->program.length()) { inputString = cr->program.c_str(); inputPosition = 0; javaYYrestart(javaYYin); // We're looking for members and nested classes. findClasses = false; BEGIN(FindMembers); current_root = cr; strcpy(yyFileName, cr->file.c_str()); yyLineNr = cr->startLine; javaYYlex(); cr->program.clear(); } parseJavaClasses(cr); } parseDoc(rt);}void parseJava(Entry *rt){ assert(rt); current_root = rt; global_root = rt; current = new Entry; inputString = rt->program.c_str(); inputPosition = 0; javaYYrestart(javaYYin); // We're looking for first-level Classes. BEGIN(FindClasses); findClasses = true; javaYYlex(); rt->program.clear(); parseJavaClasses(rt); delete current;}extern "C" { int javaYYwrap() { return 1; }};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -