Skip to content

Vector instead of trees - #1

Open
detolly wants to merge 9 commits into
masterfrom
vector-instead-of-trees
Open

Vector instead of trees#1
detolly wants to merge 9 commits into
masterfrom
vector-instead-of-trees

Conversation

@detolly

@detolly detolly commented Jul 4, 2026

Copy link
Copy Markdown
Owner

No description provided.

detolly and others added 9 commits July 3, 2026 19:22
- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant