ProgrammingLanguageNr1.Parser.parenthesisExpression C# (CSharp) Method

parenthesisExpression() private method

private parenthesisExpression ( ) : ProgrammingLanguageNr1.AST
return ProgrammingLanguageNr1.AST
        private AST parenthesisExpression()
        {
            #if WRITE_DEBUG_INFO
            Console.WriteLine("parenthesis expression");
            #endif
            AST lhs;

            if (lookAheadType(1) == Token.TokenType.PARANTHESIS_LEFT) {
            #if WRITE_DEBUG_INFO
            Console.WriteLine("paranthesis left");
            #endif
                match(Token.TokenType.PARANTHESIS_LEFT);
                lhs = expression();
            #if WRITE_DEBUG_INFO
            Console.WriteLine("paranthesis right");
            #endif
                match(Token.TokenType.PARANTHESIS_RIGHT);
            } else {
                return operand();
            }

            if (lookAheadType(1) == Token.TokenType.OPERATOR) { // two parenthesis expressions with an operator between them
                Token operatorToken = match(Token.TokenType.OPERATOR);

                AST rightParenthesisTree = expression();

                AST duoParenthesisTree = new AST(operatorToken);
                duoParenthesisTree.addChild(lhs);
                duoParenthesisTree.addChild(rightParenthesisTree);
                return duoParenthesisTree;
            } else {
                return lhs;
            }
        }