From 1d2c5ce39d12adcb584d586952a59e15f2495f67 Mon Sep 17 00:00:00 2001 From: Spartan322 Date: Sat, 2 Sep 2023 23:56:26 -0400 Subject: 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 --- src/headless/main.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/headless') 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(); 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(); 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; } -- cgit v1.2.3-56-ga3b1