From 1d6f877864f3c1e8c04a2be8cb007fc598360642 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Sat, 5 Sep 2026 16:42:34 +0000 Subject: fix typo --- ast.cc | 93 -------------------------------------------------- include/lexer/ast.h | 6 ++-- include/lexer/shared.h | 2 +- include/lexer/token.h | 6 ++-- module-test/ast.cc | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 100 insertions(+), 100 deletions(-) delete mode 100644 ast.cc create mode 100644 module-test/ast.cc diff --git a/ast.cc b/ast.cc deleted file mode 100644 index 4e92969..0000000 --- a/ast.cc +++ /dev/null @@ -1,93 +0,0 @@ -// TEST FILE -// ONLY FOR DEMONSTRATION -// will be removed as soon as parser is completed - - -#include -#include -#include -#include -#include -#include -#include - -#include "magic_enum/magic_enum.hpp" - -#include "parser/shared.h" -#include "parser/ast.h" -#include "parser/enum_type.h" -#include "parser/token.h" - -using namespace std; -using namespace ov4; - -constexpr int MAXLINE = 1024; - - - - -int main() -{ - int test_case = 5; - string s; - - switch (test_case) - { - case 0: - s = "hello | hi || foo && bar || baz &"; - break; - case 1: - s = "hi"; - break; - case 2: - s = "&&"; - break; - case 3: - s = "hi (hello || foo)"; - break; - case 4: - s = "alpha || beta (gamma argument && (delta || epsilon second_argument & ) )"; - break; - case 5: - s = "alpha || beta && (gamma || epsilon)"; - break; - default: - return 0; - } - - - - tokenizer(s); - cout << "---------- tokenizer ----------" << endl; - for (auto c : token) - { - if (c.token_type == LOGIC_AND) - println("{} LOGIC_AND", c.bracket_depth); - else if (c.token_type == LOGIC_OR) - println("{} LOGIC_OR", c.bracket_depth); - else if (c.token_type == ASYNC) - println("{} ASYNC", c.bracket_depth); - else if (c.token_type == PIPE) - println("{} PIPE", c.bracket_depth); - else if (c.token_type == LEFT_BRACKET) - println("{} LEFT_BRACKET", c.bracket_depth); - else if (c.token_type == RIGHT_BRACKET) - println("{} RIGHT_BRACKET", c.bracket_depth); - else if (c.token_type == TEXT) - println("{} TEXT .{}.", c.bracket_depth, c.text); - } - - cout << "---------- parse ----------" << endl; - - parse(0, token.size(), alloc_ast()); - - cout << "---------- AST ----------" << endl; - for (size_t i = 0; i < ast.size(); i++) - { - print("{}: type: {} left: {} right: {}", i, magic_enum::enum_name(ast[i].token_type), ast[i].left, ast[i].right); - if (ast[i].token_type == TEXT) - print(" command: {}", ast[i].command_text); - println(); - } - return 0; -} diff --git a/include/lexer/ast.h b/include/lexer/ast.h index 05ba553..59c1e4b 100644 --- a/include/lexer/ast.h +++ b/include/lexer/ast.h @@ -2,9 +2,9 @@ #include -#include "parser/enum_type.h" -#include "parser/token.h" -#include "parser/shared.h" +#include "lexer/enum_type.h" +#include "lexer/token.h" +#include "lexer/shared.h" using namespace std; // remove this diff --git a/include/lexer/shared.h b/include/lexer/shared.h index 01f1483..eadef14 100644 --- a/include/lexer/shared.h +++ b/include/lexer/shared.h @@ -3,7 +3,7 @@ #include #include -#include "parser/enum_type.h" +#include "lexer/enum_type.h" namespace ov4 { diff --git a/include/lexer/token.h b/include/lexer/token.h index 5b65d67..5494009 100644 --- a/include/lexer/token.h +++ b/include/lexer/token.h @@ -1,9 +1,9 @@ #pragma once -#include +#include lexer -#include "parser/enum_type.h" -#include "parser/shared.h" +#include "lexer/enum_type.h" +#include "lexer/shared.h" using namespace std; // remove this diff --git a/module-test/ast.cc b/module-test/ast.cc new file mode 100644 index 0000000..f9dcbb8 --- /dev/null +++ b/module-test/ast.cc @@ -0,0 +1,93 @@ +// TEST FILE +// ONLY FOR DEMONSTRATION +// will be removed as soon as lexer is completed + + +#include +#include +#include +#include +#include +#include +#include + +#include "magic_enum/magic_enum.hpp" + +#include "lexer/shared.h" +#include "lexer/ast.h" +#include "lexer/enum_type.h" +#include "lexer/token.h" + +using namespace std; +using namespace ov4; + +constexpr int MAXLINE = 1024; + + + + +int main() +{ + int test_case = 5; + string s; + + switch (test_case) + { + case 0: + s = "hello | hi || foo && bar || baz &"; + break; + case 1: + s = "hi"; + break; + case 2: + s = "&&"; + break; + case 3: + s = "hi (hello || foo)"; + break; + case 4: + s = "alpha || beta (gamma argument && (delta || epsilon second_argument & ) )"; + break; + case 5: + s = "alpha || beta && (gamma || epsilon)"; + break; + default: + return 0; + } + + + + tokenizer(s); + cout << "---------- tokenizer ----------" << endl; + for (auto c : token) + { + if (c.token_type == LOGIC_AND) + println("{} LOGIC_AND", c.bracket_depth); + else if (c.token_type == LOGIC_OR) + println("{} LOGIC_OR", c.bracket_depth); + else if (c.token_type == ASYNC) + println("{} ASYNC", c.bracket_depth); + else if (c.token_type == PIPE) + println("{} PIPE", c.bracket_depth); + else if (c.token_type == LEFT_BRACKET) + println("{} LEFT_BRACKET", c.bracket_depth); + else if (c.token_type == RIGHT_BRACKET) + println("{} RIGHT_BRACKET", c.bracket_depth); + else if (c.token_type == TEXT) + println("{} TEXT .{}.", c.bracket_depth, c.text); + } + + cout << "---------- parse ----------" << endl; + + parse(0, token.size(), alloc_ast()); + + cout << "---------- AST ----------" << endl; + for (size_t i = 0; i < ast.size(); i++) + { + print("{}: type: {} left: {} right: {}", i, magic_enum::enum_name(ast[i].token_type), ast[i].left, ast[i].right); + if (ast[i].token_type == TEXT) + print(" command: {}", ast[i].command_text); + println(); + } + return 0; +} -- cgit v1.3.1-4-g156e