ProgrammingLanguageNr1.Parser.FunctionArgumentList C# (CSharp) Method

FunctionArgumentList() private method

private FunctionArgumentList ( ) : ProgrammingLanguageNr1.AST
return ProgrammingLanguageNr1.AST
        AST FunctionArgumentList()
        {
            match (Token.TokenType.PARANTHESIS_LEFT);

            AST argumentList = new AST (new Token (Token.TokenType.NODE_GROUP, "<ARGUMENT_LIST>"));
            if (lookAheadType (1) != Token.TokenType.PARANTHESIS_RIGHT) {
                while (true) {
                    AST expressionTree = expression ();
                    if (expressionTree != null) {
                        argumentList.addChild (expressionTree);
                        // add arguments as subtrees
                    }
                    else {
                        throw new Error ("Something is wrong with the argument list", Error.ErrorType.SYNTAX, lookAhead (1).LineNr, lookAhead (1).LinePosition);
                    }
                    if (lookAheadType (1) == Token.TokenType.COMMA) {
                        match (Token.TokenType.COMMA);
                        continue;
                    }
                    else {
                        // Is something wrong?
                        if (lookAheadType (1) == Token.TokenType.NEW_LINE || lookAheadType (1) == Token.TokenType.EOF) {
                            throw new Error ("Ending parenthesis is missing in function call", Error.ErrorType.SYNTAX, lookAhead (1).LineNr, lookAhead (1).LinePosition);
                        }
                        else
                            if (lookAheadType (1) == Token.TokenType.NAME || lookAheadType (1) == Token.TokenType.QUOTED_STRING || lookAheadType (1) == Token.TokenType.NUMBER) {
                                //throw new Error("A comma is missing in argument list", Error.ErrorType.SYNTAX, lookAhead(1).LineNr, lookAhead(1).LinePosition);
                                // allow missing commas in function call
                                continue;
                            }
                        break;
                    }
                }
            }
            match (Token.TokenType.PARANTHESIS_RIGHT);
            return argumentList;
        }