Vector instead of trees - #1
Open
detolly wants to merge 9 commits into
Open
Conversation
- Rename struct var → factor, type var_impl → var, concept var_impl_type → var_type - Change exponentiation base/exponent from unique_ptr<expression> to unique_ptr<var> - Add make_term, make_expression, make_factor, make_unique_factor helpers - Rename copy_var→copy_factor, copy_var_impl→copy_var - Replace incomplete node_hasher with complete hash_var_value, hash_term_value, hash_expr_value, hash_factor functions and hash<T> specializations Parser: - Template parse_result<T> for type-safe returns per AST node type - Replace op_node tree with flat expression→term→factor→var structure - Add #include <math.hpp> for function name lookup - Replace make_parse_result_node/make_parse_error with generic make_error<R> - Fix PROPAGATE_ERROR to properly forward errors via std::unexpected Other: - common.hpp: fix PROPAGATE_ERROR to forward error instead of entire expected - math.hpp: add pow(const number&, const number&) overload - number.hpp: fix formatter specialization placement inside include guard
node.hpp: - Change function_call::arguments from vector<expression> to vector<var> - Swap negated/inverse enum order so no=0, yes=1 - Remove make_expression overloads (unused after var-based exponentiation) - Fix copy_function_call and hash_var_value for new argument type - Rename shadowed lambda parameter n→n2 parser.hpp: - Rename current_token_is→current_token_if_current_token_is_of_type - Change parse_function_call param from string_view to const string& - Avoid redundant string copy in function_call construction - Tweak error message: 'Expected expression'→'Empty input'
Remove the factor/var split. value now directly holds its variant
impl along with negated and inverse flags, replacing the two-layer
factor{negated,inverse,var{impl}} indirection.
- Replace factor/var types with value in parser.hpp - Replace make_var with make_value (adds negated/inverse flags) - Fix variable shadowing in parse_factor() - Update print.hpp enum refs (factor::negated→value::negated) - Add .value accessor for visit/holds_alternative
- Add tree_printer struct to print.hpp for indented AST output - Every value node shows its neg/inv flags - Use tree_printer::print in parser.cpp instead of flat print_tree
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.