lex: Added test harness for lexer

This commit is contained in:
Paul Beckingham 2016-04-10 10:34:52 -04:00
parent f9d7c97410
commit 0b9f25bfe0
4 changed files with 27 additions and 2 deletions

View file

@ -60,6 +60,6 @@ set (CPACK_SOURCE_PACKAGE_FILE_NAME ${PACKAGE_NAME}-${PACKAGE_VERSION})
set (CPACK_SOURCE_IGNORE_FILES "CMakeCache" "CMakeFiles" "CPackConfig" "CPackSourceConfig"
"_CPack_Packages" "cmake_install" "install_manifest" "Makefile$"
"test" "package-config" "src/timew$" "src/libtimew.a"
"src/commands/libcommands.a"
"src/commands/libcommands.a" "src/lex"
"/\\\\.gitignore" "/\\\\.git/" "swp$")
include (CPack)

4
src/.gitignore vendored
View file

@ -1,6 +1,8 @@
timew
gr
lex
*.a
CMakeFiles
Makefile
cmake_install.cmake
lr0
sax

View file

@ -41,10 +41,13 @@ set (libshared_SRCS libshared/src/Args.cpp libshared/src/Args.h
add_library (timew STATIC ${timew_SRCS})
add_library (libshared STATIC ${libshared_SRCS})
add_executable (timew_executable timew.cpp)
add_executable (lex_executable lex.cpp)
target_link_libraries (timew_executable timew libshared commands timew libshared ${TIMEW_LIBRARIES})
target_link_libraries (lex_executable timew libshared libshared ${TIMEW_LIBRARIES})
set_property (TARGET timew_executable PROPERTY OUTPUT_NAME "timew")
set_property (TARGET lex_executable PROPERTY OUTPUT_NAME "lex")
install (TARGETS timew_executable DESTINATION bin)

20
src/lex.cpp Normal file
View file

@ -0,0 +1,20 @@
////////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <Lexer.h>
int main (int argc, char** argv)
{
for (auto i = 1; i < argc; i++)
{
std::cout << "argument '" << argv[i] << "'\n";
Lexer l (argv[i]);
std::string token;
Lexer::Type type;
while (l.token (token, type))
std::cout << " token '" << token << "' " << Lexer::typeToString (type) << "\n";
}
}
////////////////////////////////////////////////////////////////////////////////