From: <ibr...@us...> - 2012-03-17 00:25:19
|
Revision: 4246 http://tora.svn.sourceforge.net/tora/?rev=4246&view=rev Author: ibre5041 Date: 2012-03-17 00:25:12 +0000 (Sat, 17 Mar 2012) Log Message: ----------- Modified Paths: -------------- branches/tora-trotl/sandbox.cpp/PLSQLLexer.g branches/tora-trotl/sandbox.cpp/UserTraits.hpp branches/tora-trotl/sandbox.cpp/t1.cpp Modified: branches/tora-trotl/sandbox.cpp/PLSQLLexer.g =================================================================== --- branches/tora-trotl/sandbox.cpp/PLSQLLexer.g 2012-03-16 15:27:00 UTC (rev 4245) +++ branches/tora-trotl/sandbox.cpp/PLSQLLexer.g 2012-03-17 00:25:12 UTC (rev 4246) @@ -213,10 +213,10 @@ /* C Syntax */ // ( { LA(1) != $delimiter->getText()->chars[0] || LA(2) != '\'' }? => . )* // ( { LA(1) == $delimiter->getText()->chars[0] && LA(2) == '\'' }? => . ) QUOTE +// { INPUT->istream->_LA = oldLA; } /* C++ Syntax */ ( { LA(1) != $delimiter->getText().at(0) || LA(2) != '\'' }? => . )* ( { LA(1) == $delimiter->getText().at(0) && LA(2) == '\'' }? => . ) QUOTE - // { INPUT->istream->_LA = oldLA; } ; Modified: branches/tora-trotl/sandbox.cpp/UserTraits.hpp =================================================================== --- branches/tora-trotl/sandbox.cpp/UserTraits.hpp 2012-03-16 15:27:00 UTC (rev 4245) +++ branches/tora-trotl/sandbox.cpp/UserTraits.hpp 2012-03-17 00:25:12 UTC (rev 4246) @@ -13,6 +13,8 @@ #include <antlr3.hpp> #include <algorithm> +#include <boost/algorithm/string/predicate.hpp> + namespace User { class PLSQLLexer; @@ -112,19 +114,29 @@ template<class StringType> inline bool enablesUsingClause(StringType const& originalFunctionName) { - StringType functionName = originalFunctionName; - std::transform(functionName.begin(), functionName.end(), functionName.begin(), ::toupper); - // if (functionName.startsWith("cluster_") || functionName.startsWith("feature_")) - // { - // return true; - // } + static const StringType cluster("CLUSTER_"); + static const StringType feature("FEATURE_"); + + // StringType functionName = originalFunctionName; + // std::transform(functionName.begin(), functionName.end(), functionName.begin(), ::toupper); + + if ( boost::algorithm::istarts_with(originalFunctionName, cluster) || boost::algorithm::istarts_with(originalFunctionName, feature)) + { + return true; + } return false; } template<class StringType> inline bool enablesOverClause(StringType const& originalFunctionName) { + static const StringType regr("REGR_"); + static const StringType stddev("STDDEV"); + static const StringType var("VAR_"); + static const StringType covar("COVAR_"); + StringType functionName = originalFunctionName; - std::transform(functionName.begin(), functionName.end(), functionName.begin(), ::toupper); + std::transform(functionName.begin(), functionName.end(), functionName.begin(), ::toupper); + if ( functionName == "AVG" || functionName == "CORR" || functionName == "LAG" @@ -137,10 +149,10 @@ || functionName == "ROW_NUMBER" || functionName == "SUM" || functionName == "VARIANCE" - // || functionName.startsWith("regr_") - // || functionName.startsWith("stddev") - // || functionName.startsWith("var_") - // || functionName.startsWith("covar_") + || boost::algorithm::istarts_with(originalFunctionName, regr) + || boost::algorithm::istarts_with(originalFunctionName, stddev) + || boost::algorithm::istarts_with(originalFunctionName, var) + || boost::algorithm::istarts_with(originalFunctionName, covar) ) { return true; @@ -151,10 +163,11 @@ template<class StringType> inline bool equalsIgnoreCase(StringType const& s1, const char* s2) { - //return !strcasecmp(s1.c_str(), s2); - StringType s1U = s1; + // return !strcasecmp(s1.c_str(), s2); + StringType s1U(s1); std::transform(s1U.begin(), s1U.end(), s1U.begin(), ::toupper); return s1U == s2; + // return iequals(s1, s2); } } Modified: branches/tora-trotl/sandbox.cpp/t1.cpp =================================================================== --- branches/tora-trotl/sandbox.cpp/t1.cpp 2012-03-16 15:27:00 UTC (rev 4245) +++ branches/tora-trotl/sandbox.cpp/t1.cpp 2012-03-17 00:25:12 UTC (rev 4246) @@ -41,8 +41,8 @@ #include <sys/types.h> #include "dirent.h" -#include <iostream> -#include <sstream> +#include <iostream> +#include <sstream> #include <fstream> #define DIRDELIM '/' @@ -217,8 +217,11 @@ // (Use antlr3AsciiFileStreamNew for UCS2/16bit input). // ///byIvan input = new PLSQLTraits::InputStreamType(fName, ANTLR_ENC_8BIT); - string data = slurp(string((const char*)fName)); - input = new PLSQLTraits::InputStreamType((const ANTLR_UINT8 *)data.c_str(), ANTLR_ENC_8BIT, data.length(), fName); + string data = slurp(string((const char*)fName)); + input = new PLSQLTraits::InputStreamType((const ANTLR_UINT8 *)data.c_str(), + ANTLR_ENC_8BIT, + strlen(data.c_str()), //data.length(), + fName); input->setUcaseLA(true); @@ -298,12 +301,12 @@ delete input; } -static string slurp(string const& fileName) { - ifstream ifs(fileName.c_str(), ios::in | ios::binary | ios::ate); - ifstream::pos_type fileSize = ifs.tellg(); - ifs.seekg(0, ios::beg); - - stringstream sstr; - sstr << ifs.rdbuf(); - return sstr.str(); -} +static string slurp(string const& fileName) { + ifstream ifs(fileName.c_str(), ios::in | ios::binary | ios::ate); + ifstream::pos_type fileSize = ifs.tellg(); + ifs.seekg(0, ios::beg); + + stringstream sstr; + sstr << ifs.rdbuf(); + return sstr.str(); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |