Skip to content

Commit

Permalink
HPCC-15018 Update reservedwords.cpp with missing reserved words
Browse files Browse the repository at this point in the history
Also adds a test for this invoked by 'eclcc -internal'

Signed-off-by: James Noss <[email protected]>
  • Loading branch information
jamienoss committed Mar 2, 2016
1 parent 341e2b8 commit 0f3790b
Show file tree
Hide file tree
Showing 7 changed files with 178 additions and 57 deletions.
2 changes: 0 additions & 2 deletions ecl/eclcc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
project( eclcc )

set ( SRCS
reservedwords.hpp
reservedwords.cpp
eclcc.hpp
eclcc.cpp
)
Expand Down
41 changes: 25 additions & 16 deletions ecl/eclcc/eclcc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ class EclCC : public CInterfaceOf<ICodegenContextCallback>
}

bool printKeywordsToXml();
bool parseCommandLineOptions(int argc, const char* argv[]);
int parseCommandLineOptions(int argc, const char* argv[]);
void loadOptions();
void loadManifestOptions();
bool processFiles();
Expand Down Expand Up @@ -435,8 +435,9 @@ static int doMain(int argc, const char *argv[])
return doSelfTest(argc, argv);

EclCC processor(argc, argv);
if (!processor.parseCommandLineOptions(argc, argv))
return 1;
int ret = processor.parseCommandLineOptions(argc, argv);
if (ret != 0)
return ret;

try
{
Expand Down Expand Up @@ -1893,12 +1894,12 @@ bool EclCC::allowAccess(const char * category, bool isSigned)
}

//=========================================================================================
bool EclCC::parseCommandLineOptions(int argc, const char* argv[])
int EclCC::parseCommandLineOptions(int argc, const char* argv[])
{
if (argc < 2)
{
usage();
return false;
return 1;
}

ArgvIterator iter(argc, argv);
Expand Down Expand Up @@ -1976,7 +1977,15 @@ bool EclCC::parseCommandLineOptions(int argc, const char* argv[])
else if (strcmp(arg, "-internal")==0)
{
outputSizeStmts();
testHqlInternals();
int error = testHqlInternals() + testReservedWords(); //NOTE: testReservedWords() depends on testHqlInternals() so must be be called after.
// report test result
if (error)
{
printf("%d error%s found!\n", error, error<=1?"":"s");
return 300;
}
else
printf("No errors\n");
}
else if (iter.matchFlag(tempBool, "-save-cpps"))
{
Expand Down Expand Up @@ -2076,7 +2085,7 @@ bool EclCC::parseCommandLineOptions(int argc, const char* argv[])
if (!checkFileExists(optIniFilename))
{
ERRLOG("Error: INI file '%s' does not exist",optIniFilename.get());
return false;
return 1;
}
}
else if (iter.matchFlag(optShowPaths, "-showpaths"))
Expand All @@ -2085,7 +2094,7 @@ bool EclCC::parseCommandLineOptions(int argc, const char* argv[])
else if (iter.matchOption(optManifestFilename, "-manifest"))
{
if (!isManifestFileValid(optManifestFilename))
return false;
return 1;
}
else if (iter.matchOption(tempArg, "-split"))
{
Expand All @@ -2094,7 +2103,7 @@ bool EclCC::parseCommandLineOptions(int argc, const char* argv[])
if (!split)
{
ERRLOG("Error: syntax is -split=part:splits\n");
return false;
return 1;
}
batchSplit = atoi(split+1);
if (batchSplit == 0)
Expand All @@ -2108,7 +2117,7 @@ bool EclCC::parseCommandLineOptions(int argc, const char* argv[])
else if (iter.matchOption(tempArg, "-platform") || /*deprecated*/ iter.matchOption(tempArg, "-target"))
{
if (!setTargetPlatformOption(tempArg.get(), optTargetClusterType))
return false;
return 1;
}
else if (iter.matchFlag(logVerbose, "-v") || iter.matchFlag(logVerbose, "--verbose"))
{
Expand All @@ -2118,7 +2127,7 @@ bool EclCC::parseCommandLineOptions(int argc, const char* argv[])
else if (strcmp(arg, "--version")==0)
{
fprintf(stdout,"%s %s\n", LANGUAGE_VERSION, BUILD_TAG);
return false;
return 1;
}
else if (startsWith(arg, "-Wc,"))
{
Expand Down Expand Up @@ -2150,15 +2159,15 @@ bool EclCC::parseCommandLineOptions(int argc, const char* argv[])
{
ERRLOG("Error: unrecognised option %s",arg);
usage();
return false;
return 1;
}
else
inputFileNames.append(arg);
}
if (showHelp)
{
usage();
return false;
return 1;
}

if (optComponentName.length())
Expand All @@ -2175,9 +2184,9 @@ bool EclCC::parseCommandLineOptions(int argc, const char* argv[])
if (inputFileNames.ordinality() == 0 && !optKeywords)
{
if (optGenerateHeader || optShowPaths || (!optBatchMode && optQueryRepositoryReference))
return true;
return 0;
ERRLOG("No input filenames supplied");
return false;
return 1;
}

if (optDebugMemLeak)
Expand All @@ -2187,7 +2196,7 @@ bool EclCC::parseCommandLineOptions(int argc, const char* argv[])
initLeakCheck(title);
}

return true;
return 0;
}

//=========================================================================================
Expand Down
54 changes: 28 additions & 26 deletions ecl/hql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,35 @@
project( hql )

set ( SRCS
hqlatoms.cpp
hqlattr.cpp
hqlatoms.cpp
hqlattr.cpp
hqlcollect.cpp
hqldesc.cpp
hqldsparam.cpp
hqlerror.cpp
hqlesp.cpp
hqlexpr.cpp
hqlfold.cpp
hqlgram2.cpp
hqlmanifest.cpp
hqlmeta.cpp
hqlopt.cpp
hqlparse.cpp
hqlpmap.cpp
hqldsparam.cpp
hqlerror.cpp
hqlesp.cpp
hqlexpr.cpp
hqlfold.cpp
hqlgram2.cpp
hqlmanifest.cpp
hqlmeta.cpp
hqlopt.cpp
hqlparse.cpp
hqlpmap.cpp
hqlplugininfo.cpp
hqlpregex.cpp
hqlpregex.cpp
hqlrepository.cpp
hqlscope.cpp
hqlstack.cpp
hqlthql.cpp
hqltrans.cpp
hqlscope.cpp
hqlstack.cpp
hqlthql.cpp
hqltrans.cpp
hqlusage.cpp
hqlutil.cpp
hqlutil.cpp
hqlir.cpp
hqlvalid.cpp
hqlwuerr.cpp
hqlxmldb.cpp
hqlvalid.cpp
hqlwuerr.cpp
hqlxmldb.cpp
reservedwords.cpp

hqlgram.y
hqllex.l
Expand Down Expand Up @@ -87,6 +88,7 @@ set ( SRCS
hqlvalid.hpp
hqlwuerr.hpp
hqlxmldb.hpp
reservedwords.hpp
)

include_directories (
Expand Down Expand Up @@ -134,11 +136,11 @@ ADD_DEFINITIONS( -D_USRDLL -DHQL_EXPORTS -DHQLFOLD_EXPORTS -DHQLTRANS_EXPORTS )

HPCC_ADD_LIBRARY( hql SHARED ${SRCS} ${CMAKE_CURRENT_BINARY_DIR}/hqlgram.cpp ${CMAKE_CURRENT_BINARY_DIR}/hqllex.cpp )
install ( TARGETS hql RUNTIME DESTINATION ${EXEC_DIR} LIBRARY DESTINATION ${LIB_DIR} )
target_link_libraries ( hql
target_link_libraries ( hql
jlib
nbcd
eclrtl
deftype
nbcd
eclrtl
deftype
${CPPUNIT_LIBRARIES}
)

Expand Down
3 changes: 2 additions & 1 deletion ecl/hql/hqlgram.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,7 @@ class HqlLex

IHqlExpression *reparseTemplateFunction(IHqlExpression * funcdef, IHqlScope *scope, HqlLookupContext & ctx, bool hasFieldMap);
extern HQL_API void resetLexerUniqueNames(); // to make regression suite consistent
extern HQL_API void testHqlInternals();
extern HQL_API int testHqlInternals();
extern HQL_API int testReservedWords();

#endif
40 changes: 31 additions & 9 deletions ecl/hql/hqlgram2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "hqlvalid.hpp"
#include "hqlrepository.hpp"
#include "hqlir.hpp"
#include "reservedwords.hpp"

#define ADD_IMPLICIT_FILEPOS_FIELD_TO_INDEX TRUE
#define FAST_FIND_FIELD
Expand Down Expand Up @@ -10551,7 +10552,7 @@ static void getTokenText(StringBuffer & msg, int token)
case ENCRYPT: msg.append("ENCRYPT"); break;
case ENCRYPTED: msg.append("ENCRYPTED"); break;
case END: msg.append("END"); break;
case ENDCPP: msg.append("ENDCPP"); break;
case ENDCPP: msg.append("ENDC++"); break;
case ENDEMBED: msg.append("ENDEMBED"); break;
case ENTH: msg.append("ENTH"); break;
case ENUM: msg.append("ENUM"); break;
Expand Down Expand Up @@ -10698,7 +10699,7 @@ static void getTokenText(StringBuffer & msg, int token)
case ONLY: msg.append("ONLY"); break;
case ONWARNING: msg.append("ONWARNING"); break;
case OPT: msg.append("OPT"); break;
case OR : msg.append("OR "); break;
case OR : msg.append("OR"); break;
case ORDER: msg.append("ORDER"); break;
case ORDERED: msg.append("ORDERED"); break;
case OUTER: msg.append("OUTER"); break;
Expand Down Expand Up @@ -11808,7 +11809,7 @@ void parseAttribute(IHqlScope * scope, IFileContents * contents, HqlLookupContex
attrCtx.noteEndAttribute();
}

void testHqlInternals()
int testHqlInternals()
{
printf("Sizes: const(%u) expr(%u) select(%u) dataset(%u) annotation(%u) prop(%u)\n",
(unsigned)sizeof(CHqlConstant),
Expand Down Expand Up @@ -11865,12 +11866,33 @@ void testHqlInternals()
}
}

//
// report test result
if (error)
printf("%d error%s found!\n", error, error<=1?"":"s");
else
printf("No errors\n");
return error;
}

int testReservedWords()
{
printf("Testing --keywords is complete...\n");
int error = 0;

for (int token = 258; token < YY_LAST_TOKEN; token++)
{
try
{
StringBuffer tokenText;
getTokenText(tokenText, token);
tokenText.toLowerCase();
if (!searchReservedWords(tokenText.str()))
{
error++;
printf(" Error: '%s' is missing from reservedWords.cpp\n", tokenText.str());
}
}
catch (...)
{
printf(" Error: complete test not possible - getTokenText() does not handle expected: %d\n", token);
}
}
return error;
}

IHqlExpression *HqlGram::yyParse(bool _parsingTemplateAttribute, bool catchAbort)
Expand Down
Loading

0 comments on commit 0f3790b

Please sign in to comment.