mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +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
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