@@ -581,6 +581,12 @@ Result<ast::Node*, Error> Parser::parse_function() {
581581 }
582582 }
583583
584+ // Check if function is - with just one argument
585+ if (function.identifier ->value == " -"
586+ && function.args .size () == 1 ) {
587+ function.identifier ->value = " -[negation]" ;
588+ }
589+
584590 this ->ast .push_back (function);
585591 return this ->ast .last_element ();
586592}
@@ -649,6 +655,12 @@ Result<ast::Node*, Error> Parser::parse_interface() {
649655
650656 interface.return_type = type.get_value ();
651657
658+ // Check if interface is - with just one argument
659+ if (interface.identifier ->value == " -"
660+ && interface.args .size () == 1 ) {
661+ interface.identifier ->value = " -[negation]" ;
662+ }
663+
652664 this ->ast .push_back (interface);
653665 return this ->ast .last_element ();
654666}
@@ -725,6 +737,12 @@ Result<ast::Node*, Error> Parser::parse_builtin() {
725737 builtin.state = ast::FunctionGenericCompletelyTyped;
726738 }
727739
740+ // Check if builtin is - with just one argument
741+ if (builtin.identifier ->value == " -"
742+ && builtin.args .size () == 1 ) {
743+ builtin.identifier ->value = " -[negation]" ;
744+ }
745+
728746 this ->ast .push_back (builtin);
729747 return this ->ast .last_element ();
730748}
@@ -1522,16 +1540,6 @@ Result<ast::Node*, Error> Parser::parse_binary(int precedence) {
15221540
15231541 // Add identifier to call
15241542 call.identifier = (ast::IdentifierNode*) identifier.get_value ();
1525- // if (call.identifier->value == "==") call.identifier->value = "equal";
1526- // else if (call.identifier->value == "<") call.identifier->value = "less";
1527- // else if (call.identifier->value == "<=") call.identifier->value = "lessEqual";
1528- // else if (call.identifier->value == ">") call.identifier->value = "greater";
1529- // else if (call.identifier->value == ">=") call.identifier->value = "greaterEqual";
1530- // else if (call.identifier->value == "+") call.identifier->value = "add";
1531- // else if (call.identifier->value == "-") call.identifier->value = "subtract";
1532- // else if (call.identifier->value == "*") call.identifier->value = "multiply";
1533- // else if (call.identifier->value == "/") call.identifier->value = "divide";
1534- // else if (call.identifier->value == "%") call.identifier->value = "modulo";
15351543
15361544 // Add left node to call
15371545 this ->ast .push_back (left_node);
@@ -1641,7 +1649,7 @@ Result<ast::Node*, Error> Parser::parse_negation() {
16411649 auto identifier = this ->parse_identifier (token::Minus);
16421650 if (identifier.is_error ()) return identifier;
16431651 call.identifier = (ast::IdentifierNode*) identifier.get_value ();
1644- call.identifier ->value = " negate " ;
1652+ call.identifier ->value = " -[negation] " ;
16451653
16461654 // Parse expression
16471655 auto arg = ast::CallArgumentNode {this ->current ().line , this ->current ().column };
0 commit comments