Skip to content

Commit

Permalink
fix(parse): permit unbraced function expression as template argument
Browse files Browse the repository at this point in the history
  • Loading branch information
JohelEGP committed Aug 18, 2023
1 parent 5aa17f8 commit ef5b963
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions source/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ struct postfix_expression_node
if (ops.empty()) {
return false;
} else {
return (ops.front().op->type() == lexeme::Ampersand
return (ops.front().op->type() == lexeme::Ampersand
|| ops.front().op->type() == lexeme::Tilde);
}
}
Expand Down Expand Up @@ -3993,7 +3993,7 @@ class parser
// || curr().type() == lexeme::LeftBrace
)
{
bool inside_initializer = (
bool inside_initializer = (
peek(-1) && peek(-1)->type() == lexeme::Assignment
);
auto open_paren = &curr();
Expand All @@ -4015,12 +4015,12 @@ class parser
next();
if (
curr().type() != lexeme::Semicolon
&& curr().type() != lexeme::RightParen
&& curr().type() != lexeme::RightBracket
&& curr().type() != lexeme::RightParen
&& curr().type() != lexeme::RightBracket
&& curr().type() != lexeme::Comma
) {
expr_list->inside_initializer = false;
}
}
n->expr = std::move(expr_list);
return n;
}
Expand Down Expand Up @@ -4060,6 +4060,7 @@ class parser
&& curr().type() != lexeme::LeftParen // not imediatelly called
&& curr().type() != lexeme::RightParen // not as a last argument to function
&& curr().type() != lexeme::Comma // not as first or in-the-middle, function argument
&& curr().type() != lexeme::Greater // not as the last argument to template
&& curr().type() != lexeme::RightBracket // not as the last index argument
&& curr() != "is" // not as the argument to is
&& curr() != "as" // not as the argument to as
Expand Down Expand Up @@ -4382,7 +4383,7 @@ class parser
//G shift-expression '<<' additive-expression
//G shift-expression '>>' additive-expression
//G
auto shift_expression(bool allow_angle_operators = true)
auto shift_expression(bool allow_angle_operators = true)
-> auto
{
if (allow_angle_operators) {
Expand Down Expand Up @@ -4417,7 +4418,7 @@ class parser
//G shift-expression
//G compare-expression '<=>' shift-expression
//G
auto compare_expression(bool allow_angle_operators = true)
auto compare_expression(bool allow_angle_operators = true)
-> auto
{
return binary_expression<compare_expression_node> (
Expand All @@ -4433,7 +4434,7 @@ class parser
//G relational-expression '<=' compare-expression
//G relational-expression '>=' compare-expression
//G
auto relational_expression(bool allow_angle_operators = true)
auto relational_expression(bool allow_angle_operators = true)
-> auto
{
if (allow_angle_operators) {
Expand Down Expand Up @@ -4465,7 +4466,7 @@ class parser
//G equality-expression '==' relational-expression
//G equality-expression '!=' relational-expression
//G
auto equality_expression(bool allow_angle_operators = true)
auto equality_expression(bool allow_angle_operators = true)
-> auto
{
return binary_expression<equality_expression_node> (
Expand All @@ -4478,7 +4479,7 @@ class parser
//G equality-expression
//G bit-and-expression '&' equality-expression
//G
auto bit_and_expression(bool allow_angle_operators = true)
auto bit_and_expression(bool allow_angle_operators = true)
-> auto
{
return binary_expression<bit_and_expression_node> (
Expand All @@ -4491,7 +4492,7 @@ class parser
//G bit-and-expression
//G bit-xor-expression '^' bit-and-expression
//G
auto bit_xor_expression(bool allow_angle_operators = true)
auto bit_xor_expression(bool allow_angle_operators = true)
-> auto
{
return binary_expression<bit_xor_expression_node> (
Expand All @@ -4504,7 +4505,7 @@ class parser
//G bit-xor-expression
//G bit-or-expression '|' bit-xor-expression
//G
auto bit_or_expression(bool allow_angle_operators = true)
auto bit_or_expression(bool allow_angle_operators = true)
-> auto
{
return binary_expression<bit_or_expression_node> (
Expand All @@ -4517,7 +4518,7 @@ class parser
//G bit-or-expression
//G logical-and-expression '&&' bit-or-expression
//G
auto logical_and_expression(bool allow_angle_operators = true)
auto logical_and_expression(bool allow_angle_operators = true)
-> auto
{
return binary_expression<logical_and_expression_node> (
Expand All @@ -4532,7 +4533,7 @@ class parser
//G logical-and-expression
//G logical-or-expression '||' logical-and-expression
//G
auto logical_or_expression(bool allow_angle_operators = true)
auto logical_or_expression(bool allow_angle_operators = true)
-> auto
{
return binary_expression<logical_or_expression_node> (
Expand Down Expand Up @@ -4850,7 +4851,7 @@ class parser

n->open_angle = curr().position();
next();

auto term = unqualified_id_node::term{};

do {
Expand Down Expand Up @@ -6421,7 +6422,7 @@ class parser
}
assert (n->is_type());
}

// Or a function type, declaring a function - and tell the function whether it's in a user-defined type
else if (auto t = function_type(n.get(), named))
{
Expand Down Expand Up @@ -6569,11 +6570,11 @@ class parser
)
{
auto& type = std::get<declaration_node::an_object>(n->type);
// object initialized by the address of the curr() object
// object initialized by the address of the curr() object
if (peek(1)->type() == lexeme::Ampersand) {
type->address_of = &curr();
}
// object initialized by (potentially multiple) dereference of the curr() object
// object initialized by (potentially multiple) dereference of the curr() object
else if (peek(1)->type() == lexeme::Multiply) {
type->dereference_of = &curr();
for (int i = 1; peek(i)->type() == lexeme::Multiply; ++i)
Expand Down Expand Up @@ -6778,7 +6779,7 @@ class parser
return {};
}
if (
t->is_wildcard()
t->is_wildcard()
|| ( t->get_token() && t->get_token()->to_string(true) == "auto" )
) {
errors.emplace_back(
Expand Down

0 comments on commit ef5b963

Please sign in to comment.