mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-26 06:37:20 +02:00
Lex
- Added a 'lex' binary to test Lexer2.
This commit is contained in:
parent
21553d9044
commit
ae6024ef8b
3 changed files with 34 additions and 0 deletions
1
src/.gitignore
vendored
1
src/.gitignore
vendored
|
@ -3,3 +3,4 @@ Makefile.in
|
||||||
tw-*
|
tw-*
|
||||||
args
|
args
|
||||||
calc
|
calc
|
||||||
|
lex
|
||||||
|
|
|
@ -49,16 +49,19 @@ set (task_SRCS CLI.cpp CLI.h
|
||||||
add_library (task STATIC ${task_SRCS})
|
add_library (task STATIC ${task_SRCS})
|
||||||
add_executable (task_executable main.cpp)
|
add_executable (task_executable main.cpp)
|
||||||
add_executable (calc_executable calc.cpp)
|
add_executable (calc_executable calc.cpp)
|
||||||
|
add_executable (lex_executable lex.cpp)
|
||||||
|
|
||||||
# Yes, 'task' is included twice, otherwise linking fails on assorted OSes.
|
# Yes, 'task' is included twice, otherwise linking fails on assorted OSes.
|
||||||
target_link_libraries (task_executable task commands columns task ${TASK_LIBRARIES})
|
target_link_libraries (task_executable task commands columns task ${TASK_LIBRARIES})
|
||||||
target_link_libraries (calc_executable task commands columns task ${TASK_LIBRARIES})
|
target_link_libraries (calc_executable task commands columns task ${TASK_LIBRARIES})
|
||||||
|
target_link_libraries (lex_executable task commands columns task ${TASK_LIBRARIES})
|
||||||
|
|
||||||
set_property (TARGET task_executable PROPERTY OUTPUT_NAME "task")
|
set_property (TARGET task_executable PROPERTY OUTPUT_NAME "task")
|
||||||
|
|
||||||
install (TARGETS task_executable DESTINATION ${TASK_BINDIR})
|
install (TARGETS task_executable DESTINATION ${TASK_BINDIR})
|
||||||
|
|
||||||
set_property (TARGET calc_executable PROPERTY OUTPUT_NAME "calc")
|
set_property (TARGET calc_executable PROPERTY OUTPUT_NAME "calc")
|
||||||
|
set_property (TARGET lex_executable PROPERTY OUTPUT_NAME "lex")
|
||||||
|
|
||||||
#SET(CMAKE_BUILD_TYPE gcov)
|
#SET(CMAKE_BUILD_TYPE gcov)
|
||||||
#SET(CMAKE_CXX_FLAGS_GCOV "--coverage")
|
#SET(CMAKE_CXX_FLAGS_GCOV "--coverage")
|
||||||
|
|
30
src/lex.cpp
Normal file
30
src/lex.cpp
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <Lexer2.h>
|
||||||
|
#include <Context.h>
|
||||||
|
|
||||||
|
Context context;
|
||||||
|
|
||||||
|
int main (int argc, char** argv)
|
||||||
|
{
|
||||||
|
for (auto i = 1; i < argc; i++)
|
||||||
|
{
|
||||||
|
std::cout << "input '" << argv[i] << "'\n";
|
||||||
|
// Low-level tokens.
|
||||||
|
Lexer2 lexer (argv[i]);
|
||||||
|
std::string token;
|
||||||
|
Lexer2::Type type;
|
||||||
|
while (lexer.token (token, type))
|
||||||
|
std::cout << " token '" << token << "' " << Lexer2::typeToString (type) << "\n";
|
||||||
|
|
||||||
|
/*
|
||||||
|
// High-level tokens.
|
||||||
|
auto all = Lexer2::tokens (argv[i]);
|
||||||
|
for (auto token : Lexer2::tokens (argv[i]))
|
||||||
|
std::cout << " token '" << token.first << "' " << Lexer2::typeToString (token.second) << "\n";
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
Loading…
Add table
Add a link
Reference in a new issue