private void ParseSubroutine()
        {
            Modifier modifiers;

            MemberName name;
            ParameterList paramList;

            TokenInfo token = tokenQueue.Dequeue();

            bool flag;

            modifiers = ParseMethodModifiers();

            name = ParseMemberName();
            paramList = ParseMethodParameters();

            TokenInfo token2 = Tokenizer.PeekToken();

            if (token.Is(Token.Handles))
            {
                FullNamedExpression expr = ParseTypeName();

                if (expr == null)
                {
                    Report.AddError("?", "Identifier expected.", token.SourceFile,
                                    new SourceSpan(token.GetSourceLocation(), default(SourceLocation)), null);
                }
            }

            TokenInfo token3 = statementSymbols.ElementAt(statementSymbols.Count() - 1);

            TokenList symbols = statementSymbols;

            ExpectEndOfStatementOrEat();

            method = new SubroutineDef((ClassStructOrModuleDef) type, name.BaseName, paramList, modifiers);

            flag = ParseSubroutineBlock();

            if (!flag)
            {
                Report.AddItem(VBErrors.EndSubExpected, SourceFile, token.GetSpan(token3), symbols);
            }

            paramList.SetMethod(method);
            method.SetBody(CloseBlock());
        }
        private void ParseFunction()
        {
            TokenInfo token = tokenQueue.Dequeue();

            Modifier modifiers;

            MemberName name;
            ParameterList paramList;
            FullNamedExpression returnType;

            bool flag;

            modifiers = ParseMethodModifiers();

            name = ParseMemberName();
            paramList = ParseMethodParameters();

            Expect(Token.As);
            returnType = ParseFullName();

            TokenInfo token2 = statementSymbols.ElementAt(statementSymbols.Count() - 1);

            TokenList symbols = statementSymbols;

            ExpectEndOfStatementOrEat();

            method = new FunctionDef((ClassStructOrModuleDef) type, name.BaseName, returnType, paramList, modifiers);

            flag = ParseFunctionBlock();

            if (!flag)
            {
                Report.AddItem(VBErrors.EndFunctionExpected, SourceFile, token.GetSpan(token2),
                               symbols);
            }

            paramList.SetMethod(method);
            method.SetBody(CloseBlock());
        }