diff options
Diffstat (limited to 'src/tclscanner.l')
-rw-r--r-- | src/tclscanner.l | 190 |
1 files changed, 105 insertions, 85 deletions
diff --git a/src/tclscanner.l b/src/tclscanner.l index 88bd474..a4709ce 100644 --- a/src/tclscanner.l +++ b/src/tclscanner.l @@ -59,6 +59,8 @@ #define MAX_INCLUDE_DEPTH 10 +static const char *stateToString(int state); + //! Application error. #define tcl_err \ printf("Error %d %s() at line %d! ",__LINE__,tcl.file_name.data(),yylineno); \ @@ -423,11 +425,11 @@ static struct int code_linenumbers; // if true create line numbers in code const char *code_font; // used font to codify bool config_autobrief; // value of configuration option - QMap<QString,QString> config_subst; // map of configuration option values + QMap<QCString,QCString> config_subst; // map of configuration option values QCString input_string; // file contents int input_position; // position in file QCString file_name; // name of used file - ParserInterface *this_parser; // myself + OutlineParserInterface *this_parser; // myself int command; // true if command was found int comment; // set true if comment was scanned int brace_level; // bookkeeping of braces @@ -462,7 +464,7 @@ static struct // scanner functions static int yyread(char *buf,int max_size); -static tcl_scan *tcl_scan_start(char type, QString content, QCString ns, Entry *entry_cls, Entry *entry_fn); +static tcl_scan *tcl_scan_start(char type, QCString content, QCString ns, Entry *entry_cls, Entry *entry_fn); static void tcl_scan_end(); static void tcl_comment(int what,const char *text); static void tcl_word(int what,const char *text); @@ -484,6 +486,8 @@ Entry* tcl_entry_new() // myEntry->mtype = Method; // myEntry->virt = Normal; // myEntry->stat = FALSE; + myEntry->docFile = tcl.file_name; + myEntry->inbodyFile = tcl.file_name; myEntry->fileName = tcl.file_name; myEntry->lang = SrcLangExt_Tcl; Doxygen::docGroup.initGroupInfo(myEntry); @@ -533,6 +537,13 @@ static void tcl_name(const QCString &ns0, const QCString &name0, QCString &ns, Q ns = ""; name = myNm; } + else if (myNm.length()-myStart == 2) + { + // ending with :: so get name equal to last component + ns = myNm.mid(0,myStart); + myStart = ns.findRev("::"); + name = myNm.mid(myStart+2); + } else { ns = myNm.mid(0,myStart); @@ -576,7 +587,7 @@ Entry* tcl_entry_namespace(const QCString ns) myEntry = tcl_entry_new(); myEntry->section = Entry::NAMESPACE_SEC; myEntry->name = ns; - tcl.entry_main->addSubEntry(myEntry); + tcl.entry_main->moveToSubEntryAndKeep(myEntry); tcl.ns.insert(ns,myEntry); } return myEntry; @@ -595,7 +606,7 @@ Entry* tcl_entry_class(const QCString cl) myEntry = tcl_entry_new(); myEntry->section = Entry::CLASS_SEC; myEntry->name = cl; - tcl.entry_main->addSubEntry(myEntry); + tcl.entry_main->moveToSubEntryAndKeep(myEntry); tcl.cl.insert(cl,myEntry); } return myEntry; @@ -727,7 +738,7 @@ static void tcl_codify(const char *s,const char *str) } //! Codify 'str' with special font class 's'. -static void tcl_codify(const char *s,const QString &str) +static void tcl_codify(const char *s,const QCString &str) { if (tcl.code==NULL) return; tcl_codify(s,str); @@ -1133,10 +1144,10 @@ D //! Start new scan context for given 'content'. // @return created new scan context. -static tcl_scan *tcl_scan_start(char type, QString content, QCString ns, Entry *entry_cl, Entry *entry_fn) +static tcl_scan *tcl_scan_start(char type, QCString content, QCString ns, Entry *entry_cl, Entry *entry_fn) { tcl_scan *myScan=tcl.scan.at(0); -tcl_inf("line=%d type=%d '%s'\n",tcl.line_body0,type,content.ascii()); +tcl_inf("line=%d type=%d '%s'\n",tcl.line_body0,type,content.data()); myScan->line1=yylineno; yy_push_state(TOP); @@ -1165,7 +1176,7 @@ tcl_inf("line=%d type=%d '%s'\n",tcl.line_body0,type,content.ascii()); myScan->entry_cl = entry_cl; myScan->entry_fn = entry_fn; myScan->entry_scan = tcl.entry_current; - myScan->buffer_state=yy_scan_string(content.ascii()); + myScan->buffer_state=yy_scan_string(content.data()); myScan->line0=tcl.line_body0; myScan->line1=tcl.line_body1; myScan->after.clear(); @@ -1492,7 +1503,7 @@ tcl_inf("-> %s\n",(const char *)tcl.string_comment); { tcl_inf("-> %s\n",(const char *)tcl.string_comment); int myPos=0; - bool myNew=0; + bool myNew=false; int myLine=tcl.line_comment; BufStr myI(1024); BufStr myO(1024); @@ -1538,7 +1549,7 @@ tcl_inf("-> %s\n",(const char *)tcl.string_comment); processedDoc = preprocessCommentBlock(myDoc,tcl.file_name,myLine0); parseCommentBlock(tcl.this_parser, myEntry, processedDoc, tcl.file_name, myLine0, FALSE, tcl.config_autobrief, FALSE, myProt, myPos0, myNew); - tcl.entry_inside->addSubEntry(myEntry); + tcl.entry_inside->moveToSubEntryAndRefresh(myEntry); } else { // we can add to current entry in this case @@ -1560,7 +1571,7 @@ tcl_inf("-> %s\n",(const char *)tcl.string_comment); processedDoc = preprocessCommentBlock(myDoc,tcl.file_name,myLine0); parseCommentBlock(tcl.this_parser, myEntry, processedDoc, tcl.file_name, myLine0, FALSE, tcl.config_autobrief, FALSE, myProt, myPos0, myNew); - tcl.entry_inside->addSubEntry(myEntry); + tcl.entry_inside->moveToSubEntryAndKeep(myEntry); } else { // we can add to current entry @@ -1583,7 +1594,7 @@ tcl_inf("-> %s\n",(const char *)tcl.string_comment); { if (myNew) { - tcl.entry_inside->addSubEntry(tcl.entry_current); + tcl.entry_inside->moveToSubEntryAndKeep(tcl.entry_current); tcl.entry_current = tcl_entry_new(); } else @@ -1594,7 +1605,7 @@ tcl_inf("-> %s\n",(const char *)tcl.string_comment); } if (myNew) { - tcl.entry_inside->addSubEntry(tcl.entry_current); + tcl.entry_inside->moveToSubEntryAndKeep(tcl.entry_current); tcl.entry_current = tcl_entry_new(); } else @@ -1620,37 +1631,32 @@ tcl_inf("-> %s\n",(const char *)tcl.string_comment); static void tcl_command_ARGLIST(QCString &arglist) { D - Argument *myArg; QCStringList myArgs; QCString myArglist=""; - if (!tcl.entry_current->argList) - { - tcl.entry_current->argList=new ArgumentList; - } tcl_split_list(arglist,myArgs); for (uint i=0;i<myArgs.count();i++) { QCStringList myArgs1; - myArg=new Argument; + Argument myArg; tcl_split_list(*myArgs.at(i),myArgs1); if (myArgs1.count()==2) { - myArg->name= (*myArgs1.at(0)); - myArg->defval= (*myArgs1.at(1)); - if (myArg->defval.isEmpty()) + myArg.name= (*myArgs1.at(0)); + myArg.defval= (*myArgs1.at(1)); + if (myArg.defval.isEmpty()) { - myArg->defval = " "; + myArg.defval = " "; } - myArglist += "?" + QCString(myArg->name) + "? "; + myArglist += "?" + QCString(myArg.name) + "? "; } else { - myArg->name= (*myArgs.at(i)); - myArglist += myArg->name + " "; + myArg.name= (*myArgs.at(i)); + myArglist += myArg.name + " "; } - tcl.entry_current->argList->append(myArg); + tcl.entry_current->argList.push_back(myArg); } arglist = myArglist; tcl.entry_current->args = arglist; @@ -2149,11 +2155,13 @@ D tcl.entry_current->mtype = Method; tcl.entry_current->name = myName; tcl.entry_current->startLine = tcl.line_command; + tcl.entry_current->docLine = tcl.line_comment; + tcl.entry_current->inbodyLine = tcl.line_comment; tcl.entry_current->bodyLine = tcl.line_body0; tcl.entry_current->endBodyLine = tcl.line_body1; tcl_protection(tcl.entry_current); tcl_command_ARGLIST(*tcl.list_commandwords.at(4)); - myEntryNs->addSubEntry(tcl.entry_current); + myEntryNs->moveToSubEntryAndKeep(tcl.entry_current); myEntry = tcl.entry_current; tcl.fn.insert(myName,myEntry); myScan = tcl_scan_start(tcl.word_is,*tcl.list_commandwords.at(6), @@ -2191,11 +2199,13 @@ D tcl.entry_current->mtype = Method; tcl.entry_current->name = myName; tcl.entry_current->startLine = tcl.line_command; + tcl.entry_current->docLine = tcl.line_comment; + tcl.entry_current->inbodyLine = tcl.line_comment; tcl.entry_current->bodyLine = tcl.line_body0; tcl.entry_current->endBodyLine = tcl.line_body1; tcl_protection(tcl.entry_current); tcl_command_ARGLIST(*tcl.list_commandwords.at(4)); - myEntryCl->addSubEntry(tcl.entry_current); + myEntryCl->moveToSubEntryAndKeep(tcl.entry_current); tcl.fn.insert(myName,tcl.entry_current); myEntry = tcl.entry_current; myScan = tcl_scan_start(tcl.word_is,*tcl.list_commandwords.at(6), @@ -2228,11 +2238,13 @@ D tcl.entry_current->mtype = Method; tcl.entry_current->name = myName; tcl.entry_current->startLine = tcl.line_command; + tcl.entry_current->docLine = tcl.line_comment; + tcl.entry_current->inbodyLine = tcl.line_comment; tcl.entry_current->bodyLine = tcl.line_body0; tcl.entry_current->endBodyLine = tcl.line_body1; tcl_protection(tcl.entry_current); tcl_command_ARGLIST(*tcl.list_commandwords.at(2)); - if (myEntryCl) myEntryCl->addSubEntry(tcl.entry_current); + if (myEntryCl) myEntryCl->moveToSubEntryAndKeep(tcl.entry_current); myEntry = tcl.entry_current; tcl.fn.insert(myName,myEntry); myScan = tcl_scan_start(tcl.word_is,*tcl.list_commandwords.at(4), @@ -2263,10 +2275,12 @@ D tcl.entry_current->mtype = Method; tcl.entry_current->name = myName; tcl.entry_current->startLine = tcl.line_command; + tcl.entry_current->docLine = tcl.line_comment; + tcl.entry_current->inbodyLine = tcl.line_comment; tcl.entry_current->bodyLine = tcl.line_body0; tcl.entry_current->endBodyLine = tcl.line_body1; tcl_protection(tcl.entry_current); - myEntryCl->addSubEntry(tcl.entry_current); + myEntryCl->moveToSubEntryAndKeep(tcl.entry_current); myEntry = tcl.entry_current; tcl.fn.insert(myName,myEntry); myScan = tcl_scan_start(tcl.word_is,*tcl.list_commandwords.at(2), @@ -2296,9 +2310,11 @@ D tcl.entry_current->section = Entry::NAMESPACE_SEC; tcl.entry_current->name = myName; tcl.entry_current->startLine = tcl.line_command; + tcl.entry_current->docLine = tcl.line_comment; + tcl.entry_current->inbodyLine = tcl.line_comment; tcl.entry_current->bodyLine = tcl.line_body0; tcl.entry_current->endBodyLine = tcl.line_body1; - tcl.entry_main->addSubEntry(tcl.entry_current); + tcl.entry_main->moveToSubEntryAndKeep(tcl.entry_current); tcl.ns.insert(myName,tcl.entry_current); //myEntryNs = tcl.entry_current; myStr = (*tcl.list_commandwords.at(6)); @@ -2334,9 +2350,11 @@ D tcl.entry_current->section = Entry::CLASS_SEC; tcl.entry_current->name = myName; tcl.entry_current->startLine = tcl.line_command; + tcl.entry_current->docLine = tcl.line_comment; + tcl.entry_current->inbodyLine = tcl.line_comment; tcl.entry_current->bodyLine = tcl.line_body0; tcl.entry_current->endBodyLine = tcl.line_body1; - tcl.entry_main->addSubEntry(tcl.entry_current); + tcl.entry_main->moveToSubEntryAndKeep(tcl.entry_current); tcl.cl.insert(myName,tcl.entry_current); myEntryCl = tcl.entry_current; myScan = tcl_scan_start(tcl.word_is,*tcl.list_commandwords.at(4), @@ -2366,9 +2384,11 @@ D tcl.entry_current->section = Entry::CLASS_SEC; tcl.entry_current->name = myName; tcl.entry_current->startLine = tcl.line_command; + tcl.entry_current->docLine = tcl.line_comment; + tcl.entry_current->inbodyLine = tcl.line_comment; tcl.entry_current->bodyLine = tcl.line_body0; tcl.entry_current->endBodyLine = tcl.line_body1; - tcl.entry_main->addSubEntry(tcl.entry_current); + tcl.entry_main->moveToSubEntryAndKeep(tcl.entry_current); //myEntryNs = tcl_entry_namespace(myName); tcl.cl.insert(myName,tcl.entry_current); myEntryCl = tcl.entry_current; @@ -2418,6 +2438,8 @@ D tcl.entry_current->mtype = Method; tcl.entry_current->name = myMethod; tcl.entry_current->startLine = tcl.line_command; + tcl.entry_current->docLine = tcl.line_comment; + tcl.entry_current->inbodyLine = tcl.line_comment; tcl.entry_current->bodyLine = tcl.line_body0; tcl.entry_current->endBodyLine = tcl.line_body1; tcl_protection(tcl.entry_current); @@ -2429,7 +2451,7 @@ D { tcl_command_ARGLIST(*tcl.list_commandwords.at(6)); } - if (myEntryCl) myEntryCl->addSubEntry(tcl.entry_current); + if (myEntryCl) myEntryCl->moveToSubEntryAndKeep(tcl.entry_current); tcl.fn.insert(myMethod,tcl.entry_current); myEntry = tcl.entry_current; myScan = tcl_scan_start('?',*tcl.list_commandwords.at(n-1), @@ -2488,10 +2510,12 @@ D tcl.entry_current->section = Entry::VARIABLE_SEC; tcl.entry_current->name = myName; tcl.entry_current->startLine = tcl.line_command; + tcl.entry_current->docLine = tcl.line_comment; + tcl.entry_current->inbodyLine = tcl.line_comment; tcl.entry_current->bodyLine = tcl.line_body0; tcl.entry_current->endBodyLine = tcl.line_body1; tcl_protection(tcl.entry_current); - myEntry->addSubEntry(tcl.entry_current); + myEntry->moveToSubEntryAndKeep(tcl.entry_current); tcl.entry_current = tcl_entry_new(); } @@ -2560,7 +2584,7 @@ tcl_inf("->\n"); if (myStr.left(2)=="::") myStr = myStr.mid(2); if (tcl.config_subst.contains(myStr)) { - myStr=tcl.config_subst[myStr].utf8(); + myStr=tcl.config_subst[myStr]; } if (myStr=="private") { @@ -2596,7 +2620,7 @@ tcl_inf("->\n"); if (myStr.left(2)=="::") myStr = myStr.mid(2); if (tcl.config_subst.contains(myStr)) { - myStr=tcl.config_subst[myStr].utf8(); + myStr=tcl.config_subst[myStr]; } } if (myStr=="proc") @@ -2703,7 +2727,7 @@ tcl_inf("->\n"); { for (unsigned int i = 2; i < tcl.list_commandwords.count(); i = i + 2) { - tcl.scan.at(0)->entry_cl->extends->append(new BaseInfo((*tcl.list_commandwords.at(i)),Public,Normal)); + tcl.scan.at(0)->entry_cl->extends.push_back(BaseInfo((*tcl.list_commandwords.at(i)),Public,Normal)); } } goto command_end; @@ -2909,10 +2933,10 @@ static void tcl_parse(const QCString ns, const QCString cls) tcl.entry_file->name = tcl.file_name; tcl.entry_file->section = Entry::SOURCE_SEC; tcl.entry_file->protection = Public; - tcl.entry_main->addSubEntry(tcl.entry_file); + tcl.entry_main->moveToSubEntryAndKeep(tcl.entry_file); Entry *myEntry=tcl_entry_new(); myEntry->name=""; - tcl.entry_main->addSubEntry(myEntry); + tcl.entry_main->moveToSubEntryAndKeep(myEntry); tcl.ns.insert("::",myEntry); tcl.entry_current = tcl_entry_new(); @@ -2940,9 +2964,9 @@ static void tcl_parse(const QCString ns, const QCString cls) } //! Parse text file and build up entry tree. -void TclLanguageScanner::parseInput(const char *fileName, +void TclOutlineParser::parseInput(const char *fileName, const char *input, - Entry *root, + const std::shared_ptr<Entry> &root, bool /*sameTranslationUnit*/, QStrList & /*filesInSameTranslationUnit*/) { @@ -2963,7 +2987,7 @@ tcl_inf("%s\n",fileName); tcl.code = NULL; tcl.file_name = fileName; tcl.this_parser = this; - tcl.entry_main = root; /* toplevel entry */ + tcl.entry_main = root.get(); /* toplevel entry */ tcl_parse("",""); Doxygen::docGroup.leaveFile(tcl.file_name,yylineno); root->program.resize(0); @@ -2971,8 +2995,40 @@ tcl_inf("%s\n",fileName); printlex(yy_flex_debug, FALSE, __FILE__, fileName); } + +bool TclOutlineParser::needsPreprocessing(const QCString &extension) const +{ + (void)extension; + return FALSE; +} + +void TclOutlineParser::parsePrototype(const char *text) +{ + (void)text; +} + +static int yyread(char *buf,int max_size) +{ + int c=0; + + *buf = '\0'; + while ( c < max_size && tcl.input_string.at(tcl.input_position) ) + { + *buf = tcl.input_string.at(tcl.input_position++) ; + c++; buf++; + } + //printf("Read from=%d size=%d max=%d c=%d\n",tcl.input_position,strlen(&tcl.input_string[tcl.input_position]),max_size,c); + return c; +} + +//---------------------------------------------------------------------------- + +void TclCodeParser::resetCodeParserState() +{ +} + //! Parse file and codify. -void TclLanguageScanner::parseCode(CodeOutputInterface & codeOutIntf, +void TclCodeParser::parseCode(CodeOutputInterface & codeOutIntf, const char * scopeName, const QCString & input, SrcLangExt lang, @@ -3016,7 +3072,7 @@ void TclLanguageScanner::parseCode(CodeOutputInterface & codeOutIntf, } } - QString myStr="Codifying.."; + QCString myStr="Codifying.."; if (scopeName) { myStr +=" scope="; @@ -3039,7 +3095,7 @@ void TclLanguageScanner::parseCode(CodeOutputInterface & codeOutIntf, myStr+=" file="; myStr+=fileDef->fileName(); } -tcl_inf("%s (%d,%d) %d %d\n",myStr.ascii(),startLine,endLine,isExampleBlock,inlineFragment); +tcl_inf("%s (%d,%d) %d %d\n",myStr.data(),startLine,endLine,isExampleBlock,inlineFragment); //tcl_inf("%s\n"input.data()); tcl_init(); tcl.collectXRefs = collectXRefs; @@ -3076,36 +3132,6 @@ tcl_inf("%s (%d,%d) %d %d\n",myStr.ascii(),startLine,endLine,isExampleBlock,inli tcl.entry.clear(); printlex(yy_flex_debug, FALSE, __FILE__, fileDef ? fileDef->fileName().data(): NULL); } - -bool TclLanguageScanner::needsPreprocessing(const QCString &extension) -{ - (void)extension; - return FALSE; -} - -void TclLanguageScanner::resetCodeParserState() -{ -} - -void TclLanguageScanner::parsePrototype(const char *text) -{ - (void)text; -} - -static int yyread(char *buf,int max_size) -{ - int c=0; - - *buf = '\0'; - while ( c < max_size && tcl.input_string.at(tcl.input_position) ) - { - *buf = tcl.input_string.at(tcl.input_position++) ; - c++; buf++; - } - //printf("Read from=%d size=%d max=%d c=%d\n",tcl.input_position,strlen(&tcl.input_string[tcl.input_position]),max_size,c); - return c; -} - //---------------------------------------------------------------------------- // to avoid a warning @@ -3114,10 +3140,4 @@ void tclDummy() yy_top_state(); } -#if !defined(YY_FLEX_SUBMINOR_VERSION) -//---------------------------------------------------------------------------- -extern "C" { // some bogus code to keep the compiler happy - void tclscannerYYdummy() { yy_flex_realloc(0,0); } -} -#endif - +#include "tclscanner.l.h" |