printing fixes

This commit is contained in:
ProgramSnail 2023-07-25 21:33:57 +03:00
parent 0bb72e0b10
commit 469cb3581f
23 changed files with 318 additions and 151 deletions

View file

@ -16,9 +16,10 @@ build_expression(parser::ParseTree::Node parser_node,
nodes::TypeStorage &type_storage) {
tokens::Type type = tokens::string_to_type(parser_node.get_type());
auto maybe_parenthesis = parser_node.next_sibling();
auto maybe_parenthesis = parser_node.previous_sibling();
bool is_scoped =
(!maybe_parenthesis.is_null() && maybe_parenthesis.get_value() == "(");
(!maybe_parenthesis.is_null() && !maybe_parenthesis.is_named() &&
maybe_parenthesis.get_value() == "(");
switch (type) {
// --- flow control
@ -119,6 +120,9 @@ build_expression(parser::ParseTree::Node parser_node,
case tokens::Type::NULL_LITERAL:
return expression_storage.add_expression(
nodes::Expression(build_null_literal(parser_node), is_scoped));
case tokens::Type::EMPTY_LINES:
return expression_storage.add_expression(
nodes::Expression(build_empty_lines(parser_node), is_scoped));
default:
error_handling::handle_parsing_error("Unexprected expression node type",
parser_node);
@ -271,7 +275,7 @@ build_comma_expression(parser::ParseTree::Node parser_node,
return nodes::NameExpression(
build_node(parser_node),
nodes::Identifier(
build_node(parser_node), // can't find more precise location'
build_node(parser_node), // can't find more precise location
nodes::Identifier::SIMPLE_NAME, ","),
std::move(arguments), std::nullopt, false, true);
}
@ -308,7 +312,7 @@ build_container(parser::ParseTree::Node parser_node,
nodes::Container::ContainerType container_type) {
std::vector<nodes::ExpressionProxy> expressions;
auto current_node = parser_node.nth_named_child(0).next_named_sibling();
auto current_node = parser_node.nth_named_child(0);
while (!current_node.is_null()) {
expressions.push_back(