From: <mrj...@us...> - 2008-02-09 20:24:10
|
Revision: 2539 http://tora.svn.sourceforge.net/tora/?rev=2539&view=rev Author: mrjohnson0 Date: 2008-02-09 12:24:05 -0800 (Sat, 09 Feb 2008) Log Message: ----------- adds isOperator, don't start a new line if keyword follows an operator Modified Paths: -------------- trunk/tora/src/tosqlparse.cpp Modified: trunk/tora/src/tosqlparse.cpp =================================================================== --- trunk/tora/src/tosqlparse.cpp 2008-02-09 20:23:16 UTC (rev 2538) +++ trunk/tora/src/tosqlparse.cpp 2008-02-09 20:24:05 UTC (rev 2539) @@ -637,6 +637,15 @@ return token; } +bool toSQLParse::isOperator(QString tok) { + for(int i = 0; Operators[i]; i++) { + if(tok == Operators[i] || tok == "<" || tok == ">") + return true; + } + + return false; +} + QString toSQLParse::stringTokenizer::remaining(bool eol) { QString ret; @@ -1259,6 +1268,8 @@ any = true; } + // set true if previous token was an operator + bool afterOperator = false; for (std::list<toSQLParse::statement>::iterator i = stat.subTokens().begin(); i != stat.subTokens().end(); i++) @@ -1267,7 +1278,7 @@ QString upp = (*i).String.toUpper(); #ifdef TOPARSE_DEBUG - printf("%s\n", (const char*)(*i).String.toLatin1()); + printf("%s\n", (*i).String.toAscii().constData()); #endif if ((*i).Type == statement::List) @@ -1341,7 +1352,7 @@ } any = false; } - else if (any && (*i).Type == statement::Keyword && !noKeyBreak) + else if (any && (*i).Type == statement::Keyword && !noKeyBreak && !afterOperator) { if (first) first = false; @@ -1460,6 +1471,8 @@ ) maxlev += t.length() + 1; } + + afterOperator = isOperator((*i).String); } if (stat.Type == statement::Statement) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mrj...@us...> - 2008-03-15 19:14:54
|
Revision: 2620 http://tora.svn.sourceforge.net/tora/?rev=2620&view=rev Author: mrjohnson0 Date: 2008-03-15 12:14:58 -0700 (Sat, 15 Mar 2008) Log Message: ----------- awesome, hard-coded indent level... Modified Paths: -------------- trunk/tora/src/tosqlparse.cpp Modified: trunk/tora/src/tosqlparse.cpp =================================================================== --- trunk/tora/src/tosqlparse.cpp 2008-03-15 18:12:49 UTC (rev 2619) +++ trunk/tora/src/tosqlparse.cpp 2008-03-15 19:14:58 UTC (rev 2620) @@ -1034,9 +1034,9 @@ QString ret; if (Settings.ExpandSpaces) { - for (int i = 0;i < level / 8;i++) + for (int i = 0;i < level / Settings.IndentLevel;i++) ret += ("\t"); - for (int j = 0;j < level % 8;j++) + for (int j = 0;j < level % Settings.IndentLevel;j++) ret += (" "); } else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <su...@us...> - 2008-03-17 15:36:50
|
Revision: 2626 http://tora.svn.sourceforge.net/tora/?rev=2626&view=rev Author: subik Date: 2008-03-17 08:36:41 -0700 (Mon, 17 Mar 2008) Log Message: ----------- debug outputs ported to Qt4 Modified Paths: -------------- trunk/tora/src/tosqlparse.cpp Modified: trunk/tora/src/tosqlparse.cpp =================================================================== --- trunk/tora/src/tosqlparse.cpp 2008-03-16 16:38:06 UTC (rev 2625) +++ trunk/tora/src/tosqlparse.cpp 2008-03-17 15:36:41 UTC (rev 2626) @@ -79,12 +79,12 @@ printf("Raw:"); break; } - printf("%s (%d)\n", (const char *)stat.String, stat.Line); + printf("%s (%d)\n", (const char *)stat.String.toUtf8(), stat.Line); if (!stat.Comment.isNull()) { for (int i = 0;i < level;i++) printf(" "); - printf("Comment:%s\n", (const char *)stat.Comment); + printf("Comment:%s\n", (const char *)stat.Comment.toUtf8()); } for (std::list<toSQLParse::statement>::iterator i = stat.subTokens().begin(); i != stat.subTokens().end(); @@ -365,12 +365,12 @@ QString firstparse = toSQLParse::indent(res); QString secondparse = toSQLParse::indent(firstparse); - printf("First\n\n%s\n", (const char *)firstparse); + printf("First\n\n%s\n", (const char *)firstparse.toUtf8()); if (firstparse != secondparse) { printf("Reparse doesn't match\n"); - printf("Second\n\n%s\n", (const char *)secondparse); + printf("Second\n\n%s\n", (const char *)secondparse.toUtf8()); } return 0; @@ -811,7 +811,7 @@ QString upp = token.toUpper(); #ifdef TOPARSE_DEBUG - printf("%s (%d)\n", (const char*)token, tokens.line()); + printf("%s (%d)\n", (const char*)token.toUtf8(), tokens.line()); #endif if (first.isNull() && !token.startsWith(("/*")) && !token.startsWith("--") && !token.startsWith("//")) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |