From: <che...@us...> - 2008-08-16 00:42:40
|
Revision: 10764 http://swig.svn.sourceforge.net/swig/?rev=10764&view=rev Author: cherylfoil Date: 2008-08-16 00:42:37 +0000 (Sat, 16 Aug 2008) Log Message: ----------- Cleaning up directories a bit Removed Paths: ------------- branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/DoxygenEntity.cpp branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/DoxygenEntity.h branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/DoxygenTranslator.cpp branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/JavaDocConverter.cpp branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/JavaDocConverter.h branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/Token.cpp branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/Token.h branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/TokenList.cpp branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/TokenList.h Deleted: branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/DoxygenEntity.cpp =================================================================== --- branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/DoxygenEntity.cpp 2008-08-15 23:54:53 UTC (rev 10763) +++ branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/DoxygenEntity.cpp 2008-08-16 00:42:37 UTC (rev 10764) @@ -1,89 +0,0 @@ -#include "DoxygenEntity.h" -#include <string> - -/* Little data class for Doxygen Commands */ - - -/* Basic node for commands that have - * nothing after them - * example: \n - */ -string commandArray2[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attention", - "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", - "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", - "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", - "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", - "endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", - "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", - "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", - "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", - "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", - "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", - "private", "privatesection", "property", "protected", "protectedsection", "protocol", - "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", - "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", - "subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until", - "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", - "$", "@", string(1, 92), "&", "~", "<", ">", "#", "%"}; - -string findCommand(int commandNum){ - - int arraySize = sizeof(commandArray2)/sizeof(*commandArray2); - if (commandNum - 101 >= 0 && commandNum - 101 < arraySize){ - return commandArray2[commandNum - 101]; - } - - return "" ; -} - -DoxygenEntity::DoxygenEntity(string typeEnt){ - typeOfEntity = typeEnt; - data = ""; - isLeaf = 1; -} - -/* Basic node for commands that have - * only 1 thing after them - * example: \b word - * OR holding a string - */ -DoxygenEntity::DoxygenEntity(string typeEnt, string param1){ - typeOfEntity = typeEnt; - data = param1; - isLeaf = 1; -} - -/* Nonterminal node - * contains - */ -DoxygenEntity::DoxygenEntity(string typeEnt, list <DoxygenEntity> &entList ){ - typeOfEntity = typeEnt; - data = ""; - isLeaf = 0; - entityList = entList; -} - - -void DoxygenEntity::printEntity(int level){ - int thisLevel = level; - if (isLeaf) { - for (int i = 0; i < thisLevel; i++) {cout << "\t";} - cout << "Node Command: " << typeOfEntity << " "; - if (data.compare("") != 0) cout << "Node Data: " << data; - cout << endl; - } - else{ - for (int i = 0; i < thisLevel; i++) {cout << "\t";} - cout << "Node Command : " << typeOfEntity << endl; - list<DoxygenEntity>::iterator p = entityList.begin(); - thisLevel++; - while (p != entityList.end()){ - (*p).printEntity(thisLevel); - p++; - } - } -} - -DoxygenEntity::~DoxygenEntity() -{ -} Deleted: branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/DoxygenEntity.h =================================================================== --- branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/DoxygenEntity.h 2008-08-15 23:54:53 UTC (rev 10763) +++ branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/DoxygenEntity.h 2008-08-16 00:42:37 UTC (rev 10764) @@ -1,26 +0,0 @@ -#ifndef DOXYGENENTITY_H_ -#define DOXYGENENTITY_H_ - -#include <cstdlib> -#include <iostream> -#include <string> -#include <list> - -using namespace std; - -class DoxygenEntity{ - -public: - DoxygenEntity(string typeEnt); - DoxygenEntity(string typeEnt, string param1); - DoxygenEntity(string typeEnt, list <DoxygenEntity> &entList ); - ~DoxygenEntity(); - void printEntity(int level); - string typeOfEntity; - list <DoxygenEntity> entityList; - string data; - int isLeaf; -}; - - -#endif /*TOKENLIST_H_*/ Deleted: branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/DoxygenTranslator.cpp =================================================================== --- branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/DoxygenTranslator.cpp 2008-08-15 23:54:53 UTC (rev 10763) +++ branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/DoxygenTranslator.cpp 2008-08-16 00:42:37 UTC (rev 10764) @@ -1,810 +0,0 @@ - - - //THE TOKENIZER REWORK - - /* The main class for translating blobs of Doxygen for SWIG - * by Cheryl Foil, mentor Olly Betts, for Google's Summer of Code Program - * Currently the spacing/format on this is a bit goofy in places, due to shuffling code - * between 2 editors! Apologies for anyone combing through it :) - */ - //TODO DOH instead of STL? -//TODO work in Brief descriptions, detailed descriptions for autobrief - - #include <cstdlib> - #include <iostream> - #include <fstream> - #include <string> - #include <list> - #include "DoxygenEntity.h" - #include "TokenList.h" - #include "JavaDocConverter.h" - #define SIMPLECOMMAND 1 - #define IGNOREDSIMPLECOMMAND 2 - #define COMMANDWORD 3 - #define IGNOREDCOMMANDWORD 4 - #define COMMANDLINE 5 - #define IGNOREDCOMMANDLINE 6 - #define COMMANDPARAGRAPH 7 - #define IGNORECOMMANDPARAGRAPH 8 - #define COMMANDENDCOMMAND 9 - #define COMMANDWORDPARAGRAPH 10 - #define COMMANDWORDLINE 11 - #define COMMANDWORDOWORDWORD 12 - #define COMMANDOWORD 13 - #define COMMANDERRORTHROW 14 - #define COMMANDUNIQUE 15 -#define END_LINE 101 -#define PARAGRAPH_END 102 -#define PLAINSTRING 103 -#define COMMAND 104 - using namespace std; - - ////////////////////////////////////////// - /*Set these to pick what internal functions - to test. */ - - //int testCommandParsingFunctions = 1;// not implemented - - - int noisy = 0; // set this to 1 for extra chatter from the parsing stage. - int addCommand(string currCommand, TokenList &tokList, list <DoxygenEntity> &aNewList); - list <DoxygenEntity> parse(list<Token>::iterator endParsingIndex, TokenList &tokList); - - ////////////////////////////////////////// - - - string commandArray[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attention", - "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", - "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", - "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", - "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", - "endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", - "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", - "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", - "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", - "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", - "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", - "private", "privatesection", "property", "protected", "protectedsection", "protocol", - "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", - "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", - "subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until", - "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", - "$", "@", "\\","&", "~", "<", ">", "#", "%"}; - - - string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details", - "else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param", - "tparam", "post" , "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "todo", - "version", "warning", "xrefitem" }; - - /* All of the doxygen commands divided up by how they are parsed */ - string simpleCommands[] = {"n", "$", "@", "\\", "&", "~", "<", ">", "#", "%"}; - string ignoredSimpleCommands[] = {"nothing at the moment"}; - string commandWords[] = {"a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", - "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno"}; - string ignoredCommandWords[] = {"copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"}; - string commandLines[] = {"addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"}; - string ignoreCommandLines[] = {"nothing at the moment"}; - string commandParagraph[] = {"return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", - "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author"}; - string ignoreCommandParagraphs[] = {"nothing at the moment"}; - string commandEndCommands[] = {"code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", - "verbatim", "xmlonly", "cond", "if", "ifnot", "link"}; - string commandWordParagraphs[] = {"param", "tparam", "throw", "retval", "exception"}; - string commandWordLines[] = {"page", "subsection", "subsubsection", "section", "paragraph", "defgroup"}; - string commandWordOWordOWords [] = {"category", "class", "protocol", "interface", "struct", "union"}; - string commandOWords[] = {"dir", "file", "cond"}; - string commandErrorThrowings[] = {"annotatedclasslist", "classhierarchy", "define", "functionindex", "header", - "headerfilelist", "inherit", "l", "postheader", "private", "privatesection", "protected", - "protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly", - "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endcond", - "endif"}; - string commandUniques[] = {"xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", - "subpage", "dotfile", "image", "addtogroup", "li"}; - - - /* Changes a string to all lower case*/ - string StringToLower(string stringToConvert) - - { - - for(unsigned int i=0;i<stringToConvert.length();i++) - { - stringToConvert[i] = tolower(stringToConvert[i]); - } - return stringToConvert;//return the converted string - } - - /* finds out if a command exists (is a possible command) - * from the string array commandArray - * returns -1 if no match is found */ - int findCommand(string smallString){ - - smallString = StringToLower(smallString); - int a; - for (int i = 0; i < sizeof(commandArray)/sizeof(*commandArray); i++){ - if( (a = smallString.compare(commandArray[i])) == 0){ - return 101 + i; - } - - - } - return -1; - } - - /* isSectionIndicator returns a boolean if the command is a section indicator - * This is a helper method for finding the end of a paragraph - * by Doxygen's terms - */ - int isSectionIndicator(string smallString){ - smallString = StringToLower(smallString); - - for (int i = 0; i < sizeof( sectionIndicators)/sizeof(* sectionIndicators); i++){ - if( smallString.compare( sectionIndicators[i]) == 0){ - return 1; - } - } - return 0; - } - - /* prints the parse tree - * - */ - void printTree( list <DoxygenEntity> &rootList){ - - list<DoxygenEntity>::iterator p = rootList.begin(); - while (p != rootList.end()){ - (*p).printEntity(0); - p++; - } - - } - - /* Determines how a command should be handled (what group it belongs to - * for parsing rules - */ - - int commandBelongs(string theCommand){ - string smallString = StringToLower(theCommand ); - //cout << " Looking for command " << theCommand << endl; - int i = 0; - for ( i = 0; i < sizeof(simpleCommands)/sizeof(*simpleCommands); i++){ - if(smallString.compare(simpleCommands[i]) == 0){return SIMPLECOMMAND ;} - } - for ( i = 0; i < sizeof(ignoredSimpleCommands)/sizeof(*ignoredSimpleCommands); i++){ - if(smallString.compare(ignoredSimpleCommands[i]) == 0){return IGNOREDSIMPLECOMMAND;} - } - for ( i = 0; i < sizeof(commandWords)/sizeof(*commandWords); i++){ - if(smallString.compare( commandWords[i]) == 0){return COMMANDWORD;} - } - for ( i = 0; i < sizeof(ignoredCommandWords)/sizeof(*ignoredCommandWords); i++){ - if(smallString.compare( ignoredCommandWords[i]) == 0){return IGNOREDCOMMANDWORD;} - } - for ( i = 0; i < sizeof(commandLines)/sizeof(*commandLines); i++){ - if(smallString.compare( commandLines[i]) == 0){return COMMANDLINE;} - } - for ( i = 0; i < sizeof(ignoreCommandLines)/sizeof(*ignoreCommandLines); i++){ - if(smallString.compare( ignoreCommandLines[i]) == 0){return IGNOREDCOMMANDLINE;} - } - for ( i = 0; i < sizeof(commandParagraph)/sizeof(*commandParagraph); i++){ - if(smallString.compare( commandParagraph[i]) == 0){return COMMANDPARAGRAPH;} - } - /* IgnoreCommandParagraph */ - for ( i = 0; i < sizeof(ignoreCommandParagraphs)/sizeof(*ignoreCommandParagraphs); i++){ - if(smallString.compare( ignoreCommandParagraphs[i]) == 0){return IGNORECOMMANDPARAGRAPH;} - } - for ( i = 0; i < sizeof(commandEndCommands)/sizeof(*commandEndCommands); i++){ - if(smallString.compare( commandEndCommands[i]) == 0){return COMMANDENDCOMMAND ;} - } - for ( i = 0; i < sizeof(commandWordParagraphs)/sizeof(*commandWordParagraphs); i++){ - if(smallString.compare( commandWordParagraphs[i]) == 0){return COMMANDWORDPARAGRAPH;} - } - for ( i = 0; i < sizeof(commandWordLines)/sizeof(*commandWordLines); i++){ - if(smallString.compare( commandWordLines[i]) == 0){return COMMANDWORDLINE ;} - } - for ( i = 0; i < sizeof(commandWordOWordOWords)/sizeof(*commandWordOWordOWords); i++){ - if(smallString.compare( commandWordOWordOWords[i]) == 0){return COMMANDWORDOWORDWORD;} - } - for ( i = 0; i < sizeof(commandOWords)/sizeof(*commandOWords); i++){ - if(smallString.compare( commandOWords[i]) == 0){return COMMANDOWORD;} - } - for ( i = 0; i < sizeof(commandErrorThrowings)/sizeof(*commandErrorThrowings); i++){ - if(smallString.compare( commandErrorThrowings[i]) == 0){return COMMANDERRORTHROW;} - } - for ( i = 0; i < sizeof(commandUniques)/sizeof(*commandUniques); i++){ - if(smallString.compare( commandUniques[i]) == 0){return COMMANDUNIQUE;} - } - - return 0; - - } - /* Returns the next word ON THE CURRENT LINE ONLY - * if a new line is encountered, returns a blank string. - * Updates the index it is given if success. - */ - - string getNextWord(TokenList &tokList){ - Token nextToken = tokList.peek(); - if (nextToken.tokenType == PLAINSTRING ){ - nextToken = tokList.next(); - return nextToken.tokenString; - } - return ""; - } - - /* Returns the location of the end of the line as - * an iterator. - */ - list<Token>::iterator getOneLine(TokenList &tokList){ - list<Token>::iterator endOfParagraph = tokList.iteratorCopy(); - while(endOfParagraph != tokList.end()){ - if ((* endOfParagraph).tokenType == END_LINE){ - return endOfParagraph; - } - endOfParagraph++; - } - return tokList.end(); - } - - - -/* Returns a properly formatted string - * up til ANY command or end of paragraph is encountered. - */ -string getStringTilCommand(TokenList &tokList){ - string description; - if (tokList.peek().tokenType == 0) return ""; - while(tokList.peek().tokenType == PLAINSTRING || tokList.peek().tokenType == END_LINE ){ - Token currentToken = tokList.next(); - if(currentToken.tokenType == PLAINSTRING) { - description = description + currentToken.tokenString + " "; - } - else if (tokList.peek().tokenType == END_LINE) break; - } - - return description; - } - -/* Returns a properly formatted string - * up til the command specified is encountered - */ -//TODO check that this behaves properly for formulas - -string getStringTilEndCommand(string theCommand, TokenList &tokList){ - string description; - if (tokList.peek().tokenType == 0) return ""; - while(tokList.peek().tokenString.compare(theCommand) != 0 ){ - Token currentToken = tokList.next(); - description = description + currentToken.tokenString + " "; - - } - - return description; - } - -/* Returns the end of a Paragraph as an iterator- - * Paragraph is defined in Doxygen to be a paragraph of text - * seperate by either a structural command or a blank line - */ - -list<Token>::iterator getEndOfParagraph(TokenList &tokList){ - list<Token>::iterator endOfParagraph = tokList.iteratorCopy(); - while(endOfParagraph != tokList.end()){ - if ((* endOfParagraph).tokenType == COMMAND){ - if(isSectionIndicator((* endOfParagraph).tokenString)) return endOfParagraph; - else endOfParagraph++; - } - else if((* endOfParagraph).tokenType == PLAINSTRING) { - endOfParagraph++; - } - else if ((* endOfParagraph).tokenType == END_LINE){ - endOfParagraph++; - if ((* endOfParagraph).tokenType == END_LINE){ - endOfParagraph++; - return endOfParagraph; - } - } - - } - - return tokList.end(); - - } - -/* Returns the end of a section, defined as the first blank line OR first encounter of the same - * command. Example of this behaviour is \arg - */ - -list<Token>::iterator getEndOfSection(string theCommand, TokenList &tokList){ - list<Token>::iterator endOfParagraph = tokList.iteratorCopy(); - while(endOfParagraph != tokList.end()){ - if ((* endOfParagraph).tokenType == COMMAND){ - if(theCommand.compare((*endOfParagraph).tokenString) == 0) return endOfParagraph; - else endOfParagraph++; - } - else if((* endOfParagraph).tokenType == PLAINSTRING) { - endOfParagraph++; - } - else if ((* endOfParagraph).tokenType == END_LINE){ - endOfParagraph++; - if ((* endOfParagraph).tokenType == END_LINE){ - endOfParagraph++; - return endOfParagraph; - } - } - - } -} - /* This method is for returning the end of a specific form of doxygen command - * that begins with a \command and ends in \endcommand - * such as \code and \endcode. The proper usage is - * progressTilEndCommand("endcode", tokenList); - */ -list<Token>::iterator getEndCommand(string theCommand, TokenList &tokList){ - list<Token>::iterator endOfCommand = tokList.iteratorCopy(); - while (endOfCommand!= tokList.end()){ - if ((*endOfCommand).tokenType == COMMAND){ - if (theCommand.compare((* endOfCommand).tokenString) == 0){ - return endOfCommand; - } - endOfCommand++; - } - } - //End command not found - return tokList.end(); - } - - /* A specialty method for commands such as \arg that end at the end of a paragraph OR when another \arg is encountered - */ - -list<Token>::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ - list<Token>::iterator anIterator; - return anIterator; - } - - - - - /* Method for Adding a Simple Command - * Format: @command - * Plain commands, such as newline etc, they contain no other data - * \n \\ \@ \& \$ \# \< \> \% - */ - int addSimpleCommand(string theCommand, list <DoxygenEntity> &doxyList){ - - if (noisy) cout << "Parsing " << theCommand << endl; - doxyList.push_back(DoxygenEntity(theCommand)); - return 1; - } - - /* NOT INCLUDED Simple Commands - * Format: @command - * Plain commands, such as newline etc, they contain no other data - */ - int ignoreSimpleCommand(string theCommand, list <DoxygenEntity> &doxyList){ - - if (noisy) cout << "Not Adding " << theCommand << endl; - return 1; - } - - /* CommandWord - * Format: @command <word> - * Commands with a single WORD after then such as @b - * "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", - * "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno" - */ - int addCommandWord(string theCommand, TokenList &tokList, list <DoxygenEntity> &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(tokList); - if (!name.empty()){ - doxyList.push_back(DoxygenEntity(theCommand, name)); - return 1; - } - else cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - /* NOT INCLUDED CommandWord - * Format: @command <word> - * Commands with a single WORD after then such as @b - * "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude" - */ - int ignoreCommandWord(string theCommand, TokenList &tokList, list <DoxygenEntity> &doxyList){ - if (noisy) cout << "Not Adding " << theCommand << endl; - string name = getNextWord(tokList); - if (!name.empty()){ - return 1; - } - else cout << "WARNING: No word followed " << theCommand << " command." << endl; - return 0; - } - - /* CommandLine - * Format: @command (line) - * Commands with a single LINE after then such as @var - * "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property" - */ - int addCommandLine(string theCommand, TokenList &tokList, list <DoxygenEntity> &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; - list<Token>::iterator endOfLine = getOneLine(tokList); - list <DoxygenEntity> aNewList; - aNewList = parse(endOfLine, tokList); - doxyList.push_back( DoxygenEntity(theCommand, aNewList)); - return 1; - - } - - /* NOT INCLUDED CommandLine - * Format: @command (line) - * Commands with a single LINE after then such as @var - * - */ - int ignoreCommandLine(string theCommand, TokenList &tokList, list <DoxygenEntity> &doxyList){ - if (noisy) cout << "Not Adding " << theCommand << endl; - list<Token>::iterator endOfLine = getOneLine(tokList); - tokList.setIterator(endOfLine); - return 1; - } - - /* CommandParagraph - * Format: @command {paragraph} - * Commands with a single paragraph after then such as @return - * "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", - * "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author" - */ - int addCommandParagraph(string theCommand, TokenList &tokList, list <DoxygenEntity> &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; - list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList); - //if(!restOfParagraph.empty()){ - list <DoxygenEntity> aNewList; - aNewList = parse(endOfParagraph, tokList); - doxyList.push_back( DoxygenEntity(theCommand, aNewList)); - return 1; - // } - //else cout << "No line followed " << theCommand << " command. Not added" << endl; - } - /* CommandParagraph - * Format: @command {paragraph} - * Commands with a single LINE after then such as @var - * - */ - int ignoreCommandParagraph(string theCommand, TokenList &tokList, list <DoxygenEntity> &doxyList){ - if (noisy) cout << "Not Adding " << theCommand << endl; - list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); - //else cout << "WARNING: No line followed " << theCommand << " command." << endl; - return 1; - } - /* Command EndCommand - * Format: @command and ends at @endcommand - * Commands that take in a block of text such as @code - * "code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", - * "verbatim", "xmlonly", "cond", "if", "ifnot", "link" - * Returns 1 if success, 0 if the endcommand is never encountered. - */ - - int addCommandEndCommand(string theCommand, TokenList &tokList, list <DoxygenEntity> &doxyList){ - if (noisy) cout << "Not Adding " << theCommand << endl; - string description = getStringTilEndCommand( "end" + theCommand, tokList); - doxyList.push_back(DoxygenEntity(theCommand, description)); - return 1; - } - - /* CommandWordParagraph - * Format: @command <word> {paragraph} - * Commands such as param - * "param", "tparam", "throw", "retval", "exception" - */ - int addCommandWordParagraph(string theCommand, TokenList &tokList, list <DoxygenEntity> &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(tokList); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList); - //if(!restOfParagraph.empty()){ - list <DoxygenEntity> aNewList; - aNewList = parse(endOfParagraph, tokList); - aNewList.push_front(DoxygenEntity("plainstring", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 0; - } - /* CommandWordLine - * Format: @command <word> (line) - * Commands such as param - * "page", "subsection", "subsubsection", "section", "paragraph", "defgroup" - */ - int addCommandWordLine(string theCommand, TokenList &tokList, list <DoxygenEntity> &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(tokList); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - list<Token>::iterator endOfLine = getOneLine(tokList); - list <DoxygenEntity> aNewList; - aNewList = parse(endOfLine, tokList); - aNewList.push_front(DoxygenEntity("plainstring", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - - //else cout << "No line followed " << theCommand << " command. Not added" << endl; - } - - /* Command Word Optional Word Optional Word - * Format: @command <word> [<header-file>] [<header-name>] - * Commands such as class - * "category", "class", "protocol", "interface", "struct", "union" - */ - int addCommandWordOWordOWord(string theCommand, TokenList &tokList, list <DoxygenEntity> &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(tokList); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - string headerfile = getNextWord(tokList); - string headername = getNextWord(tokList); - list <DoxygenEntity> aNewList; - aNewList.push_back(DoxygenEntity("plainstring", name)); - if (!headerfile.empty()) aNewList.push_back(DoxygenEntity("plainstring", headerfile)); - if (!headername.empty()) aNewList.push_back(DoxygenEntity("plainstring", headername)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - } - - /* Command Optional Word - * Format: @command [<word>] - * Commands such as dir - * "dir", "file", "cond" - */ - int addCommandOWord(string theCommand, TokenList &tokList, list <DoxygenEntity> &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(tokList); - doxyList.push_back(DoxygenEntity(theCommand, name)); - return 1; - } - - /* Commands that should not be encountered (such as PHP only) - */ - int addCommandErrorThrow(string theCommand, TokenList &tokList, list <DoxygenEntity> &doxyList){ - cout << "Encountered :" << theCommand << endl; - cout << "This command should not have been encountered. Behaviour past this may be unpredictable " << endl; - } - - - int addCommandUnique(string theCommand, TokenList &tokList, list <DoxygenEntity> &doxyList){ - list <DoxygenEntity> aNewList; - if (theCommand.compare("arg") == 0 || theCommand.compare("li") == 0){ - list<Token>::iterator endOfSection = getEndOfSection(theCommand, tokList); - list <DoxygenEntity> aNewList; - aNewList = parse(endOfSection, tokList); - doxyList.push_back( DoxygenEntity(theCommand, aNewList)); - } - - // \xrefitem <key> "(heading)" "(list title)" {text} - else if (theCommand.compare("xrefitem") == 0){ - //TODO Implement xrefitem - if (noisy) cout << "Not Adding " << theCommand << endl; - list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); - return 1; - } - // \ingroup (<groupname> [<groupname> <groupname>]) - else if (theCommand.compare("ingroup") == 0){ - string name = getNextWord(tokList); - aNewList.push_back(DoxygenEntity("plainstring", name)); - name = getNextWord(tokList); - if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstring", name)); - name = getNextWord(tokList); - if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstring", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - } - // \par [(paragraph title)] { paragraph } - else if (theCommand.compare("par") == 0){ - list<Token>::iterator endOfLine = getOneLine(tokList); - aNewList = parse(endOfLine, tokList); - list <DoxygenEntity> aNewList2; - aNewList2 = parse(endOfLine, tokList); - aNewList.splice(aNewList.end(), aNewList2); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - } - // \headerfile <header-file> [<header-name>] - else if (theCommand.compare("headerfile") == 0){ - list <DoxygenEntity> aNewList; - string name = getNextWord(tokList); - aNewList.push_back(DoxygenEntity("plainstring", name)); - name = getNextWord(tokList); - if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstring", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - } - // \overload [(function declaration)] - else if (theCommand.compare("overload") == 0){ - list<Token>::iterator endOfLine = getOneLine(tokList); - if (endOfLine != tokList.current()){ - list <DoxygenEntity> aNewList; - aNewList = parse(endOfLine, tokList); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - } - else doxyList.push_back(DoxygenEntity(theCommand)); - } - // \weakgroup <name> [(title)] - else if (theCommand.compare("weakgroup") == 0){ - if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(tokList); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - list <DoxygenEntity> aNewList; - list<Token>::iterator endOfLine = getOneLine(tokList); - if (endOfLine != tokList.current()) { - aNewList = parse(endOfLine, tokList); - } - aNewList.push_front(DoxygenEntity("plainstring", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - } - // \ref <name> ["(text)"] - else if (theCommand.compare("ref") == 0){ - //TODO Implement ref - if (noisy) cout << "Not Adding " << theCommand << endl; - list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); - } - // \subpage <name> ["(text)"] - else if (theCommand.compare("subpage") == 0){ - //TODO implement subpage - if (noisy) cout << "Not Adding " << theCommand << endl; - list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); - } - // \dotfile <file> ["caption"] - else if (theCommand.compare("dotfile") == 0){ - //TODO implement dotfile - if (noisy) cout << "Not Adding " << theCommand << endl; - list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); - } - // \image <format> <file> ["caption"] [<sizeindication>=<size>] - else if (theCommand.compare("image") == 0){ - //todo implement image - } - // \addtogroup <name> [(title)] - else if (theCommand.compare("addtogroup") == 0){ - if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(tokList); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - list <DoxygenEntity> aNewList; - list<Token>::iterator endOfLine = getOneLine(tokList); - if (endOfLine != tokList.current()) { - aNewList = parse(endOfLine, tokList); - } - aNewList.push_front(DoxygenEntity("plainstring", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - } - - } - - /* The actual "meat" of the doxygen parser. This is not yet fully implemented - * with my current design- however the skeletal outline is contained in - * the file Skeleton - */ - - - int addCommand(string commandString, TokenList &tokList,list <DoxygenEntity> &doxyList){ - string theCommand = StringToLower(commandString); - - if (theCommand.compare("plainstring") == 0){ - string nextPhrase = getStringTilCommand( tokList); - if (noisy) cout << "Parsing plain string :" << nextPhrase << endl; - doxyList.push_back(DoxygenEntity("plainstring", nextPhrase )); - return 1; - } - int commandNumber = commandBelongs(theCommand); - if (commandNumber == SIMPLECOMMAND){ - return addSimpleCommand(theCommand, doxyList); - } - if (commandNumber == IGNOREDSIMPLECOMMAND){ - return ignoreSimpleCommand(theCommand, doxyList); - } - if (commandNumber == COMMANDWORD){ - return addCommandWord(theCommand, tokList, doxyList); - } - if (commandNumber == IGNOREDCOMMANDWORD){ - return ignoreCommandWord(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDLINE ){ - return addCommandLine(theCommand, tokList, doxyList); - } - if (commandNumber == IGNOREDCOMMANDLINE ){ - return ignoreCommandLine(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDPARAGRAPH){ - return addCommandParagraph(theCommand, tokList, doxyList); - } - if (commandNumber == IGNORECOMMANDPARAGRAPH){ - return ignoreCommandParagraph(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDENDCOMMAND){ - return addCommandEndCommand(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDWORDPARAGRAPH){ - return addCommandWordParagraph(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDWORDLINE){ - return addCommandWordLine(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDWORDOWORDWORD){ - return addCommandWordOWordOWord(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDOWORD){ - return addCommandOWord(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDERRORTHROW){ - return addCommandErrorThrow(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDUNIQUE){ - return addCommandUnique(theCommand, tokList, doxyList); - } - - return 0; - } - - list<DoxygenEntity> parse(list<Token>::iterator endParsingIndex, TokenList &tokList){ - list <DoxygenEntity> aNewList; - int currCommand; - while (tokList.current() != endParsingIndex){ - Token currToken = tokList.peek(); - if(noisy) cout << "Parsing for phrase starting in:" << currToken.toString() << endl; - if(currToken.tokenType == END_LINE ){ - tokList.next(); - } - else if(currToken.tokenType == COMMAND){ - currCommand = findCommand(currToken.tokenString); - tokList.next(); - if (currCommand < 0 ){ if(noisy) cout << "BAD COMMAND: " << currToken.tokenString << endl;} - //cout << "Command: " << currWord << " " << currCommand << endl; - - else addCommand(currToken.tokenString, tokList, aNewList); - } - else if (currToken.tokenType == PLAINSTRING){ - addCommand(string("plainstring"), tokList, aNewList); - } - - - } - - return aNewList; - } - -list<DoxygenEntity> convert(string doxygenBlob){ - TokenList tokList = TokenList(doxygenBlob); - if(noisy) { - cout << "---TOKEN LIST---" << endl; - tokList.printList(); - } - list <DoxygenEntity> rootList; - rootList = parse( tokList.end(), tokList); - if(noisy) { - cout << "PARSED LIST" << endl; - printTree(rootList); - } - return rootList; - } - -int main(int argc, char *argv[]){ - string doxygenString1 = "//! A normal member taking two arguments and returning an integer value. This is a very long description for the simple purpose of showing off formatting. Let's make it a bit longer just to be sure. \n/*!\n \\param a an \\b integer argument.\n \\return The test results\n \\param s a constant character pointer. Let's also make this a very long description! \n \\bug this command should, for now, be totally ignored\n \\author cheryl foil\n \\sa Test(), ~Test(), testMeToo() and publicVar()\n */"; - cout << "---ORIGINAL DOXYGEN--- " << endl << doxygenString1 << endl; - list <DoxygenEntity> rootList = convert(doxygenString1); - JavaDocConverter jDC = JavaDocConverter(); - jDC.convertToJavaDoc(rootList); - return 1; -} - - Deleted: branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/JavaDocConverter.cpp =================================================================== --- branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/JavaDocConverter.cpp 2008-08-15 23:54:53 UTC (rev 10763) +++ branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/JavaDocConverter.cpp 2008-08-16 00:42:37 UTC (rev 10764) @@ -1,210 +0,0 @@ -#include "JavaDocConverter.h" -#include <cstdlib> -#include <iostream> -#include <string> -#include <list> -#define APPROX_LINE_LENGTH 64//characters per line allowed -#define TAB_SIZE 8//characters per line allowed -int printSortedTree2 = 0; -//TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a javadoc tag -JavaDocConverter::JavaDocConverter() -{ -} - -JavaDocConverter::~JavaDocConverter() -{ -} - -/* Sorts entities by javaDoc standard order for commands - * NOTE: will not behave entirely properly until "First level" comments - * such as brief descriptions are TAGGED as such - */ -bool compare_DoxygenEntities(DoxygenEntity first, DoxygenEntity second){ - if(first.typeOfEntity.compare("plainstring") == 0) return true; - if(second.typeOfEntity.compare("plainstring") == 0) return false; - if(first.typeOfEntity.compare("param") == 0){ - if(second.typeOfEntity.compare("param")== 0) return true; - if(second.typeOfEntity.compare("return")== 0) return true; - if(second.typeOfEntity.compare("exception")== 0) return true; - if(second.typeOfEntity.compare("author")== 0) return true; - if(second.typeOfEntity.compare("version")== 0)return true; - if(second.typeOfEntity.compare("see")== 0)return true; - if(second.typeOfEntity.compare("since")== 0)return true; - if(second.typeOfEntity.compare("deprecated")== 0)return true; - return false; - } - if(first.typeOfEntity.compare("return")== 0){ - if(second.typeOfEntity.compare("return")== 0) return true; - if(second.typeOfEntity.compare("exception")== 0) return true; - if(second.typeOfEntity.compare("author")== 0) return true; - if(second.typeOfEntity.compare("version")== 0)return true; - if(second.typeOfEntity.compare("see")== 0)return true; - if(second.typeOfEntity.compare("since")== 0)return true; - if(second.typeOfEntity.compare("deprecated")== 0)return true; - return false; - - } - if(first.typeOfEntity.compare("exception")== 0){ - if(second.typeOfEntity.compare("exception")== 0) return true; - if(second.typeOfEntity.compare("author")== 0) return true; - if(second.typeOfEntity.compare("version")== 0)return true; - if(second.typeOfEntity.compare("see")== 0)return true; - if(second.typeOfEntity.compare("since")== 0)return true; - if(second.typeOfEntity.compare("deprecated")== 0)return true; - return false; - } - if(first.typeOfEntity.compare("author")== 0){ - if(first.typeOfEntity.compare("author")== 0) return true; - if(first.typeOfEntity.compare("version")== 0)return true; - if(first.typeOfEntity.compare("see")== 0)return true; - if(first.typeOfEntity.compare("since")== 0)return true; - if(first.typeOfEntity.compare("deprecated")== 0)return true; - return false; - } - if(first.typeOfEntity.compare("version")== 0){ - if(second.typeOfEntity.compare("version")== 0)return true; - if(second.typeOfEntity.compare("see")== 0)return true; - if(second.typeOfEntity.compare("since")== 0)return true; - if(second.typeOfEntity.compare("deprecated")== 0)return true; - return false; - } - if(first.typeOfEntity.compare("see")== 0 || first.typeOfEntity.compare("sa")== 0){ - if(second.typeOfEntity.compare("see")== 0)return true; - if(second.typeOfEntity.compare("sa")== 0)return true; - if(second.typeOfEntity.compare("since")== 0)return true; - if(second.typeOfEntity.compare("deprecated")== 0)return true; - return false; - } - if(first.typeOfEntity.compare("since")== 0){ - if(second.typeOfEntity.compare("since")== 0) return true; - if(second.typeOfEntity.compare("deprecated")== 0)return true; - return false; - } - if(first.typeOfEntity.compare("deprecated")== 0){ - if(second.typeOfEntity.compare("deprecated")== 0)return true; - return false; - } - return true; -} - -void JavaDocConverter::printSortedTree(list <DoxygenEntity> &entityList){ - list<DoxygenEntity>::iterator p = entityList.begin(); - while (p != entityList.end()){ - (*p).printEntity(0); - p++; - } -} -string formatCommand(string unformattedLine, int indent){ - string formattedLines = "\n * "; - int lastPosition = 0; - int i = 0; - int isFirstLine = 1; - while (i != -1 && i < unformattedLine.length()){ - lastPosition = i; - if (isFirstLine){ - i+=APPROX_LINE_LENGTH; - } - else i+=APPROX_LINE_LENGTH - indent*TAB_SIZE; - i = unformattedLine.find(" ", i); - - if (i > 0 && i + 1 < unformattedLine.length()){ - if (!isFirstLine) for (int j = 0; j < indent; j++) { - formattedLines.append("\t"); - } - else { - isFirstLine = 0; - } - formattedLines.append(unformattedLine.substr(lastPosition, i - lastPosition + 1)); - formattedLines.append("\n *"); - - } - } - if (lastPosition < unformattedLine.length()){ - if (!isFirstLine) {for (int j = 0; j < indent; j++) {formattedLines.append("\t");}} - formattedLines.append(unformattedLine.substr(lastPosition, unformattedLine.length() - lastPosition)); - } - - return formattedLines; -} - -/* Contains the conversions for tags - * could probably be much more efficient... - */ -string javaDocFormat(DoxygenEntity &doxygenEntity){ - if (doxygenEntity.typeOfEntity.compare("plainstring") == 0){ - return doxygenEntity.data; - } - else if (doxygenEntity.typeOfEntity.compare("brief") == 0){ - return doxygenEntity.data; - } - if (doxygenEntity.typeOfEntity.compare("detailed") == 0){ - return doxygenEntity.data; - } - else if (doxygenEntity.typeOfEntity.compare("b") == 0){ - return "<b>" + doxygenEntity.data + "</b>"; - } - else if (doxygenEntity.typeOfEntity.compare("c") == 0){ - return "<tt>" + doxygenEntity.data + "</tt>"; - } - return ""; -} - - -string translateSubtree( DoxygenEntity &doxygenEntity){ - string returnedString; - if (doxygenEntity.isLeaf){ return javaDocFormat(doxygenEntity) + " ";} - else { - returnedString += javaDocFormat(doxygenEntity); - list<DoxygenEntity>::iterator p = doxygenEntity.entityList.begin(); - while (p != doxygenEntity.entityList.end()){ - returnedString+= translateSubtree(*p); - p++; - } - } - return returnedString; -} - -string translateEntity(DoxygenEntity &doxyEntity){ - if(doxyEntity.typeOfEntity.compare("plainstring")== 0 || doxyEntity.typeOfEntity.compare("deprecated")== 0 || doxyEntity.typeOfEntity.compare("brief")== 0) - return formatCommand(doxyEntity.data, 0) + "\n * "; - else if(doxyEntity.typeOfEntity.compare("see") == 0){ - return formatCommand(string("@" + doxyEntity.typeOfEntity + "\t\t" + translateSubtree(doxyEntity)), 2); - } - else if(doxyEntity.typeOfEntity.compare("return")== 0 - || doxyEntity.typeOfEntity.compare("author")== 0 - || doxyEntity.typeOfEntity.compare("param")== 0 - || doxyEntity.typeOfEntity.compare("since")== 0 - || doxyEntity.typeOfEntity.compare("version")== 0 - || doxyEntity.typeOfEntity.compare("exception") == 0 - || doxyEntity.typeOfEntity.compare("deprecated") == 0){ - return formatCommand(string("@" + doxyEntity.typeOfEntity + "\t" + translateSubtree(doxyEntity)), 2); - } - else if(doxyEntity.typeOfEntity.compare("sa")== 0){ - return formatCommand(string("@see\t\t" + translateSubtree(doxyEntity)), 2); - } - - return ""; -} - -string JavaDocConverter:: convertToJavaDoc(list <DoxygenEntity> entityList){ - - - entityList.sort(compare_DoxygenEntities); - if(printSortedTree2){ - cout << "---RESORTED LIST---" << endl; - printSortedTree(entityList); - } - - string javaDocString = "/**"; - - list<DoxygenEntity>::iterator entityIterator = entityList.begin(); - while (entityIterator != entityList.end()){ - javaDocString += translateEntity(*entityIterator); - entityIterator++; - } - - javaDocString += "\n */\n"; - cout << "\n---RESULT IN JAVADOC---" << endl; - cout << javaDocString; - return javaDocString; -} \ No newline at end of file Deleted: branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/JavaDocConverter.h =================================================================== --- branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/JavaDocConverter.h 2008-08-15 23:54:53 UTC (rev 10763) +++ branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/JavaDocConverter.h 2008-08-16 00:42:37 UTC (rev 10764) @@ -1,18 +0,0 @@ - #include <list> - #include <string> - #include "DoxygenEntity.h" - -#ifndef JAVADOCCONVERTER_H_ -#define JAVADOCCONVERTER_H_ - -class JavaDocConverter -{ -public: - - JavaDocConverter(); - string convertToJavaDoc(list <DoxygenEntity> entityList); - ~JavaDocConverter(); - void printSortedTree(list <DoxygenEntity> &entityList); -}; - -#endif /*JAVADOCCONVERTER_H_*/ Deleted: branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/Token.cpp =================================================================== --- branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/Token.cpp 2008-08-15 23:54:53 UTC (rev 10763) +++ branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/Token.cpp 2008-08-16 00:42:37 UTC (rev 10764) @@ -1,32 +0,0 @@ -#include "Token.h" -#include <cstdlib> -#include <iostream> -#include <string> -#include <list> -using namespace std; - - -Token::Token(int tType, string tString) -{ - tokenType = tType; - tokenString = tString; -} - -string Token::toString() -{ - if (tokenType == END_LINE){ - return "{END OF LINE}"; - } - if (tokenType == PARAGRAPH_END){ - return "{END OF PARAGRAPH}"; - } - if (tokenType == PLAINSTRING){ - return tokenString; - } - if (tokenType == COMMAND){ - return "{COMMAND : " + tokenString+ "}"; - } - return ""; -} - -Token:: ~Token(){} Deleted: branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/Token.h =================================================================== --- branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/Token.h 2008-08-15 23:54:53 UTC (rev 10763) +++ branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/Token.h 2008-08-16 00:42:37 UTC (rev 10764) @@ -1,21 +0,0 @@ -#ifndef TOKEN_H_ -#define TOKEN_H_ -#include <string> - -#define END_LINE 101 -#define PARAGRAPH_END 102 -#define PLAINSTRING 103 -#define COMMAND 104 -using namespace std; - -class Token -{ -public: - Token(int tType, string tString); - ~Token(); - int tokenType; /* currently can be END_LINE, PLAINSTRING, or COMMAND */ - string tokenString; /* the data , such as param for @param*/ - string toString(); -}; - -#endif /*TOKEN_H_*/ Deleted: branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/TokenList.cpp =================================================================== --- branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/TokenList.cpp 2008-08-15 23:54:53 UTC (rev 10763) +++ branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/TokenList.cpp 2008-08-16 00:42:37 UTC (rev 10764) @@ -1,114 +0,0 @@ -#include "TokenList.h" -#include <cstdlib> -#include <iostream> -#include <string> -#include <list> -#include "Token.h" -#define TOKENSPERLINE 8; //change this to change the printing behaviour of the token list -#define END_LINE 101 -#define PARAGRAPH_END 102 //not used at the moment -#define PLAINSTRING 103 -#define COMMAND 104 -using namespace std; - - -list <Token> tokenList; -list<Token>::iterator tokenListIterator; -int noisy2 = 0; -/* The tokenizer*/ - -TokenList::TokenList(string doxygenString){ - int currentIndex = 0; - //Regex whitespace("[ \t]+"); - //Regex newLine("[\n]"); - //Regex command("[@|\\]{1}[^ \t \n]+"); //the cheap solution - //Regex doxygenFluff("[/*!]+"); - int nextIndex = 0; - int isFluff = 0; - string currentWord; - while (currentIndex < doxygenString.length()){ - if(doxygenString[currentIndex] == '\n'){ - tokenList.push_back(Token(END_LINE, currentWord)); - currentIndex++; - } - while(currentIndex < doxygenString.length() && (doxygenString[currentIndex] == ' ' - || doxygenString[currentIndex]== '\t')) currentIndex ++; - if (currentIndex == doxygenString.length()) {} //do nothing since end of string was reached - else {nextIndex = currentIndex; - while (nextIndex < doxygenString.length() && (doxygenString[nextIndex] != ' ' - && doxygenString[nextIndex]!= '\t' && doxygenString[nextIndex]!= '\n')) nextIndex++; - currentWord = doxygenString.substr(currentIndex, nextIndex-currentIndex); - if(noisy2) cout << "Current Word: " << currentWord << endl; - if (currentWord[0] == '@' || currentWord[0] == '\\'){ - currentWord = currentWord.substr(1, currentWord.length()-1); - tokenList.push_back(Token(COMMAND, currentWord)); - } - else if (currentWord[0] == '\n'){ - //if ((tokenList.back()).tokenType == END_LINE){} - tokenList.push_back(Token(END_LINE, currentWord)); - - } - else if (currentWord[0] == '*' || currentWord[0] == '/' ||currentWord[0] == '!'){ - if (currentWord.length() == 1) {isFluff = 1;} - else { isFluff = 1; - for(int i = 1; i < currentWord.length(); i++){ - if (currentWord[0] != '*' && currentWord[0] != '/' && currentWord[0] != '!') isFluff = 0; - } - - } - if(!isFluff) tokenList.push_back(Token(PLAINSTRING, currentWord)); - } - - else tokenList.push_back(Token(PLAINSTRING, currentWord)); - currentIndex = nextIndex; - } - } - tokenListIterator = tokenList.begin(); -} - -Token TokenList::peek(){ - if(tokenListIterator!= tokenList.end()){ - Token returnedToken = (*tokenListIterator); - return returnedToken; - } - else - return Token(0, ""); -} - -Token TokenList::next(){ - if(tokenListIterator != tokenList.end()){ - Token returnedToken = (*tokenListIterator); - tokenListIterator++; - return (returnedToken); - } - else - return Token(0, ""); -} - -list<Token>::iterator TokenList::end(){ - return tokenList.end(); -} - -list<Token>::iterator TokenList::current(){ - return tokenListIterator; -} -void TokenList::printList(){ - list<Token>::iterator p = tokenList.begin(); - int i = 1; - int b = 0; - while (p != tokenList.end()){ - cout << (*p).toString() << " "; - b = i%TOKENSPERLINE; - if (b == 0) cout << endl; - p++; i++; - } -} - -list<Token>::iterator TokenList::iteratorCopy(){ - list<Token>::iterator p = tokenListIterator; - return p; -} -void TokenList::setIterator(list<Token>::iterator newPosition){ - tokenListIterator = newPosition; -} -TokenList:: ~TokenList(){} Deleted: branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/TokenList.h =================================================================== --- branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/TokenList.h 2008-08-15 23:54:53 UTC (rev 10763) +++ branches/gsoc2008-cherylfoil/Source/DoxygenTranslator/TokenList.h 2008-08-16 00:42:37 UTC (rev 10764) @@ -1,27 +0,0 @@ -#ifndef TOKENLIST_H_ -#define TOKENLIST_H_ -#include <cstdlib> -#include <iostream> -#include <string> -#include <list> -#include "Token.h" -using namespace std; - -/* a small class used to represent the sequence of tokens - * that can be derived from a formatted doxygen string - */ - -class TokenList{ -public: - TokenList(string doxygenString); /* constructor takes a blob of Doxygen comment */ - ~TokenList(); - Token peek(); /* returns next token without advancing */ - Token next(); /* returns next token and advances */ - list<Token>::iterator end(); /* returns an end iterator */ - list<Token>::iterator current(); /* returns the current iterator */ - void printList(); /* prints out the sequence of tokens */ - list<Token>::iterator iteratorCopy(); /* returns a copy of the current iterator */ - void setIterator(list<Token>::iterator newPosition); /*moves up the iterator*/ -}; - -#endif /*TOKENLIST_H_*/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |