@@ -350,7 +350,7 @@ Result<ast::Node*, Error> Parser::parse_statement() {
350350 if (result.is_error ()) return result;
351351
352352 if (result.get_value ()->index () == ast::Call) {
353- if (std::get<ast::CallNode>(*result.get_value ()).identifier ->value == " subscript " ) {
353+ if (std::get<ast::CallNode>(*result.get_value ()).identifier ->value == " [] " ) {
354354 return this ->parse_index_assignment (result.get_value ());
355355 }
356356 else {
@@ -584,7 +584,11 @@ Result<ast::Node*, Error> Parser::parse_function() {
584584 // Check if function is - with just one argument
585585 if (function.identifier ->value == " -"
586586 && function.args .size () == 1 ) {
587- function.identifier ->value = " -[negation]" ;
587+ function.identifier ->value = " -:negation" ;
588+ }
589+ else if (function.identifier ->value == " []"
590+ && function.args [0 ]->is_mutable ) {
591+ function.identifier ->value = " []:mut" ;
588592 }
589593
590594 this ->ast .push_back (function);
@@ -658,7 +662,11 @@ Result<ast::Node*, Error> Parser::parse_interface() {
658662 // Check if interface is - with just one argument
659663 if (interface.identifier ->value == " -"
660664 && interface.args .size () == 1 ) {
661- interface.identifier ->value = " -[negation]" ;
665+ interface.identifier ->value = " -:negation" ;
666+ }
667+ else if (interface.identifier ->value == " []"
668+ && interface.args [0 ]->is_mutable ) {
669+ interface.identifier ->value = " []:mut" ;
662670 }
663671
664672 this ->ast .push_back (interface);
@@ -740,7 +748,11 @@ Result<ast::Node*, Error> Parser::parse_builtin() {
740748 // Check if builtin is - with just one argument
741749 if (builtin.identifier ->value == " -"
742750 && builtin.args .size () == 1 ) {
743- builtin.identifier ->value = " -[negation]" ;
751+ builtin.identifier ->value = " -:negation" ;
752+ }
753+ else if (builtin.identifier ->value == " []"
754+ && builtin.args [0 ]->is_mutable ) {
755+ builtin.identifier ->value = " []:mut" ;
744756 }
745757
746758 this ->ast .push_back (builtin);
@@ -1116,7 +1128,7 @@ Result<ast::Node*, Error> Parser::parse_index_assignment(ast::Node* index_access
11161128 // Parse index access
11171129 assignment.assignable = index_access;
11181130 ((ast::CallNode*) index_access)->args [0 ]->is_mutable = true ;
1119- ((ast::CallNode*) index_access)->identifier ->value = " subscript_mut " ;
1131+ ((ast::CallNode*) index_access)->identifier ->value = " []:mut " ;
11201132
11211133 // Parse equal
11221134 auto equal = this ->parse_token (token::Equal);
@@ -1649,7 +1661,7 @@ Result<ast::Node*, Error> Parser::parse_negation() {
16491661 auto identifier = this ->parse_identifier (token::Minus);
16501662 if (identifier.is_error ()) return identifier;
16511663 call.identifier = (ast::IdentifierNode*) identifier.get_value ();
1652- call.identifier ->value = " -[ negation] " ;
1664+ call.identifier ->value = " -: negation" ;
16531665
16541666 // Parse expression
16551667 auto arg = ast::CallArgumentNode {this ->current ().line , this ->current ().column };
@@ -1807,6 +1819,14 @@ Result<ast::Node*, Error> Parser::parse_function_identifier() {
18071819 if (this ->current () == token::LessEqual) return this ->parse_identifier (token::LessEqual);
18081820 if (this ->current () == token::Greater) return this ->parse_identifier (token::Greater);
18091821 if (this ->current () == token::GreaterEqual) return this ->parse_identifier (token::GreaterEqual);
1822+ if (this ->match ({token::LeftBracket, token::RightBracket})) {
1823+ auto identifier = ast::IdentifierNode {this ->current ().line , this ->current ().column };
1824+ identifier.value = " []" ;
1825+ this ->advance ();
1826+ this ->advance ();
1827+ this ->ast .push_back (identifier);
1828+ return this ->ast .last_element ();
1829+ }
18101830 return this ->parse_identifier (token::Identifier);
18111831}
18121832
@@ -1932,7 +1952,7 @@ Result<ast::Node*, Error> Parser::parse_index_access(ast::Node* expression) {
19321952
19331953 // Create identifier node
19341954 auto identifier = ast::IdentifierNode {this ->current ().line , this ->current ().column };
1935- identifier.value = " subscript " ;
1955+ identifier.value = " [] " ;
19361956 this ->ast .push_back (identifier);
19371957 index_access.identifier = (ast::IdentifierNode*) this ->ast .last_element ();
19381958
0 commit comments