ProgrammingLanguageNr1.Parser.dotNotationExpression C# (CSharp) Method

dotNotationExpression() private method

private dotNotationExpression ( ) : ProgrammingLanguageNr1.AST
return ProgrammingLanguageNr1.AST
        private AST dotNotationExpression()
        {
            #if WRITE_DEBUG_INFO
            Console.WriteLine("dot notation expression");
            #endif

            AST lhs = parenthesisExpression();

            if ( lookAhead(1).getTokenType() == Token.TokenType.DOT)
            {
                match (Token.TokenType.DOT);

                #if WRITE_DEBUG_INFO
                Console.WriteLine("It's a dot notation expression!!! for example: object.f(a, b)");
                #endif

                Token nameToken = match(Token.TokenType.NAME);

                AST functionCallTree =
                    new AST_FunctionCall(new Token(Token.TokenType.FUNCTION_CALL, "RemoteFunctionCall", nameToken.LineNr, nameToken.LinePosition));

                // These are the argument sent through the remote function call
                AST innerArgumentList = FunctionArgumentList ();

                // The call to RemoteFunctionCall always takes three args: <id>, <functionName> & <args>
                AST argumentList = new AST (new Token (Token.TokenType.NODE_GROUP, "<ARGUMENT_LIST>"));

                // <ID>
                argumentList.addChild (lhs); // use whatever is on the left side of the dot in the function (method rather) call (.)
                //Console.WriteLine ("Method call ID: ");
                //(new ASTPainter()).PaintAST(lhs);

                // <FunctionName>
                Token functionNameToken = new TokenWithValue (
                    Token.TokenType.QUOTED_STRING,
                    nameToken.getTokenString (),
                    nameToken.LineNr,
                    nameToken.LinePosition,
                    nameToken.getTokenString());

                argumentList.addChild (new AST(functionNameToken));

                // <args>
                AST_ArrayEndSignal argsArray = new AST_ArrayEndSignal(new Token(Token.TokenType.ARRAY_END_SIGNAL, "<ARRAY>"));
                //Console.WriteLine ("Inner args:");
                foreach (var child in innerArgumentList.getChildren()) {
                    //Console.WriteLine (child.getTokenString ());
                    argsArray.addChild (child);
                }
                argsArray.ArraySize = innerArgumentList.getChildren().Count; // DAMNIT DON'T FORGET THIS ONE
                argumentList.addChild (argsArray); // send the arguments as an array to RemoteFunctionCall

                functionCallTree.addChild(argumentList);
                return functionCallTree;
            } else {
                return lhs;
            }
        }