summaryrefslogtreecommitdiff
path: root/unit-tests/lexer/driver.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-04-08 14:51:57 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-04-27 11:38:53 +0300
commit720c5a33b6a49cf328fdd7611f49153cf8f60247 (patch)
tree9725f3d1f42ec90fde84520f49647edea013ce5e /unit-tests/lexer/driver.cxx
parent3183f3bb927a90783ae0aeaf190a0919377aabe4 (diff)
Separate tests and examples into individual packages
Also make cli module to be explicitly enabled via the config.cli configuration variable.
Diffstat (limited to 'unit-tests/lexer/driver.cxx')
-rw-r--r--unit-tests/lexer/driver.cxx122
1 files changed, 0 insertions, 122 deletions
diff --git a/unit-tests/lexer/driver.cxx b/unit-tests/lexer/driver.cxx
deleted file mode 100644
index f65bd2f..0000000
--- a/unit-tests/lexer/driver.cxx
+++ /dev/null
@@ -1,122 +0,0 @@
-// file : unit-tests/lexer/driver.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// license : MIT; see accompanying LICENSE file
-
-#include <fstream>
-#include <iostream>
-
-#include <cli/token.hxx>
-#include <cli/lexer.hxx>
-
-using namespace std;
-
-const char* keywords[] =
-{
- "source",
- "include",
- "namespace",
- "class",
- "signed",
- "unsigned",
- "bool",
- "char",
- "wchar_t",
- "short",
- "int",
- "long",
- "float",
- "double"
-};
-
-const char* punctuation[] = {
- ";", ",", ":", "::", "{", "}", /*"(", ")",*/ "=", "|"};
-
-int
-main (int argc, char* argv[])
-{
- if (argc != 2)
- {
- cerr << "usage: " << argv[0] << " file.cli" << endl;
- return 1;
- }
-
- ifstream ifs;
- ifs.exceptions (ifstream::failbit | ifstream::badbit);
- ifs.open (argv[1]);
-
- lexer l (ifs, argv[1]);
-
- while (true)
- {
- token t (l.next ());
-
- switch (t.type ())
- {
- case token::t_eos:
- {
- cout << "<EOS>" << endl;
- return 0;
- }
- case token::t_keyword:
- {
- cout << "keyword: " << keywords[t.keyword ()] << endl;
- break;
- }
- case token::t_identifier:
- {
- cout << "identifier: " << t.identifier () << endl;
- break;
- }
- case token::t_punctuation:
- {
- cout << punctuation[t.punctuation ()] << endl;
- break;
- }
- case token::t_cxx_path_lit:
- {
- cout << "c++ path: " << t.literal () << endl;
- break;
- }
- case token::t_cli_path_lit:
- {
- cout << "cli path: " << t.literal () << endl;
- break;
- }
- case token::t_string_lit:
- {
- cout << t.literal () << endl;
- break;
- }
- case token::t_char_lit:
- {
- cout << t.literal () << endl;
- break;
- }
- case token::t_bool_lit:
- {
- cout << t.literal () << endl;
- break;
- }
- case token::t_int_lit:
- {
- cout << t.literal () << endl;
- break;
- }
- case token::t_float_lit:
- {
- cout << t.literal () << endl;
- break;
- }
- case token::t_call_expr:
- {
- cout << t.expression () << endl;
- break;
- }
- case token::t_template_expr:
- {
- cout << t.expression () << endl;
- break;
- }
- }
- }
-}