730730function Parser :expressionFunctionCall (scope , base )
731731 base = base or self :expressionIndex (scope );
732732
733- -- Function Passing self
734- if (consume (self , TokenKind .Symbol , " :" )) then
735- local passSelfFunctionName = expect (self , TokenKind .Ident ).value ;
736- local args = {};
737- if (is (self , TokenKind .String )) then
738- args = {
739- Ast .StringExpression (get (self ).value ),
740- };
741- elseif (is (self , TokenKind .Symbol , " {" )) then
742- args = {
743- self :tableConstructor (scope ),
744- };
745- else
746- expect (self , TokenKind .Symbol , " (" );
747- if (not is (self , TokenKind .Symbol , " )" )) then
748- args = self :exprList (scope );
749- end
750- expect (self , TokenKind .Symbol , " )" );
751- end
752-
753- local node = Ast .PassSelfFunctionCallExpression (base , passSelfFunctionName , args );
754-
755- -- the result of a function call can be indexed
756- if (is (self , TokenKind .Symbol , " ." ) or is (self , TokenKind .Symbol , " [" )) then
757- return self :expressionIndex (scope , node );
758- end
759-
760- -- The result of a function call can be a function that is again called
761- if (is (self , TokenKind .Symbol , " (" ) or is (self , TokenKind .Symbol , " :" ) or is (self , TokenKind .Symbol , " {" ) or is (self , TokenKind .String )) then
762- return self :expressionFunctionCall (scope , node );
763- end
764-
765- return node
766- end
767-
768733 -- Normal Function Call
769734 local args = {};
770735 if (is (self , TokenKind .String )) then
@@ -787,12 +752,12 @@ function Parser:expressionFunctionCall(scope, base)
787752 local node = Ast .FunctionCallExpression (base , args );
788753
789754 -- the result of a function call can be indexed
790- if (is (self , TokenKind .Symbol , " ." ) or is (self , TokenKind .Symbol , " [" )) then
755+ if (is (self , TokenKind .Symbol , " ." ) or is (self , TokenKind .Symbol , " [" ) or is ( self , TokenKind . Symbol , " : " ) ) then
791756 return self :expressionIndex (scope , node );
792757 end
793758
794759 -- The result of a function call can be a function that is again called
795- if (is (self , TokenKind .Symbol , " (" ) or is (self , TokenKind .Symbol , " : " ) or is ( self , TokenKind . Symbol , " {" ) or is (self , TokenKind .String )) then
760+ if (is (self , TokenKind .Symbol , " (" ) or is (self , TokenKind .Symbol , " {" ) or is (self , TokenKind .String )) then
796761 return self :expressionFunctionCall (scope , node );
797762 end
798763
@@ -820,6 +785,46 @@ function Parser:expressionIndex(scope, base)
820785 base = Ast .IndexExpression (base , expr );
821786 end
822787 end
788+
789+ -- Function Passing self
790+ if (consume (self , TokenKind .Symbol , " :" )) then
791+ local passSelfFunctionName = expect (self , TokenKind .Ident ).value ;
792+ local args = {};
793+ if (is (self , TokenKind .String )) then
794+ args = {
795+ Ast .StringExpression (get (self ).value ),
796+ };
797+ elseif (is (self , TokenKind .Symbol , " {" )) then
798+ args = {
799+ self :tableConstructor (scope ),
800+ };
801+ else
802+ expect (self , TokenKind .Symbol , " (" );
803+ if (not is (self , TokenKind .Symbol , " )" )) then
804+ args = self :exprList (scope );
805+ end
806+ expect (self , TokenKind .Symbol , " )" );
807+ end
808+
809+ local node = Ast .PassSelfFunctionCallExpression (base , passSelfFunctionName , args );
810+
811+ -- the result of a function call can be indexed
812+ if (is (self , TokenKind .Symbol , " ." ) or is (self , TokenKind .Symbol , " [" ) or is (self , TokenKind .Symbol , " :" )) then
813+ return self :expressionIndex (scope , node );
814+ end
815+
816+ -- The result of a function call can be a function that is again called
817+ if (is (self , TokenKind .Symbol , " (" ) or is (self , TokenKind .Symbol , " {" ) or is (self , TokenKind .String )) then
818+ return self :expressionFunctionCall (scope , node );
819+ end
820+
821+ return node
822+ end
823+
824+ -- The result of a function call can be a function that is again called
825+ if (is (self , TokenKind .Symbol , " (" ) or is (self , TokenKind .Symbol , " {" ) or is (self , TokenKind .String )) then
826+ return self :expressionFunctionCall (scope , base );
827+ end
823828
824829 return base ;
825830end
0 commit comments