- Added a 'lex' binary to test Lexer2.
This commit is contained in:
Paul Beckingham 2015-02-21 10:03:17 -08:00
parent 21553d9044
commit ae6024ef8b
3 changed files with 34 additions and 0 deletions

30
src/lex.cpp Normal file
View 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";
*/
}
}
////////////////////////////////////////////////////////////////////////////////