diff options
author | Spartan322 <Megacake1234@gmail.com> | 2023-09-03 05:56:26 +0200 |
---|---|---|
committer | Spartan322 <Megacake1234@gmail.com> | 2023-09-05 21:29:31 +0200 |
commit | 1d2c5ce39d12adcb584d586952a59e15f2495f67 (patch) | |
tree | f7569029f45ec019b0387e63aa7b94d1da7cc03a /src/headless | |
parent | 238ab9dfaa8ec7a48142154d227605ae367d53d1 (diff) |
Add Node Line/Column Generator
Fix Errors.hpp dependency on v2script/Parser.hpp
Add node location print to headless/main.cpp
Add Node::line_col << operator
Add Node::cast_to
WARNING: Takes advantage of non-standard behavior in unordered_multimap
THIS IS A HACK FOR NOW
Only GCC unordered_multimap::equal_range sees elements backwards
Prefer moving off of unordered_multimap to something like EASTL hash_multimap
Diffstat (limited to 'src/headless')
-rw-r--r-- | src/headless/main.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/headless/main.cpp b/src/headless/main.cpp index c3ca8c2..2075d9b 100644 --- a/src/headless/main.cpp +++ b/src/headless/main.cpp @@ -81,6 +81,21 @@ int print_v2script_simple(const std::string_view path) { } } + parser.generate_node_location_map(); + + for (const auto& node : parser.get_file_node()->_statements) { + std::cout << node->get_type() << ": " << parser.get_node_begin(node.get()) << std::endl; + if (auto assign_node = node->cast_to<ovdl::v2script::ast::AssignNode>(); assign_node) { + auto lnode_ptr = assign_node->_initializer.get(); + std::cout << lnode_ptr->get_type() << " begin: " << parser.get_node_begin(lnode_ptr) << std::endl; + std::cout << lnode_ptr->get_type() << " end: " << parser.get_node_end(lnode_ptr) << std::endl; + if (auto list_node = lnode_ptr->cast_to<ovdl::v2script::ast::AbstractListNode>(); list_node) { + for (const auto& inode : list_node->_statements) { + std::cout << inode->get_type() << ": " << parser.get_node_begin(inode.get()) << std::endl; + } + } + } + } std::cout << parser.get_file_node() << std::endl; return EXIT_SUCCESS; } |